适配前理清楚一下调试的流程:
1.该模块为LGA封装,需要控制上电时序模块才能正常上电工作:
2.模块供电正常后,读取模组的PID 和VID 并将其ID添加到内核里面,确保USB转Serial端口能够正常生成:
3.生成ttyUSB0~ttyUSB2端口后,确保rild进程正常启动,能够正常加载ril库;
4.查看一下AT命令集,善于捕捉ril log,熟练使用 logcat -b radio,移远方案,可以通过创建文件
/data/quectel_debug_log 来存储RIL 加载信息,同时瑞芯微对应4G模块这方面的资料也是比较完善的,可以阅读一下
RKDocs/common/mobile-net/Rockchip_Introduction_4G_Module_Configuration_CN\&EN.pdf。流程理清楚了,我们就可以在我们的硬件平台上来移植4G模组了。
//偷个懒,将EC200A的module PWR RK0_PB4和reset脚RK0_PB1 控制添加到LED灯的控制驱动里面,
//将 module PWR RK0_PB4 置高,将reset脚RK0_PB1置低
#include "rk3566-box.dtsi"
/ {
model = "Rockchip RK3566 BOX DM35 Project";
compatible = "rockchip,rk3568-box-demo-v10", "rockchip,rk3566";
gpio-leds {
compatible = "gpio-leds";
// ir-led {
// gpios = <&gpio4 RK_PC5 GPIO_ACTIVE_HIGH>;
// default-state = "off";
// };
//MODULE_PWR GPIO0_B4
+ modem-resetled {
+ gpios = <&gpio0 RK_PB1 GPIO_ACTIVE_LOW>;
+ default-state = "on";
+ };
+ modem-led {
+ gpios = <&gpio0 RK_PB4 GPIO_ACTIVE_HIGH>;
+ default-state = "on";
+ };
work-led { /*led GPIO0_C3_d*/
gpios = <&gpio0 RK_PC3 GPIO_ACTIVE_HIGH>;
//linux,default-trigger = "timer";
default-state = "on";
};
};
-------------------------------------------------------------
wireless_bluetooth: wireless-bluetooth {
compatible = "bluetooth-platdata";
clocks = <&pmucru CLK_RTC_32K>;
clock-names = "ext_clock";
//wifi-bt-power-toggle;
uart_rts_gpios = <&gpio2 RK_PB5 GPIO_ACTIVE_LOW>;
pinctrl-names = "default", "rts_gpio";
pinctrl-0 = <&uart1m0_rtsn>;
pinctrl-1 = <&uart1_gpios>;
BT,reset_gpio = <&gpio2 RK_PB7 GPIO_ACTIVE_HIGH>;
BT,wake_gpio = <&gpio2 RK_PC1 GPIO_ACTIVE_HIGH>;
BT,wake_host_irq = <&gpio2 RK_PC0 GPIO_ACTIVE_HIGH>;
status = "okay";
};
+//添加4G模块的上电初始化时序,以确保模块能够正常上电工作
+rk_modem: rk-modem {
+ compatible="4g-modem-platdata";
+ pinctrl-names = "default";
+ pinctrl-0 = <<e_vbat <e_power_en /*<e_reset*/>;
+ 4G,vbat-gpio = <&gpio0 RK_PB3 GPIO_ACTIVE_HIGH>; //VBUS_CTRL
+ 4G,power-gpio = <&gpio0 RK_PB2 GPIO_ACTIVE_LOW>; //MODULE_PWRKEY
+ //4G,reset-gpio = <&gpio0 RK_PB1 GPIO_ACTIVE_LOW>; //MODULE_RESET_N
+ //MODULE_PWR GPIO0_B4
+ status = "okay";
+};
wireless-wlan {
wifi_host_wake_irq: wifi-host-wake-irq {
rockchip,pins = <2 RK_PB2 RK_FUNC_GPIO &pcfg_pull_down>;
};
};
wireless-bluetooth {
uart1_gpios: uart1-gpios {
rockchip,pins = <2 RK_PB5 RK_FUNC_GPIO &pcfg_pull_none>;
};
};
+ rk-modem {
+ lte_vbat: lte-vbat {
+ rockchip,pins = <0 RK_PB3 RK_FUNC_GPIO &pcfg_pull_none>;
+ };
+ lte_power_en: lte-power-en {
+ rockchip,pins = <0 RK_PB2 RK_FUNC_GPIO &pcfg_pull_none>;
+ };
+// lte_reset: lte-reset {
+// rockchip,pins = <0 RK_PB1 RK_FUNC_GPIO &pcfg_pull_none>;
+// };
};
修改完这些之后,使用lsusb命令查看模块的PID和VID
Bus 005 Device 001: ID 1d6b:0002
Bus 003 Device 001: ID 1d6b:0001
Bus 001 Device 001: ID 1d6b:0002
Bus 008 Device 001: ID 1d6b:0003
Bus 006 Device 001: ID 1d6b:0003
Bus 001 Device 004: ID 2c7c:6005
Bus 004 Device 001: ID 1d6b:0001
Bus 002 Device 001: ID 1d6b:0002
Bus 007 Device 001: ID 1d6b:0002
上面显示的2c7c:6005就是我们4G模块的VID和PID,这说明我们的上电时序已经修改成了,接下来修改内核,添加模块的VID和PID
git diff arch/arm64/configs/rockchip_defconfig
diff --git a/kernel/arch/arm64/configs/rockchip_defconfig b/kernel/arch/arm64/configs/rockchip_defconfig
index 3c1008aab5..66a6cc02a9 100644
--- a/kernel/arch/arm64/configs/rockchip_defconfig
+++ b/kernel/arch/arm64/configs/rockchip_defconfig
@@ -776,6 +776,7 @@ CONFIG_USB_UAS=y
CONFIG_USB_DWC3=y
CONFIG_USB_DWC2=y
CONFIG_USB_SERIAL=y
+CONFIG_USB_SERIAL_WWAN=y
CONFIG_USB_SERIAL_GENERIC=y
CONFIG_USB_SERIAL_OPTION=y
CONFIG_USB_SERIAL_CH341=y
kernel$ git diff drivers/usb/serial/option.c
diff --git a/kernel/drivers/usb/serial/option.c b/kernel/drivers/usb/serial/option.c
index ff67562572..497ca259de 100644
--- a/kernel/drivers/usb/serial/option.c
+++ b/kernel/drivers/usb/serial/option.c
@@ -2126,6 +2126,23 @@ static const struct usb_device_id option_ids[] = {
{ USB_DEVICE_INTERFACE_CLASS(0x305a, 0x1404, 0xff) }, /* GosunCn GM500 RNDIS */
{ USB_DEVICE_INTERFACE_CLASS(0x305a, 0x1405, 0xff) }, /* GosunCn GM500 MBIM */
{ USB_DEVICE_INTERFACE_CLASS(0x305a, 0x1406, 0xff) }, /* GosunCn GM500 ECM/NCM */
+#if 1 //Added by Quectel
+#if 1 //Added by Quectel
diff --git a/kernel/drivers/usb/serial/option.c b/kernel/drivers/usb/serial/option.c
index ff67562572..497ca259de 100644
--- a/kernel/drivers/usb/serial/option.c
+++ b/kernel/drivers/usb/serial/option.c
@@ -2126,6 +2126,23 @@ static const struct usb_device_id option_ids[] = {
{ USB_DEVICE_INTERFACE_CLASS(0x305a, 0x1404, 0xff) }, /* GosunCn GM500 RNDIS */
{ USB_DEVICE_INTERFACE_CLASS(0x305a, 0x1405, 0xff) }, /* GosunCn GM500 MBIM */
{ USB_DEVICE_INTERFACE_CLASS(0x305a, 0x1406, 0xff) }, /* GosunCn GM500 ECM/NCM */
+#if 1 //Added by Quectel
+ { USB_DEVICE(0x05C6, 0x9090) }, /* Quectel UC15 */
+ { USB_DEVICE(0x05C6, 0x9003) }, /* Quectel UC20 */
+ { USB_DEVICE(0x2C7C, 0x0125) }, /* Quectel EC25 */
+ { USB_DEVICE(0x2C7C, 0x0121) }, /* Quectel EC21 */
+ { USB_DEVICE(0x05C6, 0x9215) }, /* Quectel EC20 */
+ { USB_DEVICE(0x2C7C, 0x0191) }, /* Quectel EG91 */
+ { USB_DEVICE(0x2C7C, 0x0195) }, /* Quectel EG95 */
+ { USB_DEVICE(0x2C7C, 0x0306) }, /* Quectel EG06/EP06/EM06 */
+ { USB_DEVICE(0x2C7C, 0x0296) }, /* Quectel BG96 */
+ { USB_DEVICE(0x2C7C, 0x0435) }, /* Quectel AG35 */
+ { USB_DEVICE(0x2C7C, 0x0512) }, /* Quectel EG12/EG18 */
+ { USB_DEVICE(0x2C7C, 0x6026) }, /* Quectel EC200 */
+ { USB_DEVICE(0x2C7C, 0x6120) }, /* Quectel UC200 */
+ { USB_DEVICE(0x2C7C, 0x6000) }, /* Quectel EC200/UC200 */
+ { USB_DEVICE(0x2C7C, 0x6005) }, /* Quectel EC200A-CN*/
+#endif
{ } /* Terminating entry */
};
MODULE_DEVICE_TABLE(usb, option_ids);
@@ -2183,7 +2200,21 @@ static int option_probe(struct usb_serial *serial,
struct usb_interface_descriptor *iface_desc =
&serial->interface->cur_altsetting->desc;
unsigned long device_flags = id->driver_info;
-
+#if 1 //Added by Quectel
+ if(serial->dev->descriptor.idVendor == cpu_to_le16(0x2C7C)) {
+ __u16 idProduct = le16_to_cpu(serial->dev->descriptor.idProduct);
+ struct usb_interface_descriptor *intf = &serial->interface->cur_altsetting->desc;
+ if (intf->bInterfaceClass != 0xFF || intf->bInterfaceSubClass == 0x42) {
+ //ECM, RNDIS, NCM, MBIM, ACM, UAC, ADB
+ return -ENODEV;
+ }
+ if ((idProduct&0xF000) == 0x0000) {
+ //MDM interface 4 is QMI
+ if (intf->bInterfaceNumber == 4 && intf->bNumEndpoints == 3 && intf->bInterfaceSubClass == 0xFF &&intf->bInterfaceProtocol == 0xFF)
+ return -ENODEV;
+ }
+ }
+#endif
/* Never bind to the CD-Rom emulation interface */
if (iface_desc->bInterfaceClass == USB_CLASS_MASS_STORAGE)
return -ENODEV;
(END)
kernel$ git diff drivers/usb/serial/usb_wwan.c
diff --git a/kernel/drivers/usb/serial/usb_wwan.c b/kernel/drivers/usb/serial/usb_wwan.c
index c604ff4546..19fe9838de 100644
--- a/kernel/drivers/usb/serial/usb_wwan.c
+++ b/kernel/drivers/usb/serial/usb_wwan.c
@@ -509,11 +509,14 @@ static struct urb *usb_wwan_setup_urb(struct usb_serial_port *port,
if (intfdata->use_zlp && dir == USB_DIR_OUT)
urb->transfer_flags |= URB_ZERO_PACKET;
+ #if 1 //Added by Quectel for zero packet
if (dir == USB_DIR_OUT) {
- if ((desc->idVendor == cpu_to_le16(0x1286) &&
- desc->idProduct == cpu_to_le16(0x4e3c)))
- urb->transfer_flags |= URB_ZERO_PACKET;
+ struct usb_device_descriptor *desc = &serial->dev->descriptor;
+
+ if (desc->idVendor == cpu_to_le16(0x2C7C))
+ urb->transfer_flags |= URB_ZERO_PACKET;
}
+#endif
return urb;
}
修改以上内核配置后,打开内核log,
[ 10.646867] usb 1-1: new high-speed USB device number 4 using ehci-platform
[ 10.794964] usb 1-1: New USB device found, idVendor=2c7c, idProduct=6005, bcdDevice= 3.18
[ 10.794999] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 10.795007] usb 1-1: Product: Android
[ 10.795013] usb 1-1: Manufacturer: Android
[ 10.795019] usb 1-1: SerialNumber: 0000
[ 10.797366] cdc_ether 1-1:1.0 usb0: register 'cdc_ether' at usb-fd800000.usb-1, CDC Ethernet Device, 02:0c:29:a3:9b:6d
[ 10.798340] option 1-1:1.2: GSM modem (1-port) converter detected
[ 10.798917] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB0
[ 10.799720] option 1-1:1.3: GSM modem (1-port) converter detected
[ 10.800241] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB1
[ 10.800938] option 1-1:1.4: GSM modem (1-port) converter detected
[ 10.801414] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB2
这段log说明我们内核部分已经修改OK了。
-------------------------------------------------------
接下来一直和修改RIL部分:
git diff device/rockchip/common/device.mk
diff --git a/device/rockchip/common/device.mk b/device/rockchip/common/device.mk
index c79fd21d6b..c1741daefe 100644
--- a/device/rockchip/common/device.mk
+++ b/device/rockchip/common/device.mk
@@ -273,17 +273,17 @@ PRODUCT_PROPERTY_OVERRIDES += \
ro.telephony.default_network=9
ifeq ($(strip $(TARGET_ARCH)), arm64)
-PRODUCT_PROPERTY_OVERRIDES += \
+#PRODUCT_PROPERTY_OVERRIDES += \
vendor.rild.libpath=/vendor/lib64/librk-ril.so
PRODUCT_COPY_FILES += \
- $(LOCAL_PATH)/4g_modem/bin64/dhcpcd:$(TARGET_COPY_OUT_VENDOR)/bin/dhcpcd \
- $(LOCAL_PATH)/4g_modem/lib64/librk-ril.so:$(TARGET_COPY_OUT_VENDOR)/lib64/librk-ril.so
+ $(LOCAL_PATH)/4g_modem/bin64/dhcpcd:$(TARGET_COPY_OUT_VENDOR)/bin/dhcpcd
+# $(LOCAL_PATH)/4g_modem/lib64/librk-ril.so:$(TARGET_COPY_OUT_VENDOR)/lib64/librk-ril.so
else
-PRODUCT_PROPERTY_OVERRIDES += \
+#PRODUCT_PROPERTY_OVERRIDES += \
vendor.rild.libpath=/vendor/lib/librk-ril.so
-PRODUCT_COPY_FILES += \
+#PRODUCT_COPY_FILES += \
$(LOCAL_PATH)/4g_modem/bin32/dhcpcd:$(TARGET_COPY_OUT_VENDOR)/bin/dhcpcd \
$(LOCAL_PATH)/4g_modem/lib32/librk-ril.so:$(TARGET_COPY_OUT_VENDOR)/lib/librk-ril.so
amediatech@amediatech-Super-Server:~/DISK1/qhq/rk/RK_Android_11.0_sdk$ git diff device/rockchip/rk356x_box/rk356x_box/rk356x_box.mk
diff --git a/device/rockchip/rk356x_box/rk356x_box/rk356x_box.mk b/device/rockchip/rk356x_box/rk356x_box/rk356x_box.mk
index 0866c945a4..74dd85ed4c 100755
--- a/device/rockchip/rk356x_box/rk356x_box/rk356x_box.mk
+++ b/device/rockchip/rk356x_box/rk356x_box/rk356x_box.mk
@@ -110,6 +110,7 @@ PRODUCT_COPY_FILES += \
BOARD_HS_ETHERNET := true
+BOARD_HAS_RK_4G_MODEM := true
#
#add Rockchip properties here
#
git diff device/rockchip/rk356x_box/rk356x_box/system.prop
diff --git a/device/rockchip/rk356x_box/rk356x_box/system.prop b/device/rockchip/rk356x_box/rk356x_box/system.prop
index 5b2b456f50..c3602fef4f 100644
--- a/device/rockchip/rk356x_box/rk356x_box/system.prop
+++ b/device/rockchip/rk356x_box/rk356x_box/system.prop
@@ -2,13 +2,13 @@
# system.prop
#
-#rild.libpath=/system/lib/libreference-ril.so
-#rild.libargs=-d /dev/ttyUSB2
+rild.libpath=/system/lib64/libreference-ril.so
+rild.libargs=-d /dev/ttyUSB2
# Default ecclist
ro.ril.ecclist=112,911
wifi.interface=wlan0
-rild.libpath=/system/lib/libril-rk29-dataonly.so
-rild.libargs=-d /dev/ttyACM0
+#rild.libpath=/system/lib/libril-rk29-dataonly.so
+#rild.libargs=-d /dev/ttyACM0
persist.tegra.nvmmlite = 1
persist.sys.boot.check=false
ro.audio.monitorOrientation=true
git diff hardware/ril/rild/rild.rc
diff --git a/hardware/ril/rild/rild.rc b/hardware/ril/rild/rild.rc
index f6beb5468f..6f48e28323 100644
--- a/hardware/ril/rild/rild.rc
+++ b/hardware/ril/rild/rild.rc
@@ -1,5 +1,6 @@
-service vendor.ril-daemon /vendor/bin/hw/rild
+#service vendor.ril-daemon /vendor/bin/hw/rild
+service ril-daemon /vendor/bin/hw/rild -l /vendor/lib64/libreference-ril.so
class main
- user radio
+ user root
group radio cache inet misc audio log readproc wakelock
capabilities BLOCK_SUSPEND NET_ADMIN NET_RAW
git diff device/rockchip/rk356x_box/rk356x_box/overlay/frameworks/base/core/res/res/values/config.xml
diff --git a/device/rockchip/rk356x_box/rk356x_box/overlay/frameworks/base/core/res/res/values/config.xml b/device/rockchip/rk356x_box/rk356x_box/overlay/frameworks/base/core/res/res/values/config.xml
index 6021354c69..4150b15aca 100755
--- a/device/rockchip/rk356x_box/rk356x_box/overlay/frameworks/base/core/res/res/values/config.xml
+++ b/device/rockchip/rk356x_box/rk356x_box/overlay/frameworks/base/core/res/res/values/config.xml
@@ -35,6 +35,14 @@
- "wifi,1,1,1,-1,true"
+ - "mobile,0,0,0,-1,true"
+ - "mobile_mms,2,0,2,60000,true"
+ - "mobile_supl,3,0,2,60000,true"
+ - "mobile_dun,4,0,2,60000,true"
+ - "mobile_hipri,5,0,3,60000,true"
+ - "mobile_fota,10,0,2,60000,true"
+ - "mobile_ims,11,0,2,60000,true"
+ - "mobile_cbs,12,0,2,60000,true"
- "ethernet,9,9,9,-1,true"
@@ -49,7 +57,7 @@
true
-
+ true