在android 4.2.2上调试MU609步骤,WCDMA

这篇为转载文章,但是有一点需要说明的是:不管是在linux还是android的平台下调试3G模块,如果调试过程中提示以下错误:

NO CARRIER

那么就是没接天线导致的,收不到3G信号。遇到此情况时,接上天线即可。

下面是转载内容:

1.修改kernel\drivers\usb\serial\option.c,添加MU609的ID号

  1. #define HUAWEI_PRODUCT_E353 0x1506
#define HUAWEI_PRODUCT_E353   0x1506
  1. 更新了firmware之后ID号改为:
更新了firmware之后ID号改为:
  1. #define HUAWEI_PRODUCT_E353 0x1573
#define HUAWEI_PRODUCT_E353   0x1573


2.对kernel进行配置,make menuconfig打开以下几项

  1. Device Drivers -> USB support -> USB Serial Converter support -><*> USB driver for GSM and CDMA modems
  2. Device Drivers -> Network device support -> PPP (point-to-point protocol) support -><*> PPP MPPE compression (encryption) (EXPERIMENTAL)
  3. 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如下:

  1. <6>[ 1.929557] usb 3-1: new high-speed USB device number 2 using exynos-xhci
  2. <6>[ 1.949389] usb 3-1: New USB device found,idVendor=12d1,idProduct=1506
  3. <6>[ 1.949483] usb 3-1: New USB device strings:Mfr=3, Product=2, SerialNumber=0
  4. <6>[ 1.949595] usb 3-1: Product: HUAWEI Mobile
  5. <6>[ 1.949645] usb 3-1: Manufacturer: Huawei Technologies
  6. <6>[ 1.949950] mmc_host mmc1: Bus speed (slot 0) = 25000000Hz (slot req 400000Hz, actual 390625HZdiv = 32)
  7. <6>[ 1.956711] option 3-1:1.0: GSM modem (1-port) converter detected
  8. <6>[ 1.956911] usb 3-1: GSM modem (1-port) converter now attached to ttyUSB0
  9. <6>[ 1.957187] option 3-1:1.1: GSM modem (1-port) converter detected
  10. <6>[ 1.957353] usb 3-1: GSM modem (1-port) converter now attached to ttyUSB1
  11. <6>[ 1.957588] option 3-1:1.2: GSM modem (1-port) converter detected
  12. <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错误信息:

  1. 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,添加:

  1. # stone add mu609
  2. PRODUCT_COPY_FILES += \
  3. $(LOCAL_PATH)/mu609/libhuawei-ril.so:system/lib/libhuawei-ril.so \
  4. $(LOCAL_PATH)/mu609/ip-up:system/etc/ppp/ip-up \
  5. $(LOCAL_PATH)/mu609/ip-down:system/etc/ppp/ip-down \
  6. $(LOCAL_PATH)/mu609/chat:system/bin/chat \
  7. $(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的加载

  1. on boot
  2. # stone add mu609
  3. chmod 777 /dev/ttyUSB0
  4. chmod 777 /dev/ttyUSB2
  5. chmod 777 /etc/ppp/ip-up
  6. chmod 777 /etc/ppp/ip-down
  7. # stone modify mu609
  8. 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缺少模块的情况,如下:

  1. E/pppd ( 2082): This system lacks kernel support for PPP. This could be because
  2. E/pppd ( 2082): the PPP kernel module could not be loaded, or because PPP was not
  3. E/pppd ( 2082): included in the kernel configuration. If PPP was included as a
  4. E/pppd ( 2082): module, try `/sbin/modprobe -v ppp'. If that fails, check that
  5. E/pppd ( 2082): ppp.o exists in /lib/modules/`uname -r`/net.
  6. 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了。

  1. shell@android:/ # busybox lsusb
  2. Bus 003 Device 002: ID 12d1:1506
shell@android:/ # busybox lsusb
Bus 003 Device 002: ID 12d1:1506


2.查看ttyUSB接口属性是否修改为0777

  1. shell@android:/ # ll /dev/ttyUSB*
  2. crwxrwxrwx root root 188, 0 2013-05-15 12:01 ttyUSB0
  3. crw------- root root 188, 1 2013-05-15 12:00 ttyUSB1
  4. crwxrwxrwx root root 188, 2 2013-05-15 12:00 ttyUSB2
shell@android:/ # 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是否响应。

  1. shell@android:/ # cd /dev/
  2. shell@android:/dev # cat ttyUSB0 &
  3. [1] 869
  4. shell@android:/dev # echo AT+CGMI > ttyUSB0
  5. shell@android:/dev #
  6. Huawei Technologies Co., Ltd.
  7. OK
  8. shell@android:/dev # echo AT+CGMM > ttyUSB0
  9. shell@android:/dev #
  10. MU609
  11. OK
  12. shell@android:/dev #
shell@android:/ # cd /dev/
shell@android:/dev # cat ttyUSB0 &                                             
[1] 869
shell@android:/dev # echo AT+CGMI > ttyUSB0                                    
shell@android:/dev # 

Huawei Technologies Co., Ltd.



OK


shell@android:/dev # echo AT+CGMM > ttyUSB0                                    
shell@android:/dev # 

MU609



OK


shell@android:/dev # 

OK,mu609正常响应了。

4.现在先抛开上层RIL不管,单纯从shell手动拨号看能否正常工作。需要自己写两个脚本,拷贝到/etc/ppp目录下
第一个脚本是/etc/ppp/chat/unicom,内容如下:

  1. # this is the chat script for unicom
  2. ABORT "NO CARRIER"
  3. ABORT "NO DIALTONE"
  4. ABORT "ERROR"
  5. ABORT "NO ANSWER"
  6. ABORT "BUSY"
  7. TIMEOUT 120
  8. "" at
  9. OK AT+CGDCONT=1,"IP","3gnet"
  10. OK atdt*99***1#
  11. 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,内容如下:

  1. # /system/etc/ppp/peers/unicom
  2. /dev/ttyUSB0
  3. 115200
  4. crtscts
  5. connect '/system/bin/chat -s -v -f /system/etc/ppp/chat/unicom'
  6. debug
  7. nodetach
  8. ipcp-accept-local
  9. ipcp-accept-remote
  10. defaultroute
  11. usepeerdns
  12. user card
  13. 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服务就不会起来了

  1. mv /system/bin/rild /system/bin/ril-d
mv /system/bin/rild /system/bin/ril-d

改完后记得重启机器。好了,现在可以手动拨号了:

  1. shell@android:/ # pppd call unicom &
  2. [1] 912
  3. shell@android:/ # abort on (NO CARRIER)
  4. abort on (NO DIALTONE)
  5. abort on (ERROR)
  6. abort on (NO ANSWER)
  7. abort on (BUSY)
  8. timeout set to 120 seconds
  9. send (at^M)
  10. expect (OK)
  11. ^M
  12. OK
  13. -- got it
  14. send (AT+CGDCONT=1,"IP","3gnet"^M)
  15. expect (OK)
  16. ^M
  17. ^M
  18. OK
  19. -- got it
  20. send (atdt*99***1#^M)
  21. expect (CONNECT)
  22. ^M
  23. ^M
  24. CONNECT
  25. -- got it
  26. shell@android:/ #
shell@android:/ # pppd call unicom &
[1] 912
shell@android:/ # 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

shell@android:/ #

好了,到这里就算是拨号成功了,然后看ppp0接口是否建立。

  1. shell@android:/ # netcfg
  2. ip6tnl0 DOWN 0.0.0.0/0 0x00000080 00:00:00:00:00:00
  3. lo UP 127.0.0.1/8 0x00000049 00:00:00:00:00:00
  4. ppp0 UP 10.105.219.114/32 0x000010d1 00:00:00:00:00:00
  5. sit0 DOWN 0.0.0.0/0 0x00000080 00:00:00:00:00:00
  6. shell@android:/ #
shell@android:/ # 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
shell@android:/ # 

好了,ppp0接口也建立了,ip地址也获得了,ping一下baidu试试看。

  1. shell@android:/ # ping www.baidu.com
  2. PING www.a.shifen.com (220.181.112.143) 56(84) bytes of data.
  3. 64 bytes from 220.181.112.143: icmp_seq=1 ttl=48 time=164 ms
  4. 64 bytes from 220.181.112.143: icmp_seq=2 ttl=48 time=172 ms
  5. 64 bytes from 220.181.112.143: icmp_seq=3 ttl=48 time=160 ms
  6. ^C64 bytes from 220.181.112.143: icmp_seq=4 ttl=48 time=148 ms
  7. --- www.a.shifen.com ping statistics ---
  8. 4 packets transmitted, 4 received, 0% packet loss, time 3005ms
  9. rtt min/avg/max/mdev = 148.703/161.427/172.377/8.508 ms
  10. shell@android:/ #
shell@android:/ # 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
shell@android:/ #

OK,一切正常,现在可以确定拨号没有问题了,剩下验证android上层ril是否工作正常了。

5.把rild的名字改回来,进入系统设置一下APN,

  1. APN:3gnet
  2. MCC:460
  3. 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发命令看是否有应答。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值