RK3568 Android12 移远4G模块EM05-CE 调试心得

Platform: RK3568
OS: Android 12
Kernel: v4.19.206
SDK Version:android-12.0-mid-rkr1
Module :Quectel EM05-CE


需求

适配Quectel EM05-CE模块

配置步骤

总体步骤是参考了旋风旋风的博客1,写的非常详细,获益良多,我这边就不再重复了。

最好要获得模组厂的技术支持,能拿到最新的驱动和ril库,还有文档等资源。根据模组厂的移植文档,主要可以分为kernel驱动和Android部分。

  • kernel驱动部分参考《Quectel_LTE&5G_Linux_USB_Driver_User_Guide_V2.0.pdf》
  • Android部分参考《Quectel_Android_RIL_Driver_User_Guide_V2.0.pdf》

主要说几处差异吧:

  1. 没有配置dts而是直接在init中设置gpio电平给模组供电。
  2. 驱动部分的drivers\usb\serial\option.c 中没有去添加vid,pid,因为默认代码已经有做适配了,除非还有缺少的模组id 可以另外补上,我使用的EM05模组对应的id是0x2c7c和0x0125看到是已经有支持了。
#define QUALCOMM_VENDOR_ID                      0x05C6
/* These Quectel products use Qualcomm's vendor ID */
#define QUECTEL_PRODUCT_UC20                    0x9003
#define QUECTEL_PRODUCT_UC15                    0x9090
/* These u-blox products use Qualcomm's vendor ID */
#define UBLOX_PRODUCT_R410M                     0x90b2
#define UBLOX_PRODUCT_R6XX                      0x90fa
/* These Yuga products use Qualcomm's vendor ID */
#define YUGA_PRODUCT_CLM920_NC5                 0x9625

#define QUECTEL_VENDOR_ID                       0x2c7c
/* These Quectel products use Quectel's vendor ID */
#define QUECTEL_PRODUCT_EC21                    0x0121
#define QUECTEL_PRODUCT_EC25                    0x0125
#define QUECTEL_PRODUCT_EG95                    0x0195
#define QUECTEL_PRODUCT_BG96                    0x0296
#define QUECTEL_PRODUCT_EP06                    0x0306
#define QUECTEL_PRODUCT_EM12                    0x0512
#define QUECTEL_PRODUCT_RM500Q                  0x0800
#define QUECTEL_PRODUCT_EC200T                  0x6026

…………
/* Quectel products using Quectel vendor ID */
        { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC21, 0xff, 0xff, 0xff),
          .driver_info = NUMEP2 },
        { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC21, 0xff, 0, 0) },
        { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC25, 0xff, 0xff, 0xff),
          .driver_info = NUMEP2 },
        { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC25, 0xff, 0, 0) },
        { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EG95, 0xff, 0xff, 0xff),
          .driver_info = NUMEP2 },
        { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EG95, 0xff, 0, 0) },
        { USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_BG96),
          .driver_info = RSVD(4) },
        { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EP06, 0xff, 0xff, 0xff),
          .driver_info = RSVD(1) | RSVD(2) | RSVD(3) | RSVD(4) | NUMEP2 },
        { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EP06, 0xff, 0, 0) },
        { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EM12, 0xff, 0xff, 0xff),
          .driver_info = RSVD(1) | RSVD(2) | RSVD(3) | RSVD(4) | NUMEP2 },
        { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EM12, 0xff, 0, 0) },
        { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, 0x0620, 0xff, 0xff, 0x30) }, /* EM160R-GL */
        { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, 0x0620, 0xff, 0, 0) },
        { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_RM500Q, 0xff, 0xff, 0x30) },
        { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_RM500Q, 0xff, 0, 0) },
        { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_RM500Q, 0xff, 0xff, 0x10),
          .driver_info = ZLP },
        { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC200T, 0xff, 0, 0) },

  1. 我们用的qmi_wwan_q.c文件版本为Quectel_Linux&Android_QMI_WWAN_Driver_V1.2.1,适配成功后在内核打印中可以看到在识别到usb模块后会有个加载网卡的信息:
