[调试记录]3288 7.1平台上移植美格 SLM790 4G模块

[调试记录]3288 7.1平台上移植美格 SLM790 4G模块

一 驱动配置

1.1 PPP 配置
需要配置 Android 内核来支持 PPP 功能,按照以下步骤来配置 PPP 选项

Device Drivers --->
[*] Network device support --->
<*> PPP (point-to-point protocol) support
[ * ] PPP filtering
[ * ] PPP multilink support
<*> PPP support for async serial ports
<*> PPP support for sync tty ports
<*> PPP Deflate compression

1.2 usb-modem 配置
需要配置 Android 内核来支持 USB-modem 功能,按照以下步骤来配置 USB-moderm 选项:

Device Drivers  --->
	[*] USB support  --->
	        <*> USB Serial Converter support
		          [*] USB Generic Serail Driver
		          [*] USB Driver for GSM and CMDA modems

1.3 修改 drivers/usb/serial/option.c 文件加入 MeiG 模块的设备 ID。
可以通过adb logcat -b radio命令将其 VendorID 和 ProductID 打印出来看一下:idVendor=2dee, idProduct=4d20

<6>[  257.331378] option 2-1.7:1.4: device disconnected
<6>[  291.814705] usb 2-1.7: new high-speed USB device number 5 using ehci-platform
<6>[  291.914363] usb 2-1.7: New USB device found, idVendor=2dee, idProduct=4d20
<6>[  291.914629] usb 2-1.7: New USB device strings: Mfr=1, Product=2, SerialNumber=3
<6>[  291.914747] usb 2-1.7: Product: Android
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
old mode 100644
new mode 100755
index d982c45..1cdf1b9
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -51,6 +51,12 @@ static void option_release(struct usb_serial *serial);
 static void option_instat_callback(struct urb *urb);
 //Step 1  增加 PID VID
 /* Vendor and product IDs */
+//added by dongshiyi 20200304 for meige_SLM790 start <<<
+#define MEIG_VENDOR_ID 0x2DEE
+#define MEIG_PRODUCT_SLM790 0X4D20
+//added by dongshiyi 20200304 for meige_SLM790 end >>>


 #define OPTION_VENDOR_ID                       0x0AF0
 #define OPTION_PRODUCT_COLT                    0x5000
 #define OPTION_PRODUCT_RICOLA                  0x6000
@@ -564,6 +570,11 @@ static void option_instat_callback(struct urb *urb);
 
 
 static const struct usb_device_id option_ids[] = {
 //Step 1  增加 PID VID
+  //added  by dongshiyi 20200304 for  meige_SLM790 start <<<
+  { USB_DEVICE(MEIG_VENDOR_ID, MEIG_PRODUCT_SLM790) },
+//added by dongshiyi 20200304 for meige_SLM790 end <<<

        { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) },
        { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) },
        { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_LIGHT) },

@@ -2000,18 +2012,30 @@ static int option_probe(struct usb_serial *serial,
         */
        if (device_flags & RSVD(iface_desc->bInterfaceNumber))
                return -ENODEV;
        /*
         * Don't bind network interface on Samsung GT-B3730, it is handled by
         * a separate module.
         */
      //step2:   屏蔽 ADB NDIS,端口预留增加 ADB ,NDIS 驱动:
+//added  by dongshiyi 20200304 for meige_SLM790 start
+ if (dev_desc->idVendor == cpu_to_le16(MEIG_VENDOR_ID) &&
+       dev_desc->idProduct == cpu_to_le16(MEIG_PRODUCT_SLM790) && 
+      iface_desc->bInterfaceNumber == 0x0){
+    return -ENODEV;
+ }
+ //added  by dongshiyi 20200304 for meige_SLM790 end  

       if (dev_desc->idVendor == cpu_to_le16(SAMSUNG_VENDOR_ID) &&
            dev_desc->idProduct == cpu_to_le16(SAMSUNG_PRODUCT_GT_B3730) &&
            iface_desc->bInterfaceClass != USB_CLASS_CDC_DATA)
                return -ENODEV;

        /* Store the device flags so we can use them during attach. */
        usb_set_serial_data(serial, (void *)device_flags);
-
        return 0;
 }


