4G模块使用的SIMTECH 的SIM7100C,SIM7100C带有UART和USB接口,在考虑速度上我们使用USB接口和ARM进行通信。所以向linux内核添加3G模块的驱动(USB转串口驱动)和PPP协议的支持,然后编译内核并下载到开发板。
1. 编译内核
◇ 大容量存储驱动
> Device Drivers > USB support
make ARCH=arm menuconfig配置USB驱动:
<*>
[*]
<*>
[*]
<*>
◇ USB驱动
> Device Drivers > USB support
<*>
<*>
[*]
<*>
◇ PPP驱动
> Device Drivers > Network device support
<*>
[*]
2. 交叉编译libusb
下载usblib库和libusb-compat
https://sourceforge.net/projects/libusb/files/
root@zhaoxc-VBox:/opt/usb-tools/libusb-1.0.20# mkdir install
configure: error: "udev support requested but libudev not installed"(解决:添加--disable-udev)
root@zhaoxc-VBox:/opt/usb-tools/libusb-1.0.20# ./configure --host=arm-none-linux-gnueabi --prefix=/opt/usb-tools/libusb-1.0.20/install --disable-udev
root@zhaoxc-VBox:/opt/usb-tools/libusb-1.0.20# make
root@zhaoxc-VBox:/opt/usb-tools/libusb-1.0.20# make install
添加环境变量 http://www.linuxidc.com/Linux/2011-03/33432.htm(PKG_CONFIG_PATH设置)
root@zhaoxc-VBox:/opt/usb-tools/libusb-1.0.20# export PKG_CONFIG_PATH=/opt/usb-tools/libusb-1.0.20/install/lib/pkgconfig:$PKG_CONFIG_PATH
root@zhaoxc-VBox:/opt/usb-tools/libusb-1.0.20# echo $PKG_CONFIG_PATH
编译libusb-compat:
root@zhaoxc-VBox:/opt/usb-tools/libusb-compat-0.1.5# ./configure --host=arm-none-linux-gnueabi --prefix=/opt/usb-tools/libusb-compat-0.1.5/install
root@zhaoxc-VBox:/opt/usb-tools/libusb-compat-0.1.5# make
root@zhaoxc-VBox:/opt/usb-tools/libusb-compat-0.1.5# make install
将生成的libusb-1.0.20和libusb-compat-0.1.5下的库文件复制到ARM板上的linux的/lib下面即可。
3. 交叉编译4G模块驱动
交叉编译GobiSerial.c(ARCH=arm CC=arm-none-linux-gnueabi-gcc),得到GobiSerial.ko。复制到ARM板安装驱动
#insmod GobiSerial.ko
4. 查看驱动运行状况
插上4G模块,虚拟出6个ttyUSB,它们分别是:
root@am335x-evm:/# ls /dev/ttyUSB*
/dev/ttyUSB0
1) /dev/ttyUSB0-diag port for output developing messages
2) /dev/ttyUSB1- NMEA port for GPS NMEA data output
3) /dev/ttyUSB2-AT port for AT commands
4) /dev/ttyUSB3-Modem port for ppp-dial
5) /dev/ttyUSB4-audio port
6) /dev/ttyUSB5-Virtual Net card
插上U盘,提示设备运行:
[75097.986054] usb 2-1: New USB device found, idVendor=058f, idProduct=6387
[75097.993167] usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[75098.000689] usb 2-1: Product: Mass Storage
[75098.004995] usb 2-1: Manufacturer: Generic
[75098.009342] usb 2-1: SerialNumber: AC3DF2EE
[75098.024341] usb-storage 2-1:1.0: USB Mass Storage device detected
[75098.049922] scsi0 : usb-storage 2-1:1.0
lsusb命令查看结果:
Bus 001 Device 002: ID 1e0e:9001
Bus 002 Device 002: ID 058f:6387
Bus 001 Device 001: ID 1d6b:0002
Bus 002 Device 001: ID 1d6b:0002
5. 交叉编译PPP
参见:http://blog.sina.com.cn/s/blog_7880d3350102wb3e.html
6. 拨号脚本设置
root@am335x-evm:/etc/ppp# vi gprs-connect-chat
#Chat script for China Mobile, used SIMCOM sim4100 TD module.
TIMEOUT 15
ABORT "DELAYED"
ABORT "BUSY"
ABORT "ERROR"
ABORT "NO DIALTONE"
ABORT "NO CARRIER"
TIMEOUT 40
'' \rAT
OK ATS0=0
OK ATE0V1
OK AT+CGDCONT=1,"IP","CMNET"
OK AT+CGEQREQ=1,2,128,384,,,0,,,,,,
OK ATDT*99*1#
CONNECT
root@am335x-evm:/etc/ppp/peers# vi gprsdial
#/etc/ppp/peers/gprsdial
# This is pppd script for China Mobile, used SIMCOM SIM7100 Module
# Usage: root>pppd call gprs
#Interface should be used is the interface which connects physics interface of S
/dev/ttyUSB3
115200
crtscts
modem
#noauth
debug
nodetach
#hide-password
usepeerdns
noipdefault
defaultroute
user "cmnet"
0.0.0.0:0.0.0.0
#ipcp-accept-local
#ipcp-accept-remote
#lcp-echo-failure 12
#lcp-echo-interval 3
#noccp
#novj
#novjccomp
#persist
connect '/usr/sbin/chat -s -v -f /etc/ppp/gprs-connect-chat'
#disconnect '/bin/chat -v -f /etc/ppp/gprs-disconnect-chat'
6. 拨号
root@am335x-evm: pppd call gprsdial
6. 测试
拨号之后进行测试,发现可以ping通ip但是无法ping通域名。这需要设置/etc/resolv.conf来添加DNS解析服务器的地址
文件/etc/resolv.conf配置DNS客户,它包含了主机的域名搜索顺序和DNS服务器的地址,每一行应包含一个关键字和一个或多个的由空格隔开的参数。下面是一个例子文件:
domain test.com
search www.test.com test.com
nameserver 202.96.128.86
nameserver 202.96.128.166
nameserver
domain
search
sortlist
主要是nameserver关键字,如果没指定nameserver就找不到DNS服务器,其它关键字是可选的。
ameserver 114.114.114.114
nameserver 8.8.8.8
参考文档:
How to use the SIM7100 module in Linux.pdf
http://blog.csdn.net/hanmengaidudu/article/details/17099737
http://www.linuxidc.com/Linux/2011-03/33430p2.htm
http://www.linuxidc.com/Linux/2011-03/33430.htm
上一篇:初学者拿到2440、6410 等开发板应该怎么学习?
下一篇:在ARM上安装minicom及“error: conflicting types for 'getline'”解决
推荐阅读最新更新时间:2024-03-16 14:51