赞
踩
1. 查看系统是否支持该4G NL668模块
ls /dev/ttyUSB*
看下是否有相对应的节点:
没有找到设备虚拟串口节点,说明底层驱动需要移植NL668模块驱动,实际上是添加该模块的PID和VID,该模块走的是欢迎大家访问USB接口;
2.底层驱动调试
(1)第一步当然是找4G模块供应商提供一份调试资料和对应系统使用的RIL库;
(2)根据驱动一直的文档《Fibocom_RIL集成指南_Android_V2.2.pdf》进行调试;
(3)添加广和通NL668模块的PID和VID
路径:kernel/drivers/usb/serial/option.c
static const struct usb_device_id option_ids[] = {
+ { USB_DEVICE(0x1508, 0x1001) }, /* Fibocom NL668 */
(4)过滤机制
Android 11系统自带过滤机制,特殊情况下需要另行添加。
(5)配置串口驱动的Linux内核
a,执行cd kernel命令,进入内核根目录。
b,执行make menuconfig命令。
c,在弹出来的界面中依次选择:Device Drivers > USB support > USB Serial Converter support。
d,选中如下USB driver for GSM and CDMA modems组件后,保存推出。
注意:关于Linux 内核配置以客户系统配置规则为准,本文描述的方法仅供参考。
(6)DTS配置,RM310的参考配置。
../../../dts/rockchip/rk**.dtsi:
rk_modem: rk-modem {
compatible="4g-modem-platdata";
pinctrl-names = "default";
pinctrl-0 = <<e_vbat <e_power_en <e_reset>;
4G,vbat-gpio = <&gpio4 RK_PD0 GPIO_ACTIVE_HIGH>;
4G,power-gpio = <&gpio4 RK_PC6 GPIO_ACTIVE_LOW>;
4G,reset-gpio = <&gpio4 RK_PD4 GPIO_ACTIVE_LOW>;
status = "okay";
};
(7)4G模块的驱动控制,可以参考RM310。
kernel/drivers/net/lte/lte_rm310.c
(8)配置kernel支持ECM 网卡方式和模块交互(推荐使用 ECM 驱动);
修改内核配置选项:
CONFIG_USB_NET_DRIVERS=y
CONFIG_USB_USBNET=y
CONFIG_NETDEVICES=y
CONFIG_USB_NET_CDCETHER=y
模块连接到目标板,主机会枚举出一个 ethx 的网络设备。RM310 模块,可以自动拨号上网,自动注册网络,并附着 PDP 业务。
3.设备加载检测
NL668 4G 模块,PID:0x1508,VID:0x1001。模块成功上电后,枚举出 ttyUSB0~ttyUSB3,用于调试口、AT 口、上网口。拨号后,生成 lte0 网口设备。若加载成功,会有以下内容返回。
ls /dev/ 或者 ls /dev/yytUSB*
1.在引入新库之前先将RK源码中,系统启动时启动RILD的进程关闭
--- a/hardware/ril/rild/init.rc
+++ b/hardware/ril/rild/init.rc
-service vendor.ril-daemon /vendor/bin/hw/rild
- class main
- user radio
- group radio cache inet misc audio log readproc wakelock
- capabilities BLOCK_SUSPEND NET_ADMIN NET_RAW
2.添加NL668模块的RIL库和相关组件,以及存放位置
需要模组厂提供RIL库libreference-ril.so,另外需组件chat、ip-down、ip-up。若模组厂只提供RIL库,其余组件可使用RK自带的组件。
注意:因为RK源码会编译生成RIL库,库名字也是libreference-ril.so,因此需要将模组厂的库修改名字:libreference-ril-nl668.so。
存放位置:(一般存放位置,也可自行选择目录,最终也是拷贝到out目录下)
vendor/rockchip/common/phone/bin/chat
vendor/rockchip/common/phone/etc/ppp/ip-down
vendor/rockchip/common/phone/etc/ppp/ip-up
vendor/rockchip/common/phone/lib/libreference-ril-nl668.so
3.RIL库和相关组件,配置到编译文件中
--- a/vendor/rockchip/common/phone/phone.mk
+++ b/vendor/rockchip/common/phone/phone.mk
CUR_PATH := vendor/rockchip/common
#########################################################
# 3G Dongle SUPPORT
#########################################################
- PRODUCT_COPY_FILES += \
- $(CUR_PATH)/phone/etc/ppp/ip-down:system/etc/ppp/ip-down \
- $(CUR_PATH)/phone/etc/ppp/ip-up:system/etc/ppp/ip-up \
- $(CUR_PATH)/phone/etc/ppp/ip-down:system/etc/ppp/ip-down \
- $(CUR_PATH)/phone/etc/ppp/ip-up:system/etc/ppp/ip-up \
- $(CUR_PATH)/phone/etc/ppp/call-pppd:system/etc/ppp/call-pppd \
- $(CUR_PATH)/phone/etc/operator_table:system/etc/operator_table
+PRODUCT_COPY_FILES += \
+ $(CUR_PATH)/phone/etc/ppp/ip-down:system/etc/ppp/ip-down \
+ $(CUR_PATH)/phone/etc/ppp/ip-up:system/etc/ppp/ip-up \
+ $(CUR_PATH)/phone/etc/ppp/call-pppd:system/etc/ppp/call-pppd \
+ $(CUR_PATH)/phone/etc/operator_table:system/etc/operator_table \
+ $(CUR_PATH)/phone/lib/libreference-ril-nl668.so:vendor/lib64/libreference-ril-nl668.so
4.radio配置
(1)库和组件加载好后,需要启动ril-daemon服务,可以在hardware/ril/rild/init.rc指定,
--- a/hardware/ril/rild/init.rc
+++ b/hardware/ril/rild/init.rc
-service vendor.ril-daemon /vendor/bin/hw/rild
- class main
- user radio
- group radio cache inet misc audio log readproc wakelock
- capabilities BLOCK_SUSPEND NET_ADMIN NET_RAW
+service ril-daemon /vendor/bin/hw/rild -l /vendor/lib64/libreference-ril-nl668.so -- -d /dev/ttyUSB0
+ 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 log
也可以在/device/rockchip/目录指定:
- rild.libpath=/system/lib/libril-rk29-dataonly.so \
- rild.libargs=-d /dev/ttyACM0 \
+ vendor.rild.libpath=/vendor/lib64/libreference-ril-nl668.so \
+ vendor.rild.libargs=-d /dev/ttyUSB0 \
(2)配置使用网络类型和指定的RIL库
--- a/device/rockchip/rk356x/device.mk
+++ b/device/rockchip/rk356x/device.mk
PRODUCT_PROPERTY_OVERRIDES += \
ro.ril.ecclist=112,911 \
ro.opengles.version=196610 \
wifi.interface=wlan0 \
+ rild.libpath=/vendor/lib64/libreference-ril-nl668.so \
+ rild.libargs=-d /dev/ttyUSB0 \
ro.audio.monitorOrientation=true \
debug.nfc.fw_download=false \
debug.nfc.se=false \
5.打开BOARD_HAS_RK_4G_MODEM开关
打开BOARD_HAS_RK_4G_MODEM开关,是系统开启4G服务功能。
--- a/device/rockchip/common/BoardConfig.mk
+++ b/device/rockchip/common/BoardConfig.mk
#for rk 4g modem
-BOARD_HAS_RK_4G_MODEM ?= false
+BOARD_HAS_RK_4G_MODEM ?= true
6.拨号方式
根据模组厂提供的文档,修改拨号方式。
PRODUCT_PROPERTY_OVERRIDES += \
ril.fibocom.dialmode=1 (ECM拨号方式) \
ril.fibocom.dialmode=0 (PPP拨号方式) \ /*拨号方式二选一*/
ril.fibocom.usbmode=18 (USB端口模式)
串口下getprop可以查看当前添加的属性。
7.Android 11.0 注意事项
device/rockchip/common 目录,打开宏 BOARD_HAS_RK_4G_MODEM,不需要打开
BOARD_HAVE_DONGLE。vendor.rild.libpath 修改为模组提供的库的路径。
以 RK356x 为例,在/device/rockchip/rk356x 对应的配置文件中加入以下修改:
--- a/device/rockchip/rk356x/overlay/frameworks/base/core/res/res/values/config.xml
+++ b/device/rockchip/rk356x/overlay/frameworks/base/core/res/res/values/config.xml
<!-- the 6th element indicates boot-time dependency-met value. -->
<string-array translatable="false" name="networkAttributes">
<item>"wifi,1,1,2,-1,true"</item>
+ <item>"mobile,0,0,0,-1,true"</item>
+ <item>"mobile_mms,2,0,2,60000,false"</item>
+ <item>"mobile_supl,3,0,2,60000,true"</item>
+ <item>"mobile_dun,4,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>"bluetooth,7,7,0,-1,true"</item>
<item>"ethernet,9,9,9,-1,true"</item>
</string-array>
该配置文件是修改设置应用和下拉框没有移动数据选项。
设置->网络和互联网->"移动网络"
8.优选网络接入模式
设置网络接入模式优选:ro.telephony.default_network
(1)若需要支持 5G,请在/device/rockchip/……/device.mk,设置
ro.telephony.default_network = 33 即 NETWORK_MODE_NR_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA。
(2)优选网络接入模式为 4G,设置
ro.telephony.default_network = 9 即 NETWORK_MODE_LTE_GSM_WCDMA。
9.编译Android升级
10.模块测试
(1)查看RIL库是否加载成功
在log中查看是否有以下打印信息:
.../hardware/ril/rild/rild.c
// ril/socket id received as -c parameter, otherwise set to 0
const char *clientId = NULL;
RLOGD("**RIL Daemon Started**");
RLOGD("**RILd param count=%d**", argc);
umask(S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH);
for (i = 1; i < argc ;) {
(2)模块测试
测试 AT 功能,查询网络驻留状态,SIM 卡状态,PDP 激活情况等。
#microcom -s 115200 /dev/ttyUSB1
SIM 卡是否正常识别:
AT+CPIN?
+CPIN: READY
OK
查询 CS 域注册状态:
AT+CREG?
+CREG: 2,1,"27A3","2C3DE15",7
OK
查询 EPS 域注册状态:
AT+CEREG?
+CEREG: 1,"252C","0A26C916",7
OK
确认 4G 系统状态:
AT^SYSINFO
^SYSINFO: 2,3,0,17,1,7
OK
查询 PDP 激活信息:
AT+CGDCONT?
+CGDCONT:1," IPV4V6 "," cmnet ","10.27.12.98",0,0,,,,
OK
注意:AT指令的使用,例如查看USB端口号:
echo -e "AT+GTUSBMODE=18\n" > /dev/ttyUSB2
cat /dev/ttyUSB2 &
1.获取 log 信息
打开串口,输入以下命令,查看串口信息
logcat –b radio & //ril log
logcat –s pppd & //ppp 拨号 log
logcat –c –b radio & //清除以前 raido log
logcat -b system -b main -b radio -v time &// 完整的系统 logcat
1.ril_daemon服务不断在重启
打印的kernel信息如下:
init: Control message: Could not find 'android.hardware.radio@1.1::IRadio/slot1' for ctl.interface_start from pid: 144 (/system/bin/hwservicemanager)
init: Control message: Could not find 'android.hardware.radio@1.1::IRadio/slot1' for ctl.interface_start from pid: 144 (/system/bin/hwservicemanager)
init: Control message: Could not find 'android.hardware.radio@1.1::IRadio/slot1' for ctl.interface_start from pid: 144 (/system/bin/hwservicemanager)
init: starting service 'ril-daemon'...
init: Untracked pid 14226 exited with status 0
init: Service 'ril-daemon' (pid 14222) received signal 11
init: Sending signal 9 to service 'ril-daemon' (pid 14222) process group...
libprocessgroup: Successfully killed process cgroup uid 1001 pid 14222 in 5ms
init: Untracked pid 14228 exited with status 0
然后查看logcat信息,发现系统加载/vendor/lib64/libreference-ril-nl668.so时会崩溃;查看这个RIL库是否适合在Android 11上使用,若不支持Android 11需找模组厂提供新的库。
若只是单纯报错一下内容,则查看是否接入4G模块或于硬件接触是否良好。
[ 103.991016] init: Control message: Processed ctl.interface_start for 'android.hardware.radio@1.1::IRadio/slot1' from pid: 144 (/system/bin/hwservicemanager)
[ 104.992025] init: Control message: Processed ctl.interface_start for 'android.hardware.radio@1.1::IRadio/slot1' from pid: 144 (/system/bin/hwservicemanager)
[ 105.992868] init: Control message: Processed ctl.interface_start for 'android.hardware.radio@1.1::IRadio/slot1' from pid: 144 (/system/bin/hwservicemanager)
[ 106.993940] init: Control message: Processed ctl.interface_start for 'android.hardware.radio@1.1::IRadio/slot1' from pid: 144 (/system/bin/hwservicemanager)
2.获取APN数据为空,导致APN设置失败不注网
报相关错误:
07-12 17:23:48.361 D/Phone ( 866): getImsRegistrationTechnology =-1
07-12 17:23:48.362 E/DCT-C-0 ( 866): getPreferredApnSetId: cursor is null
07-12 17:23:48.362 D/DCT-C-0 ( 866): hasMatchedTetherApnSetting: APNs=[]
07-12 17:23:48.380 D/DCT-C-0 ( 866): shouldRestrictDataForEcbm: isInEcm=false isInImsEcm=false
因系统获取不到APN数据,没法匹配SIM卡对应的APN,导致无法注网的解决办法:
--- a/frameworks/opt/telephony/src/java/com/android/internal/telephony/dataconnection/DcTracker.java
+++ b/frameworks/opt/telephony/src/java/com/android/internal/telephony/dataconnection/DcTracker.java
public class DcTracker extends Handler {
if (!isCarrierConfigApplied()) {
log("onCarrierConfigChanged: Carrier config is not ready yet.");
- return;
+ //return;
}
3.上网成功,但状态栏上移动信号图标显示只有空三角图标显示
修改qi-ril.conf文件:LTE_ls_Report_SignalStrength=1
参考:[RK3568 Android11] 开发之4G模块(移远模块)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。