一般来说只要 VendorID 和 ProductID 是正确的,就能把串口虚拟节点dev/ttyUSB0~tty/ttyUSB3生成出来,但是这步遇到了生成的串口虚拟节点
只有dev/ttyUSB1~tty/ttyUSB4.
遇到报错log如下:

01-18 17:57:39.887   212   230 I RIL     : /dev/ttyUSB0 cannot open, will retry 2s....
01-18 17:57:41.887   212   230 I RIL     : open ttyUSB success
01-18 17:57:41.888   212   230 I RIL     : fd is:-1
01-18 17:57:41.888   212   230 I RIL     : /dev/ttyUSB0 cannot open, will retry 2s....
01-18 17:57:43.889   212   230 I RIL     : open ttyUSB success
01-18 17:57:43.890   212   230 I RIL     : fd is:-1
01-18 17:57:43.890   212   230 I RIL     : /dev/ttyUSB0 cannot open, will retry 2s....
01-18 17:57:45.891   212   230 I RIL     : open ttyUSB success
01-18 17:57:45.892   212   230 I RIL     : fd is:-1
01-18 17:57:45.892   212   230 I RIL     : /dev/ttyUSB0 cannot open, will retry 2s....
01-18 17:57:47.893   212   230 I RIL     : open ttyUSB success
01-18 17:57:47.894   212   230 I RIL     : fd is:-1
01-18 17:57:47.894   212   230 I RIL     : /dev/ttyUSB0 cannot open, will retry 2s....
01-18 17:57:49.895   212   230 I RIL     : open ttyUSB success

解决方式://需要把iface_desc->bInterfaceNumber == 0这个判断条件中的0 改成0x0,这是由于usb_interface_descriptor设备描述符结构体里的bInterfaceNumber这个成员的类型是__u8(unsigned char),而0这个值类型不确定导致类型不匹配。

struct usb_interface_descriptor *iface_desc =
				&serial->interface->cur_altsetting->desc;
 
 iface_desc->bInterfaceNumber == 0
/* USB_DT_INTERFACE: Interface descriptor */
struct usb_interface_descriptor {
	__u8  bLength;
	__u8  bDescriptorType;

	__u8  bInterfaceNumber;//类型为__u8 unsigned char
	__u8  bAlternateSetting;
	__u8  bNumEndpoints;
	__u8  bInterfaceClass;
	__u8  bInterfaceSubClass;
	__u8  bInterfaceProtocol;
	__u8  iInterface;
} __attribute__ ((packed));
//屏蔽NCM口
+ if (dev_desc->idVendor == cpu_to_le16(MEIG_VENDOR_ID) &&
+ dev_desc->idProduct == cpu_to_le16(MEIG_PRODUCT_SLM790) &&
+ iface_desc->bInterfaceNumber == 0x0) { //需要把0 改成0x0
+ return -ENODEV;
+ }

1.4 由于选择的4G模块选择的是ncm 拨号适配 需要集成fae提供的ncm 驱动进内核
将驱动文件 meig_cdc_driver.c 拷贝到驱动目录 drivers/net/usb/下,并按如下方
法修改 Kconfig 和 Makefile,修改完成后编译并更新内核

diff --git a/drivers/net/usb/Kconfig b/drivers/net/usb/Kconfig
old mode 100644
new mode 100755
index 3a72862..b8523d0
--- a/drivers/net/usb/Kconfig
+++ b/drivers/net/usb/Kconfig
@@ -607,4 +607,11 @@ config USB_NET_CH9200
          To compile this driver as a module, choose M here: the
          module will be called ch9200.
 
+
+config LT_MEIG
+       tristate "MEIG driver for SLM790"
+       default n
+       help 
+       this is MEIG driver for 4G module
+
 endif # USB_NET_DRIVERS
