1 概述
平台:freescale i.MX 6Quad 4核開發板Sabrelite
作業系統:Android 4.0.4
核心:3.0.15
3G模組:中興MG3732和UbloxLISA-U130
2 中興MG3732模組移植2.1 準備
準備一張可用的聯通3G卡,放入SIM卡卡槽,接著把中興MG3732開發板通過usb串連到主板上。
2.2 移植步驟
1) 拷貝libztewcdma-ril.so檔案到 /system/lib目錄下
2) 在/driver/usb/serial/option.c中添加pid,vid如下:
{USB_DEVICE(0x19d2, 0xffff) }, {USB_DEVICE(0x19d2, 0xfffe) }, {USB_DEVICE(0x19d2, 0xfffd) }, {USB_DEVICE(0x19d2, 0xfffc) }, {USB_DEVICE(0x19d2, 0xfffb) }, {USB_DEVICE(0x19d2, 0xfff1) }, {USB_DEVICE(0x19d2, 0xfff6) }, {USB_DEVICE(0x19d2, 0xfff7) }, {USB_DEVICE(0x19d2, 0xfff8) }, {USB_DEVICE(0x19d2, 0xfff9) }, {USB_DEVICE(0x19d2, 0xffee) }, {USB_DEVICE(0x19d2, 0xffed) }, {USB_DEVICE(0x19d2, 0xffeb) }, {USB_DEVICE(0x19d2, 0xffec) },
3) 拷貝chat, pppd到/system/bin目錄下,確保/system/bin 目前下有pppd 和chat 兩個程式,且可以運行
4) 添加ip-up到/system/ppp/目錄下
5) 在init.rc檔案中添加
chmod 0755 /system/lib/libztewcdma-ril.sochown root /system/bin/pppdchmod 4755 /system/bin/pppd service ril-daemon /system/bin/rild -l/system/lib/libztewcdma-ril.so -- -d /dev/ttyUSB0socket rild stream 660 root radiosocket rild-debug stream 660 radio systemuser root group radio cache inet misc
6) 配置menuconfig如下:
[*] Network device support ---> <*> PPP (point-to-point protocol) support [*] PPP multilink support (EXPERIMENTAL) [*] PPP filtering <*> PPP support for async serial ports <*> PPP support for sync tty ports <*> PPP Deflate compression <*> PPP BSD-Compress compression <*> PPP MPPE compression (encryption)(EXPERIMENTAL) <*> PPP over Ethernet (EXPERIMENTAL) <*> PPP over L2TP (EXPERIMENTAL)
2.3 調試過程
1、 進入android系統後,首先查看模組的連接埠是否識別,如果能正確識別的話,可以看到以下4個連接埠:
/dev/ttyUSB0/dev/ttyUSB1/dev/ttyUSB2/dev/ttyUSB3
2、 注意設定ril-daemon的連接埠為/dev/ttyUSB0,否則rild進程無法啟動,在
logcat –b radio中會顯示以下錯誤:
I/RILJ ( 2392): Couldn't find 'rild' socket; retrying after timeoutI/RILJ ( 2392): Couldn't find'rild' socket; retrying after timeoutI/RILJ ( 2392): Couldn't find'rild' socket; retrying after timeoutI/RILJ ( 2392): Couldn't find'rild' socket; retrying after timeoutI/RILJ ( 2392): Couldn't find'rild' socket; retrying after timeout
3、 在調試過程中,模組可以撥打到電話,但無法上網,用ps命令未發現pppd進程,log如下:
D/RILJ ( 2369): 0: [77] SETUP_DATA_CALL E/RILD ( 2135): get exit sig 17 E/RILD ( 2135): checkPPPConnection: pid_exit == 1 E/RILD ( 2135): checkPPPConnection: interface[ppp0]information is not found E/RILD ( 2135): start_pppd: failed to check PPP interfaceUP E/RILD ( 2135): EVENT_PPPD_MANAGER_PPPD_EXIT E/RILD ( 2135): pppd exit. status = 1024 E/RILD ( 2135): pppd exit . no restart pppd . E/RILD ( 2135): SetupDefaultPDP failed.
說明pppd進程啟動失敗。
後發現是pppd許可權問題導致,解決方案如下:
啟動系統後,在adb中執行以下命令修改pppd許可權:
chown root /system/bin/pppdchmod 4755 /system/bin/pppd
若系統是唯讀屬性,需用remount命令重新掛載檔案系統:
mount –o remount,rw/dev/block/mmcblk0p5 /system/
3 ublox LISA-U130模組移植3.1 準備
準備一張可用的聯通3G卡,放入SIM卡卡槽,接著把ublox u130開發板通過usb串連到主板上。
3.2 移植步驟
1) 解壓ublox提供的壓縮檔如下:
RIL_sc_<version>.zipril_sc_<version> Source overlay for Android Platform build/target/product Device configuration folder files external/ppp/ Data connection files hardware/gsm0710muxd Channelmultiplexer hardware/ril/ublox_ril/ RIL core directory system/core/rootdir/Android.mk Compilation script system/core/init/property_service.c Set RIL services property system/core/liblog/logd_write.c Log configuration files
2) 把相關檔案拷貝到android源碼中
cp –pvRf ril_sc_<version>/external/ppp/ <android_root>/external/pppcp –pvRf ril_sc_<version>/hardware/ril/ublox_ril <android_root>/hardware/ril/cp –pvRf ril_sc_<version>/system/* <android_root>/systemcp –pvRfril_sc_<version>/build/* <android_root>/build
3) 在device/fsl/imx6/AndroidProducts.mk中添加:
RIL_COM_INTERFACE := usb
4) 在init.rc檔案中添加如下語句:
# Changepermissions for modem chmod 0660 /dev/ttyACM0 chown radio radio /dev/ttyACM0 chmod 0660 /dev/ttyACM1 chown radio radio /dev/ttyACM1 chmod 0660 /dev/ttyACM2 chown radio radio /dev/ttyACM2 # Set permissions for u-blox RILRepository chown radio radio /system/etc/rril chmod 0770 /system/etc/rril chown radio radio/system/etc/rril/repository.txt chmod 0660/system/etc/rril/repository.txt # Set u-blox RIL repository state setprop net.rril.repository notready #Prepare u-blox RIL repository service rril-repo/system/bin/rril-repo.sh user root group radio oneshot # Load u-blox RIL service ril-daemon /system/bin/rild -l/system/lib/librapid-ril-core.so -- -a /dev/ttyACM0 -n /dev/ttyACM1 class main socket rild stream 660 root radio socket rild-debug stream 660 radiosystem user root group radio cache inet misc audio service pppd_data0/system/bin/init.gprs-pppd user root radio group radio cache inet misc disabled oneshot service pppd_data1/system/bin/init.gprs-pppd user root radio group radio cache inet misc disabled oneshot service pppd_term /system/bin/stop_pppd15 class main disabled oneshot service pppd_kill /system/bin/stop_pppd 9 class main disabled oneshot
5) 配置menuconfig如下:
DeviceDrivers USB Support <*>USB Modem (CDC ACM)support DeviceDrivers Network device support <*>PPP (point-to-pointprotocol) support <*>PPP support for asyncserial ports <*>PPP support for sync ttyports <*>PPP Deflate compression
6) 重新編譯系統,確保產生以下檔案
/system/lib/librapid-ril-core.so/system/lib/librapid-ril-util.so/system/lib/librapid-ril-oem.so /system/bin/pppd/system/bin/chat /system/bin/init.gprs-pppd/system/bin/ip-down/system/bin/ip-up/system/bin/stop_pppd/system/bin/rril-repo.sh /system/etc/rril/repository.txt /system/etc/ppp/ chap-secrets/system/etc/ppp/ chat-isp1/system/etc/ppp/ chat-isp2/system/etc/ppp/ ip-down-ppp0/system/etc/ppp/ ip-up-ppp0/system/etc/ppp/ ip-up-vpn/system/etc/ppp/pap-secrets /system/etc/ppp/peers/gprs1/system/etc/ppp/peers/gprs2
3.3 調試過程
1、 啟動系統後,確保3G模組連接埠可以被系統識別:
/dev/ttyACM0/dev/ttyACM1/dev/ttyACM2/dev/ttyACM3/dev/ttyACM4/dev/ttyACM5
2、 用ps命令查看rild進程是否啟動,如果已啟動,此時一般撥打到電話是沒問題的。
3、 在調試過程中發現不能上網,用ps命令查看,發現pppd進程未啟動。在adb中用logcat –b radio查看日誌發現有兩處錯誤:
第一處錯誤:
E/RILR ( 2109):CRepository::OpenRepositoryFile() - ERROR: Could not open file"/data/rril/repository.txt" - No such file or directory
第二處錯誤:
I/pppd.gprs( 3262): Configure pppd securityoptions I/pppd.start( 3271): Starting pppd E/pppd ( 3272): unrecognizedoption 'gprs1'I/pppd.start( 3279): pppd exited with2
第一處錯誤could not find /data/rril/repository.txt的原因是/system/bin/rril-repo.sh指令碼未得到執行,解決方案是修改/system/bin/rril-repo.sh的許可權,以及在init.rc中添加servicerril-repo的class屬性:
# Prepare u-blox RIL repositoryservice rril-repo /system/bin/rril-repo.shclass mainuser rootgroup radiooneshot
第二處錯誤unrecognizedoption 'gprs1'的原因是執行/system/bin/init.gprs-pppd指令碼時出錯,當$ppp_usr為空白字串時,指令碼執行以下語句:
/system/bin/pppd user $ppp_usr call gprs$(( $ppp_if + 1 ))=》/system/bin/pppd user call gprs1
此語句執行失敗,所以pppd進程無法啟動。
修改後的正確的指令碼為:
case $ppp_auth in 0) /system/bin/log -t pppd.start "/system/bin/pppd call gprs$(( $ppp_if+ 1 ))"/system/bin/pppd call gprs$(( $ppp_if + 1 )) ;; *) if [ "$ppp_usr" = "" ];then/system/bin/log -t pppd.start "/system/bin/pppd call gprs$(( $ppp_if+ 1 ))"/system/bin/pppd call gprs$(( $ppp_if + 1 )) else/system/bin/log -t pppd.start "/system/bin/pppd user $ppp_usr callgprs$(( $ppp_if + 1 ))"/system/bin/pppd user $ppp_usr call gprs$(( $ppp_if + 1 )) fi