QQ群:519230208,為避免廣告騷擾,申請時請注明 “開發者” 字樣
========================================================
參考:
http://blog.csdn.net/yel617/article/details/5602934 http://wenku.baidu.com/link?url=v96wCcrz8oYObkMTiPa55OyWxg35MhHF4L7voiDhKhtNPCB3uJhvNshz9UVUgpo4BTWmJE_4AhcAoW5oVOmtxr_NHYxb8ev0VKCpGwCSq1m http://blog.csdn.net/suntao222/article/details/8930744
http://wandering.blog.51cto.com/467932/354562
http://blog.chinaunix.net/uid-9525959-id-3998519.html
一 上網模塊需要內核編譯配置 《Guide to Kernel Driver Integration ......》
修改源文件,修改內核配置項等,詳細參考3G模塊手冊。
二 交叉編譯一些工具(參考 《Yocto Project Application Developer's Guide》):
將以下內容添加到根目錄的Makefile文件中:
CC=arm-poky-linux-gnueabi-gcc -m32 -march=i586 --sysroot=/opt/poky/1.8/sysroots/x86_64-pokysdk-linux LD=arm-poky-linux-gnueabi-ld --sysroot=/opt/poky/1.8/sysroots/x86_64-pokysdk-linux CFLAGS=-O2 -pipe -g -feliminate-unused-debug-types CXXFLAGS=-O2 -pipe -g -feliminate-unused-debug-types change to : CC=arm-poky-linux-gnueabi-gcc --sysroot=/home/summer/test-yocto/qemuarm LD=arm-poky-linux-gnueabi-ld --sysroot=/home/summer/test-yocto/qemuarm CFLAGS=-O2 -pipe -g -feliminate-unused-debug-types CXXFLAGS=-O2 -pipe -g -feliminate-unused-debug-types # ./configure # make
PPP
1. 下載代碼:https://ppp.samba.org/ 2. 編譯代碼: http://blog.csdn.net/lanyou1900/article/details/40185259 3. 編譯成功后將編譯生成的chat,pppd,pppdump等命令拷貝到板子文件系統的/usr/sbin目錄下邊去
USB(我的環境里以下功能都包含了,以下僅用來參考)
libusb-1.0.9 (用於編譯usb-modeswitch-2.0.1) http://sourceforge.net/projects/libusb/postdownload?source=dlp usb-modeswitch-2.0.1 (用於切換網卡的模式) http://www.draisberghof.de/usb_modeswitch/#download usb-modeswitch-data-20130807 (用於切換時指定切換的型號) http://www.draisberghof.de/usb_modeswitch/#download
三 編寫撥號腳本
在板子文件系統/etc/ppp/peers目錄下邊創建三個文件如下:
1. wcdma
debug nodetach /dev/ttyUSB0 115200 usepeerdns noauth noipdefault novj novjccomp noccp defaultroute ipcp-accept-local ipcp-accept-remote connect '/usr/sbin/chat -s -v -f /etc/ppp/peers/chat-wcdma-connect'
2. chat-wcdma-connect
TIMEOUT 5 ABORT 'NO CARRIER' ABORT 'ERROR' ABORT 'NODIALTONE' ABORT 'BUSY' ABORT 'NO ANSWER' '' \rAT OK \rATZ OK \rAT+CGDCONT=1,"IP","3GNET",,0,0 OK-AT-OK ATDT*99# CONNECT \d\c
3. chat-wcdma-disconnect
ABORT"ERROR" ABORT "NODIALTONE" SAY"\nSending break to the modem\n" '' "\K" ''"+++ATH" SAY"\nGoodbay\n"
四 添加DNS信息
# vi /etc/resolv.conf // 加入以下內容, 如果已經存在,替換成以下內容 nameserver 202.99.160.68 nameserver 202.99.166.4
或者,替換成
nameserver 1.2.4.8
nameserver 210.2.4.8
// TOBEDO : 重啟開發板,dns信息被沖掉
五 檢測ppp0網絡是否能夠使用
# Ping –I ppp0 www.baidu.com // 能夠ping通就表示3G卡移植驅動成功
出現錯誤,域名不能ping通,ip可以
root@imx6ulevk:~# ping www.baidu.com ping: bad address 'www.baidu.com'
六 測試模塊狀態
# lsusb // 查看usb連接狀態 Bus 001 Device 005: ID 12d1:1c25 Huawei Technologies Co., Ltd. Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
# netstat -nr
# dmesg cdc_ether 1-1:2.0 eth2: register 'cdc_ether' at usb-ci_hdrc.1-1, CDC Ethernet Device, 00:1e:10:1f:00:00 usbcore: registered new interface driver option usbcore: registered new interface driver cdc_ether usbserial: USB Serial support registered for GSM modem (1-port) option 1-1:2.2: GSM modem (1-port) converter detected usb 1-1: GSM modem (1-port) converter now attached to ttyUSB0 option 1-1:2.3: GSM modem (1-port) converter detected usb 1-1: GSM modem (1-port) converter now attached to ttyUSB1 option 1-1:2.4: GSM modem (1-port) converter detected usb 1-1: GSM modem (1-port) converter now attached to ttyUSB2 usb 1-1: USB disconnect, device number 3 cdc_ether 1-1:2.0 eth2: unregister 'cdc_ether' usb-ci_hdrc.1-1, CDC Ethernet Device option1 ttyUSB0: GSM modem (1-port) converter now disconnected from ttyUSB0 option 1-1:2.2: device disconnected option1 ttyUSB1: GSM modem (1-port) converter now disconnected from ttyUSB1 option 1-1:2.3: device disconnected option1 ttyUSB2: GSM modem (1-port) converter now disconnected from ttyUSB2 option 1-1:2.4: device disconnected usb 1-1: new full-speed USB device number 4 using ci_hdrc usb 1-1: new high-speed USB device number 5 using ci_hdrc cdc_ether 1-1:2.0 eth2: register 'cdc_ether' at usb-ci_hdrc.1-1, CDC Ethernet Device, 00:1e:10:1f:00:00 option 1-1:2.2: GSM modem (1-port) converter detected usb 1-1: GSM modem (1-port) converter now attached to ttyUSB0 option 1-1:2.3: GSM modem (1-port) converter detected usb 1-1: GSM modem (1-port) converter now attached to ttyUSB1 option 1-1:2.4: GSM modem (1-port) converter detected usb 1-1: GSM modem (1-port) converter now attached to ttyUSB2
# dmesg | grep -in ppp // 查看ppp連接狀態 #cat /dev/ttyUSB0 & # echo AT+CGMI > /dev/ttyUSB0 // 查詢廠商相關信息 # echo AT+CSQ > /dev/ttyUSB0 // 查詢信號,順帶還可以讓你知道SIM卡相關的是否正常 # #netstat -nal // 查看網絡連接狀態 # ifconfig -a
Attention:
USB線的選擇直接影響到能否正常識別模塊
附錄:
一 插上USB 3G模塊顯示的log
root@imx6ulevk:/mnt# usb 1-1: new high-speed USB device number 2 using ci_hdrc usb 1-1: new high-speed USB device number 3 using ci_hdrc cdc_ether 1-1:2.0 eth2: register 'cdc_ether' at usb-ci_hdrc.1-1, CDC Ethernet Device, 00:1e:10:1f:00:00 usbcore: registered new interface driver option usbserial: USB Serial support registered for GSM modem (1-port) option 1-1:2.2: GSM modem (1-port) converter detected usb 1-1: GSM modem (1-port) converter now attached to ttyUSB0 option 1-1:2.3: GSM modem (1-port) converter detected usb 1-1: GSM modem (1-port) converter now attached to ttyUSB1 option 1-1:2.4: GSM modem (1-port) converter detected usb 1-1: GSM modem (1-port) converter now attached to ttyUSB2
二 lsusb顯示的log
root@imx6ulevk:/mnt# lsusb Bus 001 Device 003: ID 12d1:1c25 Huawei Technologies Co., Ltd. Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
三 ls /dev/ppp顯示的log
root@imx6ulevk:/mnt# ls /dev/ppp /dev/pp
四 手動撥號的錯誤log
root@imx6ulevk:~# timeout set to 5 seconds abort on (NO CARRIER) abort on (ERROR) abort on (NODIALTONE) abort on (BUSY) abort on (NO ANSWER) send (^MAT^M) expect (OK) ^M OK -- got it send (^MATZ^M) expect (OK) ^M ^M OK -- got it send (^MAT+CGDCONT=1,"IP","3GNET",,0,0^M) expect (OK) ^M ^MAT+CGDCONT=1,"IP","3GNET",,0,0^M^M OK -- got it send (ATDT*99#^M) expect (CONNECT) ^M ATDT*99#^M^M CONNECT -- got it send (\d) Script /usr/sbin/chat -s -v -f /etc/ppp/peers/chat-wcdma-connect finished (pid 902), status = 0x0 Serial connection established. Couldn't set tty to PPP discipline: Invalid argument expect (ABORT"ERROR") ^C
看起來像撥號成功的log
root@imx6ulevk:~# pppd call wcdma & [1] 844 root@imx6ulevk:~# timeout set to 5 seconds abort on (NO CARRIER) abort on (ERROR) abort on (NODIALTONE) abort on (BUSY) abort on (NO ANSWER) send (^MAT^M) expect (OK) ^MAT^M^M OK -- got it send (^MATZ^M) expect (OK) ^M ^MATZ^M^M OK -- got it send (^MAT+CGDCONT=1,"IP","3GNET",,0,0^M) expect (OK) ^M ^MAT+CGDCONT=1,"IP","3GNET",,0,0^M^M OK -- got it send (ATDT*99#^M) expect (CONNECT) ^M ATDT*99#^M^M CONNECT -- got it send (\d) Script /usr/sbin/chat -s -v -f /etc/ppp/peers/chat-wcdma-connect finished (pid 845), status = 0x0 Serial connection established. using channel 1 Using interface ppp0 Connect: ppp0 <--> /dev/ttyUSB0 sent [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0x38c54823> <pcomp> <accomp>] rcvd [LCP ConfReq id=0x1 <accomp> <pcomp> <asyncmap 0x0> <mru 1500> <magic 0x545> <auth chap MD5>] No auth is possible sent [LCP ConfRej id=0x1 <auth chap MD5>] rcvd [LCP ConfAck id=0x1 <asyncmap 0x0> <magic 0x38c54823> <pcomp> <accomp>] rcvd [LCP ConfReq id=0x2 <accomp> <pcomp> <asyncmap 0x0> <mru 1500> <magic 0x545>] sent [LCP ConfAck id=0x2 <accomp> <pcomp> <asyncmap 0x0> <mru 1500> <magic 0x545>] sent [IPCP ConfReq id=0x1 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns2 0.0.0.0>] rcvd [IPCP ConfReq id=0x1] sent [IPCP ConfNak id=0x1 <addr 0.0.0.0>] rcvd [IPCP ConfNak id=0x1 <ms-dns1 0.0.0.0> <ms-dns2 0.0.0.0>] sent [IPCP ConfReq id=0x2 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns2 0.0.0.0>] rcvd [IPCP ConfReq id=0x2] sent [IPCP ConfAck id=0x2] rcvd [IPCP ConfNak id=0x2 <addr 10.74.89.144> <ms-dns1 120.80.80.80> <ms-dns2 221.5.88.88>] sent [IPCP ConfReq id=0x3 <addr 10.74.89.144> <ms-dns1 120.80.80.80> <ms-dns2 221.5.88.88>] rcvd [IPCP ConfAck id=0x3 <addr 10.74.89.144> <ms-dns1 120.80.80.80> <ms-dns2 221.5.88.88>] Could not determine remote IP address: defaulting to 10.64.64.64 local IP address 10.74.89.144 remote IP address 10.64.64.64 primary DNS address 120.80.80.80 secondary DNS address 221.5.88.88
ifconfig -a
ppp0 Link encap:Point-to-Point Protocol inet addr:10.74.89.144 P-t-P:10.64.64.64 Mask:255.255.255.255 UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1 RX packets:5 errors:0 dropped:0 overruns:0 frame:0 TX packets:5 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:3 RX bytes:68 (68.0 B) TX bytes:80 (80.0 B)
netstat -nr
root@imx6ulevk:~# netstat -nr Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface 0.0.0.0 0.0.0.0 0.0.0.0 U 0 0 0 ppp0 10.64.64.64 0.0.0.0 255.255.255.255 UH 0 0 0 ppp0
error
root@imx6ulevk:~# ping -I ppp0 www.baidu.com ping: bad address 'www.baidu.com'
success
root@imx6ulevk:~# ping 202.108.23.237 PING 202.108.23.237 (202.108.23.237): 56 data bytes 64 bytes from 202.108.23.237: seq=0 ttl=52 time=1515.208 ms 64 bytes from 202.108.23.237: seq=2 ttl=52 time=75.742 ms