[   19.510335] usb 5-1: new high-speed USB device number 2 using xhci-hcd
[   19.660347] usb 5-1: New USB device found, idVendor=2c7c, idProduct=0125, bcdDevice= 3.18
[   19.660381] usb 5-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[   19.660388] usb 5-1: Product: LTE Module
[   19.660395] usb 5-1: Manufacturer: Quectel Incorporated
[   19.811750] option 5-1:1.0: GSM modem (1-port) converter detected
[   19.812923] usb 5-1: GSM modem (1-port) converter now attached to ttyUSB0
[   19.813529] option 5-1:1.1: GSM modem (1-port) converter detected
[   19.815846] usb 5-1: GSM modem (1-port) converter now attached to ttyUSB1
[   19.817443] option 5-1:1.2: GSM modem (1-port) converter detected
[   19.818410] usb 5-1: GSM modem (1-port) converter now attached to ttyUSB2
[   19.819589] option 5-1:1.3: GSM modem (1-port) converter detected
[   19.820894] usb 5-1: GSM modem (1-port) converter now attached to ttyUSB3
[   19.875508] qmi_wwan_q 5-1:1.4: cdc-wdm0: USB WDM device
[   19.875656] dwmac4: Master AXI performs any burst length
[   19.875693] rk_gmac-dwmac fe010000.ethernet eth0: No Safety Features support found
[   19.875718] rk_gmac-dwmac fe010000.ethernet eth0: IEEE 1588-2008 Advanced Timestamp supported
[   19.875856] qmi_wwan_q 5-1:1.4: terry shows QUECTEL_WWAN_VERSION = Quectel_Linux&Android_QMI_WWAN_Driver_V1.2.1
[   19.875866] qmi_wwan_q 5-1:1.4: Quectel LTE Module work on RawIP mode
[   19.876715] qmi_wwan_q 5-1:1.4: rx_urb_size = 1520
[   19.878678] rk_gmac-dwmac fe010000.ethernet eth0: registered PTP clock
[   19.880218] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
[   19.881325] qmi_wwan_q 5-1:1.4 wwan0: register 'qmi_wwan_q' at usb-xhci-hcd.5.auto-1, WWAN/QMI device, 0a:dd:8b:1d:3a:2b

驱动适配完成后可以看到模组id,ttyUSB* 节点和cdc-wdm0节点

console:/ # lsusb
Bus 005 Device 001: ID 1d6b:0002
Bus 003 Device 001: ID 1d6b:0001
Bus 002 Device 002: ID 1a40:0101
Bus 001 Device 001: ID 1d6b:0002
Bus 005 Device 002: ID 2c7c:0125
Bus 008 Device 001: ID 1d6b:0003
Bus 006 Device 001: ID 1d6b:0003
Bus 004 Device 001: ID 1d6b:0001
Bus 002 Device 001: ID 1d6b:0002
Bus 003 Device 002: ID 17ef:6019
Bus 007 Device 001: ID 1d6b:0002
console:/ #
console:/ # ls -l /dev/ttyUSB*                                                 
crw-rw---- 1 radio radio 188,   0 2022-02-25 01:17 /dev/ttyUSB0
crw-rw---- 1 radio radio 188,   1 2022-02-25 01:17 /dev/ttyUSB1
crw-rw---- 1 radio radio 188,   2 2022-02-25 01:30 /dev/ttyUSB2
crw-rw---- 1 radio radio 188,   3 2022-02-25 01:17 /dev/ttyUSB3
console:/ #
console:/ # ls -l /dev/cdc*
crw-rw---- 1 radio radio 180, 176 2022-02-25 01:17 /dev/cdc-wdm0
  1. 适配Android部分的时候主要是利用了rk已有的4g modem框架,打开BOARD_HAS_RK_4G_MODEM属性,并将librk-ril.so 替换为Quectel的ril库,这样会少走一些弯路。
  2. 我用的ril库版本为Quectel_Android_RIL_Driver_V3.3.78,这个版本才能适配Android12。之前用过3.3.57和3.3.62版本的库,加载时都会报错:
