当前位置: 代码迷 >> 综合 >> [RK3288][Android5.1] 调试笔记 --- 根据VIDPID读取不同的rilLib以实现4G模块的适配
  详细解决方案

[RK3288][Android5.1] 调试笔记 --- 根据VIDPID读取不同的rilLib以实现4G模块的适配

热度:111   发布时间:2023-10-09 13:45:03.0

Platform: RK3288
OS: Android 5.1.1
Kernel: v3.10.0

需求:

适配4G模块,本文以YUGA-CLM920-AC3为例

1、添加USB转虚拟串口设备

把4G模块虚拟成ttyUSB0~ttyUSB5等几个虚拟串口。

1.1 确认模块的Vendor ID and Product ID

方法一:根据厂商提供的适配文档确认模块VID、PID

方法二:拔插4G模块,根据内核日志确认模块VID、PID

1.2 kernel驱动修改

添加宏定义&添加blacklist

diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index f89de98..6f86d12 100755
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -418,8 +418,14 @@ static void option_instat_callback(struct urb *urb);#define YUGE_PRODUCT_CLM920_EC5                0x9020#define YUGE_PRODUCT_CLM920_NC5_1      0x9025#define YUGE_PRODUCT_CLM920_NC5_2      0x9625
+#define YUGA_VENDOR_AC3                        0x1286
+#define YUGA_PRODUCT_AC3               0x4E3C
+#define YUGA_PRODUCT_CLM920_NC5_GPS    0x9125  //end
+
+#define YUGA_VENDOR_ID                         0x257A#define YUGA_PRODUCT_CEM600                    0x1601#define YUGA_PRODUCT_CEM610                    0x1602
@@ -626,7 +632,9 @@ static const struct option_blacklist_info nodecom_nl650_blacklist = {.reserved = BIT(4) | BIT(5),};/*end add*/
-
+static const struct option_blacklist_info YUGA_VENDOR_AC3_blacklist = {
+        .reserved = BIT(0) | BIT(1),
+};static const struct option_blacklist_info YUGA_9X07_GPS_blacklist = {.reserved = BIT(0) | BIT(1) | BIT(5),
@@ -1836,6 +1844,8 @@ static const struct usb_device_id option_ids[] = {.driver_info = (kernel_ulong_t)&YUGA_9X07_blacklist },{ USB_DEVICE(CLM920_VENDOR_ID, YUGA_PRODUCT_CLM920_NC5_GPS),.driver_info = (kernel_ulong_t)&YUGA_9X07_GPS_blacklist },
+       { USB_DEVICE(YUGA_VENDOR_AC3, YUGA_PRODUCT_AC3),
+         .driver_info = (kernel_ulong_t)&YUGA_VENDOR_AC3_blacklist },

1.3 验证是否修改成功

 编译并烧录完成后,插入4G模块通过查询命令:ls /dev/ttyU*,应有 ttyUSB0、ttyUSB1、ttyUSB2 三个端口,如 下图:

[RK3288][Android5.1] 调试笔记 --- 根据VIDPID读取不同的rilLib以实现4G模块的适配

或者加载模块时的内核日志,如下图:

[RK3288][Android5.1] 调试笔记 --- 根据VIDPID读取不同的rilLib以实现4G模块的适配

2.导入rilLib文件

模块厂商会提供一堆rilLib文件,根据主板CPU(32位还是64位),以及系统版本选对应的rilLib文件;

2.1 将rilLib文件放置到源码并加到mk文件进行编译

路径:/vendor/rockchip/common/phone/lib

为了方便维护,将rilLib文件名改为libreference-ril-yuga-ac3.so

路径:/vendor/rockchip/common/phone/phone.mk

diff --git a/phone/phone.mk b/phone/phone.mk
index 3051b60..b43a50e 100755
--- a/phone/phone.mk
+++ b/phone/phone.mk
@@ -37,6 +37,7 @@ PRODUCT_COPY_FILES += \$(CUR_PATH)/phone/lib/libreference-ril-me3630.so:system/lib/libreference-ril-me3630.so \$(CUR_PATH)/phone/lib/libsoftwinner-ril-yuga-all2.so:system/lib/libsoftwinner-ril-yuga-all2.so \$(CUR_PATH)/phone/lib/libreference-ril-nodecom-5.1.so:system/lib/libreference-ril-nodecom-5.1.so \
+       $(CUR_PATH)/phone/lib/libreference-ril-yuga-ac3.so:system/lib/libreference-ril-yuga-ac3.so \$(CUR_PATH)/phone/lib/libreference-ril-U9507E.so:system/lib/libreference-ril-U9507E.so

 以上步骤没有问题编译之后将在out/target/product/rk3288/system/lib/生成该rilLib文件

2.2 修改rild.c以实现根据不同的VID、PID开机读取指定的rilLib。

路径:/hardware/ril/rild/rild.c

diff --git a/rild/rild.c b/rild/rild.c
index 5774a04..248236c 100644
--- a/rild/rild.c
+++ b/rild/rild.c
@@ -336,6 +336,8 @@ done:#define   YUGA_VENDOR_ID_CM920 "05c6"#define   YUGA_TB5_PRODUCT_ID  "9025"
+#define   YUGA_VENDOR_ID_AC3 "1286"
+#define   YUGA_AC3_PRODUCT_ID  "4e3c"#define   ME3630_VENDOR_ID   "19d2"#define   ME3630_PRODUCT_ID  "1476"
@@ -384,7 +386,7 @@ int checkVendor(char* path)ALOGD("tempPath = %s, idVendor = %s", tempPath, idVendor);if((strcmp(idVendor, YUGA_VENDOR_ID) == 0)
-     || (strcmp(idVendor, YUGA_VENDOR_ID_CM920) == 0)){
+     || (strcmp(idVendor, YUGA_VENDOR_ID_CM920) == 0)  || (strcmp(idVendor, YUGA_VENDOR_ID_AC3) == 0)){return VENDOR_YUGA;}else if(strcmp(idVendor, LONGSHAN_VENDOR_ID) == 0){return VENDOR_LONGSHAN;
@@ -603,6 +605,8 @@ OpenLib:flag = HWM600;}if((NULL != idProduct) && (strcmp(idProduct,YUGA_HEM600_PRODUCT_ID) == 0)){rilLibPath = "/system/lib/libreference-ril-yuga-hem600.so";
+            } if ((NULL != idProduct) && (strcmp(idProduct, YUGA_AC3_PRODUCT_ID) == 0)) {
+                rilLibPath = "/system/lib/libreference-ril-yuga-ac3.so";}else{rilLibPath = "/system/lib/libsoftwinner-ril-yuga-all2.so";}
(END)

原理

C语言strcmp库函数:

int strcmp(const char *str1, const char *str2)

C 库函数 int strcmp(const char *str1, const char *str2) 把 str1 所指向的字符串和 str2 所指向的字符串进行比较。

该函数返回值如下:

如果返回值小于 0,则表示 str1 小于 str2。

如果返回值大于 0,则表示 str1 大于 str2。

如果返回值等于 0,则表示 str1 等于 str2。

报错

dlopen failed: dlopen failed: empty/missing DT_HASH in "libreference-ril-Longsung-M5700.so" (built with --hash-style=gnu?)

咨询模块厂商,打开rilLib失败,需要模块厂商这边修改rilLib;或者提供与当前系统(android5.1/7.1、32位/64位)兼容的rilLib;

踩过的坑 

blacklist不是必须要添加,若适配文档还有明确要求则不需要添加

diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index 6f86d12..3bc3f9d 100755
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -425,6 +425,10 @@ static void option_instat_callback(struct urb *urb);#define YUGA_PRODUCT_CLM920_NC5_GPS    0x9125//end+// add for M5700
+#define Longsung_VENDOR_M5700                  0x1782
+#define Longsung_PRODUCT_M5700         0x4d10
+// end#define YUGA_VENDOR_ID                         0x257A#define YUGA_PRODUCT_CEM600                    0x1601
@@ -480,6 +484,8 @@ static void option_instat_callback(struct urb *urb);#define YUGA_PRODUCT_CLU528                    0x360D#define YUGA_PRODUCT_CLU526                    0x360F+
+/* Viettel products */#define VIETTEL_VENDOR_ID                      0x2262#define VIETTEL_PRODUCT_VT1000                 0x0002
@@ -645,6 +651,7 @@ static const struct option_blacklist_info YUGA_9X07_blacklist = {};// add end+static const struct usb_device_id option_ids[] = {//add by ZHQ 2017-11-23 for Quectel EC20//{ USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_ID) },
@@ -1846,6 +1853,7 @@ static const struct usb_device_id option_ids[] = {.driver_info = (kernel_ulong_t)&YUGA_9X07_GPS_blacklist },{ USB_DEVICE(YUGA_VENDOR_AC3, YUGA_PRODUCT_AC3),.driver_info = (kernel_ulong_t)&YUGA_VENDOR_AC3_blacklist },
+       { USB_DEVICE(Longsung_VENDOR_M5700,  Longsung_PRODUCT_M5700)},{ USB_DEVICE(CLM920_VENDOR_ID, YUGE_PRODUCT_CLM920_EC5) },{ USB_DEVICE(CLM920_VENDOR_ID, YUGE_PRODUCT_CLM920_NC5_2) },/* add end */

 

  相关解决方案