diff --git a/drivers/net/usb/Makefile b/drivers/net/usb/Makefile
old mode 100644
new mode 100755
index 37fb46a..4a5d268
--- a/drivers/net/usb/Makefile
+++ b/drivers/net/usb/Makefile
@@ -39,3 +39,6 @@ obj-$(CONFIG_USB_VL600)               += lg-vl600.o
 obj-$(CONFIG_USB_NET_QMI_WWAN) += qmi_wwan.o
 obj-$(CONFIG_USB_NET_CDC_MBIM) += cdc_mbim.o
 obj-$(CONFIG_USB_NET_CH9200)   += ch9200.o
+  # added  by dongshiyi 20200304 for meige_SLM790 start
+obj-y              += hw_cdc_driver.o
+  # added  by dongshiyi 20200304 for meige_SLM790 end
\ No newline at end of file

如果 config 文件有正确配置, 则编译完内核会生成文件
drivers/net/usb/meig_cdc_driver.o。 如果没有此.o 文件要继续排查编译选项没
有添加成功的原因。

二 Android Ril 适配
2.1 RIL库由厂家提供,将该拨号库拷贝到/system/lib/目录下,若厂家提供了ril源码,可将其拷贝到hardware/ril/reference-ril下。

如果提供libreference-ril.so 库需要删除系统自带的:hardware\ril\reference-ril,拷贝fae给的文件: libreference-ril.so 到
device\rockchip\rk3288 目录下。并修改当前目录的 rk3288.mk 文件

diff --git a/rk3288.mk b/rk3288.mk
old mode 100644
new mode 100755
index da27247..7f57e78
--- a/rk3288.mk
+++ b/rk3288.mk
@@ -29,6 +29,9 @@ PRODUCT_MANUFACTURER := rockchip
 # Get the long list of APNs
 PRODUCT_COPY_FILES += vendor/rockchip/common/phone/etc/apns-full-conf.xml:system/etc/apn
 PRODUCT_COPY_FILES += vendor/rockchip/common/phone/etc/spn-conf.xml:system/etc/spn-conf.

+  # added  by dongshiyi 20200304 for meige_SLM790 start
+ PRODUCT_COPY_FILES += device/rockchip/rk3288/libreference-ril.so:system/lib/libreferenc
+  # added  by dongshiyi 20200304 for meige_SLM790 end

 PRODUCT_PROPERTY_OVERRIDES += \
     ro.product.version = 1.0.0 \
     ro.product.ota.host = www.rockchip.com:2300 \

如果提供库源码文件只需把提供的reference-ril目录拷贝到源码hardware\ril\reference-ril

4.2 修改 rild.c
将位于/hardware/ril/rild/rild.c 中的 Int main 函数中的 switchUser()注释掉。

diff --git a/rild/rild.c b/rild/rild.c
old mode 100644
new mode 100755
index ce1adba..1c45681
--- a/rild/rild.c
+++ b/rild/rild.c
@@ -317,8 +317,9 @@ int main(int argc, char **argv) {
     }
 OpenLib:
 #endif