01-27 02:52:07.307 D/RIL RILC(16655): Quectel RIL Version: Quectel_Android_RIL_Driver_V3.3.57
01-27 02:52:07.307 D/RIL RILC(16655): libquectel-ril build info: On branch master Your branch is up to date with 'origin/master'. 34b334c769af06106a74c84868f5cacd8c1b7404 10/11/21_16:02:45 
01-27 02:52:07.307 D/RIL RILC(16655): Compiled date: Oct 11 2021 time: 16:02:49
01-27 02:52:07.307 E/RIL RILC(16655): '/vendor/manifest.xml' not exist.
01-27 02:52:07.308 D/RIL RILC(16655): 1.0
01-27 02:52:07.308 D/RIL RILC(16655): IRadioVersion 1.1
01-27 02:52:07.308 D/RIL RILC(16655): IRadioConfigVersion 1.0
--------- beginning of crash
01-27 02:52:07.310 F/libc    (16655): Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x7ffffffff0 in tid 16655 (rild), pid 16655 (rild)
01-27 02:52:07.331 I/crash_dump64(16659): obtaining output fd from tombstoned, type: kDebuggerdTombstoneProto
01-27 02:52:07.332 I/tombstoned(  213): received crash request for pid 16655
01-27 02:52:07.332 I/crash_dump64(16659): performing dump of process 16655 (target tid = 16655)
01-27 02:52:07.391 I/logd    (    0): logdr: UID=1001 GID=1001 PID=16659 n tail=0 logMask=8 pid=16655 start=0ns deadline=0ns
01-27 02:52:07.391 I/logd    (    0): logdr: UID=1001 GID=1001 PID=16659 n tail=0 logMask=1 pid=16655 start=0ns deadline=0ns
01-27 02:52:07.390 F/DEBUG   (16659): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
01-27 02:52:07.390 F/DEBUG   (16659): Build fingerprint: 'rockchip/rk3568_s/rk3568_s:12/SP1A.210812.016/eng.OEM.20220127.112536:userdebug/release-keys'
01-27 02:52:07.390 F/DEBUG   (16659): Revision: '0'
01-27 02:52:07.390 F/DEBUG   (16659): ABI: 'arm64'
01-27 02:52:07.390 F/DEBUG   (16659): Timestamp: 2022-01-27 02:52:07.334862586-0600
01-27 02:52:07.390 F/DEBUG   (16659): Process uptime: 0s
01-27 02:52:07.390 F/DEBUG   (16659): Cmdline: /vendor/bin/hw/rild
01-27 02:52:07.390 F/DEBUG   (16659): pid: 16655, tid: 16655, name: rild  >>> /vendor/bin/hw/rild <<<
01-27 02:52:07.390 F/DEBUG   (16659): uid: 1001
01-27 02:52:07.390 F/DEBUG   (16659): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x7ffffffff0
01-27 02:52:07.390 F/DEBUG   (16659):     x0  0000007ff3f015c8  x1  0000007ff3f01568  x2  000000000c0fea98  x3  0000008000000000
01-27 02:52:07.390 F/DEBUG   (16659):     x4  0000008000000060  x5  0000000000000000  x6  0003808080808080  x7  fefefefefeff3130
01-27 02:52:07.390 F/DEBUG   (16659):     x8  7f7f7f7f7f7f7f7f  x9  0000000000000001  x10 0101010101010101  x11 000000000000000e
01-27 02:52:07.390 F/DEBUG   (16659):     x12 0000000000000010  x13 0000000000000001  x14 0000000000000004  x15 ffffffffffffffff
01-27 02:52:07.391 F/DEBUG   (16659):     x16 000000756666da80  x17 00000077f6763960  x18 00000078016fa000  x19 0000007ff3f015c8
01-27 02:52:07.391 F/DEBUG   (16659):     x20 000000756666d000  x21 ffffff800c0fea98  x22 0000007566646000  x23 000000756666f000
01-27 02:52:07.391 F/DEBUG   (16659):     x24 0000007ff3f01568  x25 0000000000000003  x26 0000005c0f937368  x27 0000000000000000
01-27 02:52:07.391 F/DEBUG   (16659):     x28 0000007566646560  x29 0000007ff3f01a30
01-27 02:52:07.391 F/DEBUG   (16659):     lr  000000756661be54  sp  0000007ff3f01490  pc  00000077f6763980  pst 0000000080001000
01-27 02:52:07.391 F/DEBUG   (16659): backtrace:
01-27 02:52:07.391 F/DEBUG   (16659):       #00 pc 000000000004b980  /apex/com.android.runtime/lib64/bionic/libc.so (memmove+32) (BuildId: 28943f8bb3b7b23557619af9a38223c5)
01-27 02:52:07.391 F/DEBUG   (16659):       #01 pc 000000000001be50  /vendor/lib64/hw/libreference-ril.so (RIL_Init+824)
01-27 02:52:07.391 F/DEBUG   (16659):       #02 pc 0000000000002350  /vendor/bin/hw/rild (main+764) (BuildId: 02b0e8d29ba1c25f9d7974e526c2f2e6)
01-27 02:52:07.391 F/DEBUG   (16659):       #03 pc 00000000000485dc  /apex/com.android.runtime/lib64/bionic/libc.so (__libc_init+96) (BuildId: 28943f8bb3b7b23557619af9a38223c5)
  1. APN参数加在vendor/rockchip/common/phone/etc/apns-full-conf.xml中

