在android 4.2.2上调试MU609步骤,WCDMA

1.修改kernel\drivers\usb\serial\option.c,添加MU609的ID号
#define HUAWEI_PRODUCT_E353   0x1506
更新了firmware之后ID号改为:
#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

第一个选项打开之后开机就会识别到MU609为GSM modem,否则只会看到有USB插拔的信息,不会识别为GSM MODEM,正确识别后的Log如下:

<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错误信息:

Couldn't set tty to PPP discipline: Invalid argument

此时虽然rild已经运行,apn也设置好了但是仍旧无法上网,netcfg看不到ppp0接口。

 

3.copy libhuawei-ril.so,ip-up,ip-down到指定位置,修改device.mk,添加:

# 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

 

5.修改android\hardware\ril\rild\rild.c,按照mu609 porting guide屏蔽掉switchUser();这行代码,如果不屏蔽掉会出现手动拨号正常,但是android下提示pppd缺少模块的情况,如下:

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了。

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


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

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是否响应。

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,内容如下:

# 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,内容如下:

# /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服务就不会起来了

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

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

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接口是否建立。

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试试看。

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,

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发命令看是否有应答。

你可能感兴趣的:(Android/Linux开发)