android平台4G模块驱动及功能调试

随着4G网络的普及,4G功能在android平台使用越来越多,但是对于一些单纯的电视及监视器平台的芯片,电话和4G网络功能是被忽略的,所以4G模块应运而生。目前市场上出现并使用较多的还是高通的模块,或者基带是高通。关于4G网络原理,这里就不探讨了,还是专注于4G模块的驱动及电话功能的调试。

模块硬件需要参考具体的模块硬件接口手册,目前基本是基于USB口。

驱动部分:
1.kernle/drivers/usb/serial/option.c中加入模块VID和PID      
2
如果拨号上网则配置PPP,make menuconfig后
Device Drivers --->
    -*-Network device support --->
        {*}ppp(point-to-point protocol) support
              ……
        [*]   ppp support for async serial ports
        [*]   ppp support for sync tty ports
              ……
        一般选择以上即可,如果需要更多PPP服务,则PPP相关都选择上。
……

3.配置USB MODEM
Device Drivers --->
    [*]USB support --->
        [*]USB Serial Conerter support --->
            [*]USB Generic Serial Driver
             ……
            [*]USB driver for GSM and CDMA modems
……
    
重新编译内核。

设备正常加载后,输入命令“ls /dev/ttyUSB*”后会看到有ttyUSB(0,1,2,-,-)映射出来。

系统应用部分:
1.在init.rc中加入下面服务,下面“-- -d /dev/ttyUSB(1,2,3,,)”部分,使用哪个端口根据实际情况,若没有指定端口默认AT端口使用/dev/ttyUSB2,上网使用/dev/ttyUSB1
service ril-daemon /system/bin/rild -l /system/lib/libreference-ril.so -- -d /dev/ttyUSB2 -m /dev/ttyUSB1
    class main
    socket rild stream 660 root radio
    socket rild-debug stream 660 radio system
    user root
    group radio cache inet misc  audio sdcard_rw
2.修改或者由4G模块厂商提供:/hardware/ril/reference-ril/reference-ril.c
3.编译生成so,重新生成镜像。

附:
1.另外out/out/target/product/demoboardname/system/etc/ppp/下的ip-up内是否有类似下面信息,若没有则加入,
/system/bin/setprop "net.interfaces.defaultroute" "gprs"
/system/bin/setprop "net.ppp0.dns1" "$DNS1"
/system/bin/setprop "net.ppp0.dns2" "$DNS2"
/system/bin/setprop "net.ppp0.local-ip" "$IPLOCAL"
/system/bin/setprop "net.ppp0.remote-ip" "$IPREMOTE"
/system/bin/setprop "net.dns1" "$DNS1"
/system/bin/setprop "net.dns2" "$DNS2"

2.out/out/target/product/demoboardname/system/etc/下要加入apns-conf.xml .apn设置参考(mnc及mcc各一例):
中国移动:
   <apn carrier="中国移动因特网设置"
         mcc="460"
         mnc="00"
         apn="cmnet"
         type="default,supl"
    />
    <apn carrier="中国移动WAP设置"
         mcc="460"
         mnc="00"
         apn="cmwap"
         proxy="010.000.000.172"
         port="80"
         type="wap"
    />
    <apn carrier="中国移动彩信设置"
         mcc="460"
         mnc="00"
         apn="cmwap"
         proxy="010.000.000.172"
         port="80"
         mmsproxy="010.000.000.172"
         mmsport="80"
         mmsc="http://mmsc.monternet.com"
         type="mms"
    />


中国联通:
   <apn carrier="中国联通因特网设置"
         mcc="460"
         mnc="01"
         apn="3gnet"
         type="default,supl"
    />
    <apn carrier="中国联通WAP设置"
         mcc="460"
         mnc="01"
         apn="3gwap"
         proxy="010.000.000.172"
         port="9201"
         type="wap"
    />
    <apn carrier="中国联通彩信设置"
         mcc="460"
         mnc="01"
         apn="3gwap"
         proxy="010.000.000.172"
         port="80"
         mmsproxy="010.000.000.172"
         mmsport="80"
         mmsc="http://mmsc.myuni.com.cn"
         type="mms"
    />


中国电信:
    <apn carrier="ChinaTelecom net"
         mcc="460"
         mnc="03"
         apn="ctnet"
         type="default,supl"
    />
    <apn carrier="ChinaTelecom wap"
         mcc="460"
         mnc="03"
         apn="ctwap"
         user="[email protected]"
         password="vnet.mobi"
         proxy="010.000.000.200"
         port="80"
         type="wap"
    />
    <apn carrier="ChinaTelecom mms"
         mcc="460"
         mnc="03"
         apn="ctwap"
         user="[email protected]"
         password="vnet.mobi"
         server="*"
         proxy="010.000.000.200"
         port="80"
         mmsproxy="010.000.000.200"
         mmsport="80"
         mmsc="http://mmsc.vnet.mobi"
         type="mms"
    />


3.out/out/target/product/demoboardname/system/etc/下要加入spn-conf.xml.spn参考如下:
<?xml version="1.0" encoding="utf-8"?>
<spnOverrides>
    <spnOverride
      numeric="46000"
      spn="中国移动"/>
     <spnOverride
      numeric="46001"
      spn="中国联通"/>
    <spnOverride
      numeric="46002"
      spn="中国移动"/>
    <spnOverride
      numeric="46003"
      spn="中国电信"/>
    <spnOverride
        numeric="46007"
        spn="中国移动"/>
    <spnOverride
        numeric="46009"
        spn="中国电信"/>
    <spnOverride
        numeric="46011"
        spn="中国电信"/>
     <spnOverride
         numeric="20404"
         spn="中国电信"/>