-    switchUser();
-
+ //added by dongshiyi 20200304 for meige_SLM790 start<<< 
+  //  switchUser();
+ //added by dongshiyi 20200304 for meige_SLM790 end<<< 
     dlHandle = dlopen(rilLibPath, RTLD_NOW);
 
     if (dlHandle == NULL) {

4.3 修改 android 启动脚本 init.rc 增加对 ril-daemon 服务定义,同时定义采用的
拨号方式默认为 ncm 拨号。

修改system/core/rootdir/init.rc文件

diff --git a/rootdir/init.rc b/rootdir/init.rc
old mode 100644
new mode 100755
index deef67a..196c017
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -680,3 +680,16 @@ on property:ro.debuggable=1
 service flash_recovery /system/bin/install-recovery.sh
     class main
     oneshot

+#  added  by dongshiyi 20200304 for meige_SLM790 start
+service ril-daemon /system/bin/rild -l /system/lib/libreference-ril.so  
+    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
+    setprop ro.dial.mode ncm

+#  added by dongshiyi 20200304 for meige_SLM790 end

4.4 RK3288的Android 7.1 SDK提供了ril相关配置,各个厂家的不同,还需要更改其适配自己的4G模块 ,例如厂家提供了rild库是libreference-ril.so,4G模块生成了/dev/ttyUSB0~3共4个串口,AT指令端口为/dev/ttyUSB0;而RK3288默认的配置为:

rild.libpath=/system/lib/libril-rk29-dataonly.so
rild.libargs=-d /dev/ttyACM0

因此将其修改为:

rild.libpath=/system/lib/libreference-ril.so
rild.libargs=-d /dev/ttyUSB0

修改文件:/device/rockchip/rk3288/system.prop

diff --git a/system.prop b/system.prop
index 98101f4..9f5570e 100755
--- a/system.prop
+++ b/system.prop
@@ -8,8 +8,12 @@
 ro.ril.ecclist=112,911
 ro.opengles.version=196610
 wifi.interface=wlan0
-rild.libpath=/system/lib/libril-rk29-dataonly.so
-rild.libargs=-d /dev/ttyACM0
+
+#  added  by dongshiyi 20200304 for meige_SLM790 start
+rild.libpath=/system/lib/libreference-ril.so
+rild.libargs=-d /dev/ttyUSB0
+#  added  by dongshiyi 20200304 for meige_SLM790 end

修改文件:/device/rockchip/common/system.prop

diff --git a/system.prop b/system.prop
old mode 100644
new mode 100755
index 3f4e435..3fbfd59
--- a/system.prop
+++ b/system.prop
@@ -8,8 +8,10 @@
 ro.ril.ecclist=112,911
 ro.opengles.version = 131072
 wifi.interface=wlan0
-rild.libpath=/system/lib/libril-rk29-dataonly.so
-rild.libargs=-d /dev/ttyACM0
+#  added  by dongshiyi 20200304 for meige_SLM790 start
+rild.libpath=/system/lib/libreference-ril.so
+rild.libargs=-d /dev/ttyUSB0
+#  added  by dongshiyi 20200304 for meige_SLM790 end
 persist.tegra.nvmmlite = 1
 ro.audio.monitorOrientation=true

修改文件:/device/rockchip/common/device.mk

diff --git a/device.mk b/device.mk
index 37e73d5..dc19c50 100755
--- a/device.mk
+++ b/device.mk
@@ -700,7 +700,10 @@ PRODUCT_PROPERTY_OVERRIDES += \
     rild.libpath=/system/lib64/libril-rk29-dataonly.so
 else
 PRODUCT_PROPERTY_OVERRIDES += \
-    rild.libpath=/system/lib/libril-rk29-dataonly.so
+    # added  by dongshiyi 20200304 for meige_SLM790 start
+   # rild.libpath=/system/lib/libril-rk29-dataonly.so
+   rild.libpath=/system/lib/libreference-ril.so
+   #  added  by dongshiyi 20200304 for meige_SLM790 end
 endif
 endif

4.5 使能4G功能

文件配置修改:device/rockchip/common/BoardConfig.mk

diff --git a/BoardConfig.mk b/BoardConfig.mk
index 986a1e4..11f8464 100755
--- a/BoardConfig.mk
+++ b/BoardConfig.mk
@@ -294,7 +294,10 @@ BOARD_FORCE_UDISK_VISIBLE ?= true
 BOARD_DISABLE_SAFE_MODE ?= true
 
 #enable 3g dongle
-BOARD_HAVE_DONGLE ?= false
+# added  by dongshiyi 20200304 for meige_SLM790 start
+#BOARD_HAVE_DONGLE ?= false
+BOARD_HAVE_DONGLE ?= true
+# added  by dongshiyi 20200304 for meige_SLM790 end
 
 #for boot and shutdown animation ringing
 BOOT_SHUTDOWN_ANIMATION_RINGING ?= false

4.6 修改虚拟串口节点/dev/ttyUSB0~/dev/ttyUSB3的权限
修改文件:\device\rockchip\common\ueventd.rockchip.rc

diff --git a/ueventd.rockchip.rc b/ueventd.rockchip.rc
index 9b2c1cb..95d3203 100755
--- a/ueventd.rockchip.rc
+++ b/ueventd.rockchip.rc
@@ -59,17 +59,18 @@
 #/dev/ttyS2                0660   bluetooth  net_bt_stack
 /dev/rtk_btusb            0660   bluetooth  net_bt_stack
 
-# for radio
-/dev/ttyUSB0              0660   radio         radio
-/dev/ttyUSB1              0660   radio         radio
-/dev/ttyUSB2              0660   radio         radio
-/dev/ttyUSB3              0660   radio         radio
-/dev/ttyUSB4              0660   radio         radio
-/dev/ttyUSB5              0660   radio         radio
-/dev/ttyUSB6              0660   radio         radio
-/dev/ttyUSB7              0660   radio         radio
-/dev/ttyUSB8              0660   radio         radio
-/dev/ttyUSB9              0660   radio         radio
+# for radio  added  by dongshiyi 20200304 for meige_SLM790 start
+/dev/ttyUSB0              0777   radio         radio
+/dev/ttyUSB1              0777   radio         radio
+/dev/ttyUSB2              0777   radio         radio
+/dev/ttyUSB3              0777   radio         radio
+/dev/ttyUSB4              0777   radio         radio
+/dev/ttyUSB5              0777   radio         radio
+/dev/ttyUSB6              0777   radio         radio
+/dev/ttyUSB7              0777   radio         radio
+/dev/ttyUSB8              0777   radio         radio
+/dev/ttyUSB9              0777   radio         radio
+#   added  by dongshiyi 20200304 for meige_SLM790 end
 
 # for mali-t764
 /dev/mali0               0666   system          system


4.7把fae提供的 ip-down ip-up ip-up- init.gprs-pppd替换但源码中 \vendor\rockchip\common\phone\etc\ppp\ip-down ,\vendor\rockchip\common\phone\etc\ppp\ip-up,
\vendor\rockchip\common\phone\etc\ppp\和\vendor\rockchip\common\phone\etc\init.gprs-pppd

修改:\vendor\rockchip\common\phone\phone.mk

diff --git a/phone/phone.mk b/phone/phone.mk
index 946aacd..4dbbd0e 100755
--- a/phone/phone.mk
+++ b/phone/phone.mk
@@ -4,12 +4,14 @@ CUR_PATH := vendor/rockchip/common
 #########################################################
 #   3G Dongle SUPPORT
 #########################################################
+# added by dongshiyi 20200304 for meige_SLM790 start
 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-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
-
+# added by dongshiyi 20200304 for meige_SLM790 end
 ifeq ($(strip $(PRODUCT_MODEM)), DTS4108C)
 PRODUCT_COPY_FILES += \
     $(CUR_PATH)/phone/bin/rild_dts4108c:system/bin/rild \

这里需要把源码ip-up-.c的Android.mk编译规则给屏蔽掉,目的是不让它编译生成ip-up-,
屏蔽:frameworks/native/cmds/ip-up-/Android.mk

diff --git a/cmds/ip-up-/Android.mk b/cmds/ip-up-/Android.mk
old mode 100644
new mode 100755
index 36bbdf5..ab29f76
--- a/cmds/ip-up-/Android.mk
+++ b/cmds/ip-up-/Android.mk
@@ -14,13 +14,13 @@
 # limitations under the License.
 #
 
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
+#LOCAL_PATH := $(call my-dir)
+#include $(CLEAR_VARS)
 
-LOCAL_SRC_FILES := ip-up-.c
-LOCAL_SHARED_LIBRARIES := libcutils liblog
-LOCAL_MODULE := ip-up-
-LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/ppp
-LOCAL_MODULE_TAGS := optional
+#LOCAL_SRC_FILES := ip-up-.c
+#LOCAL_SHARED_LIBRARIES := libcutils liblog
+#LOCAL_MODULE := ip-up-
+#LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/ppp
+#LOCAL_MODULE_TAGS := optional

 
-include $(BUILD_EXECUTABLE)
+#include $(BUILD_EXECUTABLE)

4.8 修改拨号可执行文件的权限
文件修改:\system\core\libcutils\fs_config.c

diff --git a/libcutils/fs_config.c b/libcutils/fs_config.c
old mode 100644
new mode 100755
index 9acfa58..16f3893
--- a/libcutils/fs_config.c
+++ b/libcutils/fs_config.c
@@ -97,12 +97,20 @@ static const struct fs_path_config android_dirs[] = {
     { 00755, AID_ROOT,   AID_ROOT,   0, "root" },
     { 00750, AID_ROOT,   AID_SHELL,  0, "sbin" },
     { 00751, AID_ROOT,   AID_SDCARD_R, 0, "storage" },
-    { 00755, AID_ROOT,   AID_SHELL,  0, "system/bin" },
+    { 00777, AID_ROOT,   AID_SHELL,  0, "system/bin" },
     { 00755, AID_ROOT,   AID_SHELL,  0, "system/vendor" },
     { 00755, AID_ROOT,   AID_SHELL,  0, "system/xbin" },
-    { 00755, AID_ROOT,   AID_ROOT,   0, "system/etc/ppp" },
+    { 00777, AID_ROOT,   AID_ROOT,   0, "system/etc/ppp" },
     { 00755, AID_ROOT,   AID_SHELL,  0, "vendor" },
     { 00777, AID_ROOT,   AID_ROOT,   0, "sdcard" },
+    //# added  by dongshiyi 20200304 for meige_SLM790 start
+    { 00777, AID_SYSTEM, AID_SYSTEM, 0, "dev/ppp" },    
+    { 00777, AID_ROOT,   AID_SHELL,  0, "system/bin/pppd" },
+    { 00777, AID_ROOT,   AID_SHELL,  0, "system/bin/chat" },
+    { 00777, AID_ROOT,   AID_ROOT,   0, "system/etc/ppp/ip-down" },
+    { 00777, AID_ROOT,   AID_ROOT,   0, "system/etc/ppp/ip-up" },
+    { 00777, AID_ROOT,   AID_ROOT,   0, "system/etc/ppp/ip-up-" },
+     //# added  by dongshiyi 20200304 for meige_SLM790 start
     { 00755, AID_ROOT,   AID_ROOT,   0, 0 },
 };

4.8 将设置首选网络类型由3G设置为LTE
修改文件:frameworks\base\telephony\java\com\android\internal\telephony\RILConstants.java

diff --git a/telephony/java/com/android/internal/telephony/RILConstants.java b/telephony/
old mode 100644
new mode 100755
index a91e9be..a10a55c
--- a/telephony/java/com/android/internal/telephony/RILConstants.java
+++ b/telephony/java/com/android/internal/telephony/RILConstants.java
@@ -161,7 +161,7 @@ public interface RILConstants {
     int NETWORK_MODE_TDSCDMA_CDMA_EVDO_GSM_WCDMA  = 21; /*TD-SCDMA,EvDo,CDMA,GSM/WCDMA*/
     int NETWORK_MODE_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA = 22; /* TD-SCDMA/LTE/GSM/WCDMA, */
     int PREFERRED_NETWORK_MODE      = SystemProperties.getInt("ro.telephony.default_netw
-            NETWORK_MODE_WCDMA_PREF);
+            NETWORK_MODE_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA);
 
     int BAND_MODE_UNSPECIFIED = 0;      //"unspecified" (selected by baseband automatica
     int BAND_MODE_EURO = 1;             //"EURO band" (GSM-900 / DCS-1800 / WCDMA-IMT-20

你可能感兴趣的:(调试笔记,RK,笔记)