新聞中心

EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 在ARM-linux上實(shí)現(xiàn)4G模塊PPP撥號(hào)上網(wǎng)

在ARM-linux上實(shí)現(xiàn)4G模塊PPP撥號(hào)上網(wǎng)

作者: 時(shí)間:2016-11-20 來(lái)源:網(wǎng)絡(luò) 收藏
在ARM平臺(tái)上實(shí)現(xiàn)4G模塊PPP撥號(hào)上網(wǎng),參考網(wǎng)上的資料和自己的理解,從一無(wú)所知到開(kāi)發(fā)完成花了一周多。最后看到ARM板ping通www.baidu.com時(shí)甚是高興,現(xiàn)將此過(guò)程整理如下。當(dāng)然,除此之外要做的工作還有很多。
4G模塊使用的SIMTECH 的SIM7100C,SIM7100C帶有UART和USB接口,在考慮速度上我們使用USB接口和ARM進(jìn)行通信。所以向linux內(nèi)核添加3G模塊的驅(qū)動(dòng)(USB轉(zhuǎn)串口驅(qū)動(dòng))和PPP協(xié)議的支持,然后編譯內(nèi)核并下載到開(kāi)發(fā)板。
1. 編譯內(nèi)核
◇ 大容量存儲(chǔ)驅(qū)動(dòng)
> Device Drivers > USB support
make ARCH=arm menuconfig配置USB驅(qū)動(dòng):
<*> USB Mass Storage support
[*] USB Mass Storage verbose debug
<*> Realtek Card Reader support
[*] Realtek Card Reader autosuspend support
<*> Datafab Compact Flash Reader support
◇ USB驅(qū)動(dòng)
> Device Drivers > USB support
<*> Inventra Highspeed Dual Role Controller (TI, ADI, ...)
MUSB Mode Selection (Dual Role mode) --->
<*> Platform Glue Layer (TI DSPS platforms) --->
MUSB DMA mode (Disable DMA (always use PIO)) --->
<*> USB Serial Converter support --->
[*] USBGeneric Serial Driver
<*> USBdriver for GSM and CDMA modems
◇ PPP驅(qū)動(dòng)
> Device Drivers > Network device support
<*> PPP (point-to-point protocol) support
<*> PPP BSD-Compress compression
<*> PPP Deflate compression
[*] PPP filtering
<*> PPP MPPE compression (encryption)
[*] PPP multilink support
<*> PPP over Ethernet
<*> PPP support for async serial ports
<*> PPP support for sync tty ports
<*> SLIP (serial line) support
[*] CSLIP compressed headers

2. 交叉編譯libusb
下載usblib庫(kù)和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

添加環(huán)境變量 http://www.linuxidc.com/Linux/2011-03/33432.htm(PKG_CONFIG_PATH設(shè)置)
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下的庫(kù)文件復(fù)制到ARM板上的linux的/lib下面即可。

3. 交叉編譯4G模塊驅(qū)動(dòng)
交叉編譯GobiSerial.c(ARCH=arm CC=arm-none-linux-gnueabi-gcc),得到GobiSerial.ko。復(fù)制到ARM板安裝驅(qū)動(dòng)
#insmod GobiSerial.ko

4. 查看驅(qū)動(dòng)運(yùn)行狀況
插上4G模塊,虛擬出6個(gè)ttyUSB,它們分別是:
root@am335x-evm:/# ls /dev/ttyUSB*
/dev/ttyUSB0 /dev/ttyUSB1 /dev/ttyUSB2 /dev/ttyUSB3 /dev/ttyUSB4 /dev/ttyUSB5
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盤,提示設(shè)備運(yùn)行:
[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命令查看結(jié)果:
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
參見(jiàn):http://blog.sina.com.cn/s/blog_7880d3350102wb3e.html

6. 撥號(hào)腳本設(shè)置
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. 撥號(hào)
root@am335x-evm: pppd call gprsdial

6. 測(cè)試
撥號(hào)之后進(jìn)行測(cè)試,發(fā)現(xiàn)可以ping通ip但是無(wú)法ping通域名。這需要設(shè)置/etc/resolv.conf來(lái)添加DNS解析服務(wù)器的地址
文件/etc/resolv.conf配置DNS客戶,它包含了主機(jī)的域名搜索順序和DNS服務(wù)器的地址,每一行應(yīng)包含一個(gè)關(guān)鍵字和一個(gè)或多個(gè)的由空格隔開(kāi)的參數(shù)。下面是一個(gè)例子文件:
domain test.com
search www.test.com test.com
nameserver 202.96.128.86
nameserver 202.96.128.166
nameserver #定義DNS服務(wù)器的IP地址
domain #定義本地域名
search #定義域名的搜索列表
sortlist #對(duì)返回的域名進(jìn)行排序
主要是nameserver關(guān)鍵字,如果沒(méi)指定nameserver就找不到DNS服務(wù)器,其它關(guān)鍵字是可選的。
我這里只設(shè)置了兩個(gè)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


評(píng)論


相關(guān)推薦

技術(shù)專區(qū)

關(guān)閉