心得小结

调试该4g模块的时候还是走了不少弯路的,此处做个小结:

  1. EM05模块是M.2接口封装,由于前一阶段刚调试了一款M.2接口的pcie ssd模块,出现了思维定势,以为该模块也是pcie协议的,于是花了很多时间在调试pcie2.0,但一直出现training失败的打印:
[    3.233708] rk-pcie 3c0000000.pcie: PCIe Linking... LTSSM is 0x0
[    4.247096] rk-pcie 3c0000000.pcie: PCIe Linking... LTSSM is 0x0
[    5.260318] rk-pcie 3c0000000.pcie: PCIe Linking... LTSSM is 0x0
[    6.273656] rk-pcie 3c0000000.pcie: PCIe Linking... LTSSM is 0x0
[    7.287090] rk-pcie 3c0000000.pcie: PCIe Linking... LTSSM is 0x0
[    8.300327] rk-pcie 3c0000000.pcie: PCIe Linking... LTSSM is 0x1
[    9.313723] rk-pcie 3c0000000.pcie: PCIe Linking... LTSSM is 0x0
[   10.327406] rk-pcie 3c0000000.pcie: PCIe Linking... LTSSM is 0x0
[   11.340393] rk-pcie 3c0000000.pcie: PCIe Link Fail
[   11.340434] rk-pcie 3c0000000.pcie: failed to initialize host

查了供电等也都是正常的。后来实在调试不出来,回头又细看了相关规格书和文档资料,发现其实该模组还是走usb协议的,M.2接口(设计上是 B-KEY SOCKET)支持PCIex2/SATA/USB2.0/USB3.1 Gen1/HSIC/SSIC/Audio/UIM/I2C/SMBus等协议2,因此只需按照porting文档适配usb驱动即可。
这里就是对模组特性和M.2接口了解不到位,导致误入歧途浪费了很多时间。

  1. 加载ril库报错(具体报错log可见上一部分第5点),这个可以基本定位到是ril库的问题。也试过从同事那边获取到了Android11上适配OK的库,但也是同样现象。如果能尽早联系上模组厂的技术支持,更新合适的库文件,这个问题会更快地解决。
  2. 虽然直接套用rk的4g modem框架比较方便,但也还是会有一些问题,比如编译时可能会出现兼容性报错:
