android4.2.2除錯mu609 3G模組
[cpp] view plaincopyprint?
- #define HUAWEI_PRODUCT_E353 0x1506
#define HUAWEI_PRODUCT_E353 0x1506
[cpp]
view plaincopyprint?
- 更新了firmware之後ID號改為:
更新了firmware之後ID號改為:
[cpp]
view plaincopyprint?
- #define HUAWEI_PRODUCT_E353 0x1573
#define HUAWEI_PRODUCT_E353 0x1573
2.對kernel進行配置,make menuconfig開啟以下幾項
- Device Drivers -> USB support -> USB Serial Converter support -><*> USB driver for GSM and CDMA modems
- Device Drivers -> Network device support -> PPP (point-to-point protocol) support -><*> PPP MPPE compression (encryption) (EXPERIMENTAL)
- Device Drivers -> Network device support -> PPP (point-to-point protocol) support -><*> PPP support for async serial ports
Device Drivers -> USB support -> USB Serial Converter support -> <*> USB driver for GSM and CDMA modems Device Drivers -> Network device support -> PPP (point-to-point protocol) support -> <*> PPP MPPE compression (encryption) (EXPERIMENTAL) Device Drivers -> Network device support -> PPP (point-to-point protocol) support -> <*> PPP support for async serial ports
第一個選項開啟之後開機就會識別到MU609為GSM modem,否則只會看到有USB插拔的資訊,不會識別為GSM MODEM,正確識別後的Log如下:
[html] view plaincopyprint?- <6>[ 1.929557] usb 3-1: new high-speed USB device number 2 using exynos-xhci
- <6>[ 1.949389] usb 3-1: New USB device found, idVendor=12d1, idProduct=1506
- <6>[ 1.949483] usb 3-1: New USB device strings: Mfr=3, Product=2, SerialNumber=0
- <6>[ 1.949595] usb 3-1: Product: HUAWEI Mobile
- <6>[ 1.949645] usb 3-1: Manufacturer: Huawei Technologies
- <6>[ 1.949950] mmc_host mmc1: Bus speed (slot 0) = 25000000Hz (slot req 400000Hz, actual 390625HZ div = 32)
- <6>[ 1.956711] option 3-1:1.0: GSM modem (1-port) converter detected
- <6>[ 1.956911] usb 3-1: GSM modem (1-port) converter now attached to ttyUSB0
- <6>[ 1.957187] option 3-1:1.1: GSM modem (1-port) converter detected
- <6>[ 1.957353] usb 3-1: GSM modem (1-port) converter now attached to ttyUSB1
- <6>[ 1.957588] option 3-1:1.2: GSM modem (1-port) converter detected
- <6>[ 1.957729] usb 3-1: GSM modem (1-port) converter now attached to ttyUSB2
<6>[ 1.929557] usb 3-1: new high-speed USB device number 2 using exynos-xhci
<6>[ 1.949389] usb 3-1: New USB device found, idVendor=12d1, idProduct=1506
<6>[ 1.949483] usb 3-1: New USB device strings: Mfr=3, Product=2, SerialNumber=0
<6>[ 1.949595] usb 3-1: Product: HUAWEI Mobile
<6>[ 1.949645] usb 3-1: Manufacturer: Huawei Technologies
<6>[ 1.949950] mmc_host mmc1: Bus speed (slot 0) = 25000000Hz (slot req 400000Hz, actual 390625HZ div = 32)
<6>[ 1.956711] option 3-1:1.0: GSM modem (1-port) converter detected
<6>[ 1.956911] usb 3-1: GSM modem (1-port) converter now attached to ttyUSB0
<6>[ 1.957187] option 3-1:1.1: GSM modem (1-port) converter detected
<6>[ 1.957353] usb 3-1: GSM modem (1-port) converter now attached to ttyUSB1
<6>[ 1.957588] option 3-1:1.2: GSM modem (1-port) converter detected
<6>[ 1.957729] usb 3-1: GSM modem (1-port) converter now attached to ttyUSB2
第二和第三個選項開啟之後pppd才可以建立ppp0介面,否則logcat會出現如下pppd錯誤資訊:
[plain] view plaincopyprint?- Couldn't set tty to PPP discipline: Invalid argument
Couldn't set tty to PPP discipline: Invalid argument
此時雖然rild已經執行,apn也設定好了但是仍舊無法上網,netcfg看不到ppp0介面。
3.copy libhuawei-ril.so,ip-up,ip-down到指定位置,修改device.mk,新增:
[plain] view plaincopyprint?- # stone add mu609
- PRODUCT_COPY_FILES += \
- $(LOCAL_PATH)/mu609/libhuawei-ril.so:system/lib/libhuawei-ril.so \
- $(LOCAL_PATH)/mu609/ip-up:system/etc/ppp/ip-up \
- $(LOCAL_PATH)/mu609/ip-down:system/etc/ppp/ip-down \
- $(LOCAL_PATH)/mu609/chat:system/bin/chat \
- $(LOCAL_PATH)/mu609/busybox:system/bin/busybox
# stone add mu609
PRODUCT_COPY_FILES += \
$(LOCAL_PATH)/mu609/libhuawei-ril.so:system/lib/libhuawei-ril.so \
$(LOCAL_PATH)/mu609/ip-up:system/etc/ppp/ip-up \
$(LOCAL_PATH)/mu609/ip-down:system/etc/ppp/ip-down \
$(LOCAL_PATH)/mu609/chat:system/bin/chat \
$(LOCAL_PATH)/mu609/busybox:system/bin/busybox
最後兩個chat和busybox是為了除錯方便加進去的。
4.修改android\system\core\rootdir\init.rc,新增ttyUSB許可權和ril的載入
- on boot
- # stone add mu609
- chmod 777 /dev/ttyUSB0
- chmod 777 /dev/ttyUSB2
- chmod 777 /etc/ppp/ip-up
- chmod 777 /etc/ppp/ip-down
- # stone modify mu609
- service ril-daemon /system/bin/rild -l libhuawei-ril.so
on boot
# stone add mu609
chmod 777 /dev/ttyUSB0
chmod 777 /dev/ttyUSB2
chmod 777 /etc/ppp/ip-up
chmod 777 /etc/ppp/ip-down
# stone modify mu609
service ril-daemon /system/bin/rild -l libhuawei-ril.so
5.修改android\hardware\ril\rild\rild.c,按照mu609 porting guide遮蔽掉switchUser();這行程式碼,如果不遮蔽掉會出現手動撥號正常,但是android下提示pppd缺少模組的情況,如下:
[plain] view plaincopyprint?- E/pppd ( 2082): This system lacks kernel support for PPP. This could be because
- E/pppd ( 2082): the PPP kernel module could not be loaded, or because PPP was not
- E/pppd ( 2082): included in the kernel configuration. If PPP was included as a
- E/pppd ( 2082): module, try `/sbin/modprobe -v ppp'. If that fails, check that
- E/pppd ( 2082): ppp.o exists in /lib/modules/`uname -r`/net.
- E/pppd ( 2082): See README.linux file in the ppp distribution for more details.
E/pppd ( 2082): This system lacks kernel support for PPP. This could be because
E/pppd ( 2082): the PPP kernel module could not be loaded, or because PPP was not
E/pppd ( 2082): included in the kernel configuration. If PPP was included as a
E/pppd ( 2082): module, try `/sbin/modprobe -v ppp'. If that fails, check that
E/pppd ( 2082): ppp.o exists in /lib/modules/`uname -r`/net.
E/pppd ( 2082): See README.linux file in the ppp distribution for more details.
到此就已經porting完了,如果出問題了還要排查,現在從底層開始一步步排查驗證。
1.首先要確定mu609模組識別到了沒有,可以在shell下busybox lsusb檢視usb裝置,如果出現如下資訊,就是已經識別到mu609了。
[plain] view plaincopyprint?- [email protected]:/ # busybox lsusb
- Bus 003 Device 002: ID 12d1:1506
[email protected]:/ # busybox lsusb
Bus 003 Device 002: ID 12d1:1506
2.檢視ttyUSB介面屬性是否修改為0777
- [email protected]:/ # ll /dev/ttyUSB*
- crwxrwxrwx root root 188, 0 2013-05-15 12:01 ttyUSB0
- crw------- root root 188, 1 2013-05-15 12:00 ttyUSB1
- crwxrwxrwx root root 188, 2 2013-05-15 12:00 ttyUSB2
[email protected]:/ # ll /dev/ttyUSB*
crwxrwxrwx root root 188, 0 2013-05-15 12:01 ttyUSB0
crw------- root root 188, 1 2013-05-15 12:00 ttyUSB1
crwxrwxrwx root root 188, 2 2013-05-15 12:00 ttyUSB2
3.模組已經識別了,ttyUSB介面都有,現在手動發AT命令看mu609是否響應。
[plain] view plaincopyprint?- [email protected]:/ # cd /dev/
- [email protected]:/dev # cat ttyUSB0 &
- [1] 869
- [email protected]:/dev # echo AT+CGMI > ttyUSB0
- [email protected]:/dev #
- Huawei Technologies Co., Ltd.
- OK
- [email protected]:/dev # echo AT+CGMM > ttyUSB0
- [email protected]:/dev #
- MU609
- OK
- [email protected]:/dev #
[email protected]:/ # cd /dev/
[email protected]:/dev # cat ttyUSB0 &
[1] 869
[email protected]:/dev # echo AT+CGMI > ttyUSB0
[email protected]:/dev #
Huawei Technologies Co., Ltd.
OK
[email protected]:/dev # echo AT+CGMM > ttyUSB0
[email protected]:/dev #
MU609
OK
[email protected]:/dev #
OK,mu609正常響應了。
4.現在先拋開上層RIL不管,單純從shell手動撥號看能否正常工作。需要自己寫兩個指令碼,拷貝到/etc/ppp目錄下
第一個指令碼是/etc/ppp/chat/unicom,內容如下:
- # this is the chat script for unicom
- ABORT "NO CARRIER"
- ABORT "NO DIALTONE"
- ABORT "ERROR"
- ABORT "NO ANSWER"
- ABORT "BUSY"
- TIMEOUT 120
- "" at
- OK AT+CGDCONT=1,"IP","3gnet"
- OK atdt*99***1#
- CONNECT
# this is the chat script for unicom
ABORT "NO CARRIER"
ABORT "NO DIALTONE"
ABORT "ERROR"
ABORT "NO ANSWER"
ABORT "BUSY"
TIMEOUT 120
"" at
OK AT+CGDCONT=1,"IP","3gnet"
OK atdt*99***1#
CONNECT
第二個指令碼是/etc/ppp/peers/unicom,內容如下:
[plain] view plaincopyprint?- # /system/etc/ppp/peers/unicom
- /dev/ttyUSB0
- 115200
- crtscts
- connect '/system/bin/chat -s -v -f /system/etc/ppp/chat/unicom'
- debug
- nodetach
- ipcp-accept-local
- ipcp-accept-remote
- defaultroute
- usepeerdns
- user card
- password card
# /system/etc/ppp/peers/unicom
/dev/ttyUSB0
115200
crtscts
connect '/system/bin/chat -s -v -f /system/etc/ppp/chat/unicom'
debug
nodetach
ipcp-accept-local
ipcp-accept-remote
defaultroute
usepeerdns
user card
password card
chat和peers兩個目錄沒有,需要自己mkdir。還需要用到chat,就是之前在device.mk中copy過來的,android自身不帶,在我的資源中有編譯好的。因為rild一開始就會啟動,把pppd搞起來,影響手動撥號,所以要先把rild改個名字,這樣rild服務就不會起來了
[plain] view plaincopyprint?- mv /system/bin/rild /system/bin/ril-d
mv /system/bin/rild /system/bin/ril-d
改完後記得重啟機器。好了,現在可以手動撥號了:
[plain] view plaincopyprint?- [email protected]:/ # pppd call unicom &
- [1] 912
- [email protected]:/ # abort on (NO CARRIER)
- abort on (NO DIALTONE)
- abort on (ERROR)
- abort on (NO ANSWER)
- abort on (BUSY)
- timeout set to 120 seconds
- send (at^M)
- expect (OK)
- ^M
- OK
- -- got it
- send (AT+CGDCONT=1,"IP","3gnet"^M)
- expect (OK)
- ^M
- ^M
- OK
- -- got it
- send (atdt*99***1#^M)
- expect (CONNECT)
- ^M
- ^M
- CONNECT
- -- got it
- [email protected]:/ #
[email protected]:/ # pppd call unicom &
[1] 912
[email protected]:/ # abort on (NO CARRIER)
abort on (NO DIALTONE)
abort on (ERROR)
abort on (NO ANSWER)
abort on (BUSY)
timeout set to 120 seconds
send (at^M)
expect (OK)
^M
OK
-- got it
send (AT+CGDCONT=1,"IP","3gnet"^M)
expect (OK)
^M
^M
OK
-- got it
send (atdt*99***1#^M)
expect (CONNECT)
^M
^M
CONNECT
-- got it
[email protected]:/ #
好了,到這裡就算是撥號成功了,然後看ppp0介面是否建立。
[plain] view plaincopyprint?- [email protected]:/ # netcfg
- ip6tnl0 DOWN 0.0.0.0/0 0x00000080 00:00:00:00:00:00
- lo UP 127.0.0.1/8 0x00000049 00:00:00:00:00:00
- ppp0 UP 10.105.219.114/32 0x000010d1 00:00:00:00:00:00
- sit0 DOWN 0.0.0.0/0 0x00000080 00:00:00:00:00:00
- [email protected]:/ #
[email protected]:/ # netcfg
ip6tnl0 DOWN 0.0.0.0/0 0x00000080 00:00:00:00:00:00
lo UP 127.0.0.1/8 0x00000049 00:00:00:00:00:00
ppp0 UP 10.105.219.114/32 0x000010d1 00:00:00:00:00:00
sit0 DOWN 0.0.0.0/0 0x00000080 00:00:00:00:00:00
[email protected]:/ #
好了,ppp0介面也建立了,ip地址也獲得了,ping一下baidu試試看。
[plain] view plaincopyprint?- [email protected]:/ # ping www.baidu.com
- PING www.a.shifen.com (220.181.112.143) 56(84) bytes of data.
- 64 bytes from 220.181.112.143: icmp_seq=1 ttl=48 time=164 ms
- 64 bytes from 220.181.112.143: icmp_seq=2 ttl=48 time=172 ms
- 64 bytes from 220.181.112.143: icmp_seq=3 ttl=48 time=160 ms
- ^C64 bytes from 220.181.112.143: icmp_seq=4 ttl=48 time=148 ms
- --- www.a.shifen.com ping statistics ---
- 4 packets transmitted, 4 received, 0% packet loss, time 3005ms
- rtt min/avg/max/mdev = 148.703/161.427/172.377/8.508 ms
- [email protected]:/ #
[email protected]:/ # ping www.baidu.com
PING www.a.shifen.com (220.181.112.143) 56(84) bytes of data.
64 bytes from 220.181.112.143: icmp_seq=1 ttl=48 time=164 ms
64 bytes from 220.181.112.143: icmp_seq=2 ttl=48 time=172 ms
64 bytes from 220.181.112.143: icmp_seq=3 ttl=48 time=160 ms
^C64 bytes from 220.181.112.143: icmp_seq=4 ttl=48 time=148 ms
--- www.a.shifen.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3005ms
rtt min/avg/max/mdev = 148.703/161.427/172.377/8.508 ms
[email protected]:/ #
OK,一切正常,現在可以確定撥號沒有問題了,剩下驗證android上層ril是否工作正常了。
5.把rild的名字改回來,進入系統設定一下APN,
[plain] view plaincopyprint?- APN:3gnet
- MCC:460
- MNC:01
APN:3gnet
MCC:460
MNC:01
儲存,然後重啟,起來後就可以在狀態列看到3G的圖示了,當然要開啟“啟動資料網路”選項。
如果沒有工作,就"logcat -b radio &"看一下ril的log,ril是否認到ttyUSB的介面了。
除錯時候經常用到的幾個小命令。
netcfg : 檢視當前所有網路介面
getprop net.dns1 : 檢視dns(有時候dns不對也會上不了網,比如8.8.8.8,這時候需要修改pppd)
logcat -s pppd : 檢視pppd log
logcat -b radio &: 檢視radio log
cat ttyUSB0 &然後echo AT+CMD > ttyUSB0: 對modem發命令看是否有應答。