</spnOverrides>

4.需要加入到系统makefile编译的应用:

/packages/services/
Mms
Telecomm  
Telephony

/packages/providers/
ContactsProvider
TelephonyProvider

/packages/apps/
Contacts
ContactsCommon
Dialer
InCallUI
Mms
Phone (此文件夹是空,就不用编译)
PhoneCommon

5.需要修改系统默认的配置文件config.xml


/device/
product/overlay/frameworks/base/core/res/res/values/
   5.1 <string-array translatable="false" name="networkAttributes">
        <item>"wifi,1,1,1,-1,true"</item>
<item>"mobile,0,0,0,-1,true"</item>
        <item>"mobile_mms,2,0,2,60000,true"</item>
        <item>"mobile_supl,3,0,2,60000,true"</item>
        <item>"mobile_hipri,5,0,3,60000,true"</item>
        <item>"mobile_fota,10,0,2,60000,true"</item>
        <item>"mobile_ims,11,0,2,60000,true"</item>
        <item>"mobile_cbs,12,0,2,60000,true"</item>
        <item>"wifi_p2p,13,1,0,-1,true"</item>
        <item>"mobile_ia,14,0,2,-1,true"</item>
        <item>"ethernet,9,9,9,-1,true"</item>
<item>"mobile_emergency,15,15,1,-1,true"</item>
        <item>"pppoe,18,18,1,-1,true"</item>
    </string-array>


    <!-- This string array should be overridden by the device to present a list of radio
         attributes.  This is used by the connectivity manager to decide which networks can coexist
         based on the hardware -->
    <!-- An Array of "[ConnectivityManager connectionType],
                      [# simultaneous connection types]"  -->
    <string-array translatable="false" name="radioAttributes">
    <item>"0,1"</item>
        <item>"1,1"</item>
        <item>"9,1"</item>
<item>"15,1"</item>
<item>"15,15"</item><!--modify by h-->
        <item>"18,1"</item>
    </string-array>
    
    2.2 <bool name="config_voice_capable">true</bool><!--h-->
    <bool name="config_sms_capable">true</bool><!--h-->


/frameworks/base/core/res/res/values/
    <string-array translatable="false" name="networkAttributes">
        <item>"wifi,1,1,1,-1,true"</item>
        <item>"mobile,0,0,0,-1,true"</item>
        <item>"mobile_mms,2,0,2,60000,true"</item>
        <item>"mobile_supl,3,0,2,60000,true"</item>
        <item>"mobile_hipri,5,0,3,60000,true"</item>
        <item>"mobile_fota,10,0,2,60000,true"</item>
        <item>"mobile_ims,11,0,2,60000,true"</item>
        <item>"mobile_cbs,12,0,2,60000,true"</item>
        <item>"wifi_p2p,13,1,0,-1,true"</item>
        <item>"mobile_ia,14,0,2,-1,true"</item>
        <item>"mobile_emergency,15,15,1,-1,true"</item>
    </string-array>


    <!-- Array of ConnectivityManager.TYPE_xxxx constants for networks that may only
         be controlled by systemOrSignature apps.  -->
    <integer-array translatable="false" name="config_protectedNetworks">
        <item>10</item>
        <item>11</item>
        <item>12</item>
        <item>14</item>
       <!-- <item>15</item>-->
    </integer-array>


    <!-- This string array should be overridden by the device to present a list of radio
         attributes.  This is used by the connectivity manager to decide which networks can coexist
         based on the hardware -->
    <!-- An Array of "[ConnectivityManager connectionType],
                      [# simultaneous connection types]"  -->
    <string-array translatable="false" name="radioAttributes">
        <item>"1,1"</item>
        <item>"0,1"</item>
<item>"15,15"</item>
    
        <item>"1,15"</item>
    </string-array>


    <!-- Set of NetworkInfo.getType() that reflect data usage. -->
    <integer-array translatable="false" name="config_data_usage_network_types">
        <item>0</item> <!-- TYPE_MOBILE -->
        <item>2</item> <!-- TYPE_MOBILE_MMS -->
        <item>3</item> <!-- TYPE_MOBILE_SUPL -->
        <item>4</item> <!-- TYPE_MOBILE_DUN -->
        <item>5</item> <!-- TYPE_MOBILE_HIPRI -->
        <item>10</item> <!-- TYPE_MOBILE_FOTA -->
        <item>11</item> <!-- TYPE_MOBILE_IMS -->
        <item>12</item> <!-- TYPE_MOBILE_CBS -->
        <item>14</item> <!-- TYPE_MOBILE_IA -->
<item>15</item>
    </integer-array>


在调试过程中需要用到很多的基本技能,比如查看ril的打印信息,logcat -b radio ,分析ril驱动还需要对于AT指令的熟悉,同时还需要对于以上跳到的framework和packages里面phone相关的代码分析。

由于电视芯片基本没有考虑到phone的功能,所以关于phone功能的调试更多的是自己过硬的技术,同时也可以和模块原厂多沟通,虽然模块原厂对于android平台很少有人指导,但是对于ril驱动的调试,还是有很大帮助。

以上调试基于android5.1版本,android4.3 及 android4.4调试比较简单,这里就不再赘述。

猜你喜欢

转载自blog.csdn.net/rayxiang520/article/details/78602978