checkvintf I 01-14 16:37:08  8278  8278 check_vintf.cpp:388] The following HALs in device manifest are not declared in FCM <= level 6: 
checkvintf I 01-14 16:37:08  8278  8278 check_vintf.cpp:391]   [email protected]::IOemHook/slot1
checkvintf E 01-14 16:37:08  8278  8278 check_vintf.cpp:620] files are incompatible: Runtime info and framework compatibility matrix are incompatible: No compatible kernel requirement found (kernel FCM version = 6).
checkvintf E 01-14 16:37:08  8278  8278 check_vintf.cpp:620] For kernel requirements at matrix level 6, For config CONFIG_DEVMEM, value = y but required n
checkvintf E 01-14 16:37:08  8278  8278 check_vintf.cpp:620] 
checkvintf E 01-14 16:37:08  8278  8278 check_vintf.cpp:620] Cannot open out/target/product/rk3568_s/product/etc/vintf/: No such file or directory
checkvintf E 01-14 16:37:08  8278  8278 check_vintf.cpp:620] [email protected]::IRadioConfig/default is deprecated; requires at least 1.1
checkvintf E 01-14 16:37:08  8278  8278 check_vintf.cpp:620] [email protected]::IRadioConfig/default is deprecated; requires at least 1.1
checkvintf E 01-14 16:37:08  8278  8278 check_vintf.cpp:620] The following instances are in the device manifest but not specified in framework compatibility matrix: 
checkvintf E 01-14 16:37:08  8278  8278 check_vintf.cpp:620]     [email protected]::IOemHook/slot1
checkvintf E 01-14 16:37:08  8278  8278 check_vintf.cpp:620] Suggested fix:
checkvintf E 01-14 16:37:08  8278  8278 check_vintf.cpp:620] 1. Update deprecated HALs to the latest version.
checkvintf E 01-14 16:37:08  8278  8278 check_vintf.cpp:620] 2. Check for any typos in device manifest or framework compatibility matrices with FCM version >= 6.
checkvintf E 01-14 16:37:08  8278  8278 check_vintf.cpp:620] 3. For new platform HALs, add them to any framework compatibility matrix with FCM version >= 6 where applicable.
checkvintf E 01-14 16:37:08  8278  8278 check_vintf.cpp:620] 4. For device-specific HALs, add to DEVICE_FRAMEWORK_COMPATIBILITY_MATRIX_FILE or DEVICE_PRODUCT_COMPATIBILITY_MATRIX_FILE.: Success
INCOMPATIBLE
16:37:09 ninja failed with: exit status 1

根据Suggested fix,我一般有两种处理方法,一是去hardware/interfaces/compatibility_matrices/中修改对应的compatibility_matrix文件,二是在device/rockchip/common/中修改manifest.xml,主要就是针对出现冲突的属性进行删改。

  1. 还有一种问题是开机进系统后可能出现init的报错:
[   58.888469] init: Control message: Could not find '[email protected]::IRadio/slot1' for ctl.interface_start from pid: 151 (/system/bin/hwservicemanager)
[   59.889699] init: Control message: Could not find '[email protected]::IRadio/slot1' for ctl.interface_start from pid: 151 (/system/bin/hwservicemanager)
[   60.890739] init: Control message: Could not find '[email protected]::IRadio/slot1' for ctl.interface_start from pid: 151 (/system/bin/hwservicemanager)

我是在device/rockchip/common/中进行修改的,根据参考资料1,还可以在系统级修改init和ServiceManager来解决。

diff --git a/4g_modem/manifest.xml b/4g_modem/manifest.xml
index 9a19b3c..a76b41a 100644
--- a/4g_modem/manifest.xml
+++ b/4g_modem/manifest.xml
@@ -5,8 +5,9 @@
         @1.1::IRadio/slot1
         @1.1::IRadio/slot2
         @1.2::ISap/slot1
+        
     
  1. 我觉得这两个结构框图(来自模组porting文档)可以好好看看,可能会便于理解当前的操作或者遇到的问题处于哪个层级
    RK3568 Android12 移远4G模块EM05-CE 调试心得_第1张图片
    RK3568 Android12 移远4G模块EM05-CE 调试心得_第2张图片

如有谬误欢迎指正,感谢阅读~

参考资料


  1. RK3568-ANDROID11-4G-EC20-(详细步骤) ↩︎ ↩︎

  2. m.2接口 ↩︎

你可能感兴趣的:(RockChip,#,kernel,#,Android,android,lte,kernel)