自学内容网 自学内容网

全志A133 android10 适配EC20 4G模块

一,移植适配

1. 驱动移植

代码路径:longan/kernel/linux-4.9/drivers/usb/serial/option.c

diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index 9f96dd2..2f25466 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -245,6 +245,7 @@ static int  option_probe(struct usb_serial *serial,

#define QUECTEL_VENDOR_ID                      0x2c7c
/* These Quectel products use Quectel's vendor ID */
+#define QUECTEL_PRODUCT_EC20                   0x6002
#define QUECTEL_PRODUCT_EC21                   0x0121
#define QUECTEL_PRODUCT_EC25                   0x0125
#define QUECTEL_PRODUCT_BG96                   0x0296
@@ -1079,6 +1080,7 @@ static int  option_probe(struct usb_serial *serial,
        { USB_DEVICE(QUALCOMM_VENDOR_ID, UBLOX_PRODUCT_R410M),
          .driver_info = RSVD(1) | RSVD(3) },
        /* Quectel products using Quectel vendor ID */
+       { USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC20)},
        { USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC21),
          .driver_info = RSVD(4) },
        { USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC25),
@@ -1999,6 +2001,9 @@ static int  option_probe(struct usb_serial *serial,
#ifdef CONFIG_PM
        .suspend           = usb_wwan_suspend,
        .resume            = usb_wwan_resume,
+#if 1 //Added by Quectel
+       .reset_resume = usb_wwan_resume,
+#endif
#endif
};

@@ -2036,6 +2041,15 @@ static int option_probe(struct usb_serial *serial,
            iface_desc->bInterfaceClass != USB_CLASS_CDC_DATA)
                return -ENODEV;

+#if 1 //Added by Quectel
+       if (serial->dev->descriptor.idVendor == cpu_to_le16(0x2C7C)) {
+               __u16 idProduct = le16_to_cpu(serial->dev->descriptor.idProduct);
+               //Quectel EC200S's interface 0 can be used as USB Network device (ecm, rndis)
+               if (serial->interface->cur_altsetting->desc.bInterfaceClass != 0xFF)
+                       return -ENODEV;
+       }
+#endif
        /* Store the device flags so we can use them during attach. */
        usb_set_serial_data(serial, (void *)device_flags);

代码路径:longan/kernel/linux-4.9/drivers/usb/serial/usb_wwan.c

diff --git a/drivers/usb/serial/usb_wwan.c b/drivers/usb/serial/usb_wwan.c
index 3dfdfc8..0476229 100644
--- a/drivers/usb/serial/usb_wwan.c
+++ b/drivers/usb/serial/usb_wwan.c
@@ -505,6 +505,14 @@ static struct urb *usb_wwan_setup_urb(struct usb_serial_port *port,
                          usb_sndbulkpipe(serial->dev, endpoint) | dir,
                          buf, len, callback, ctx);

+#if 1 //Added by Quectel for zero packet
+       if (dir == USB_DIR_OUT) {
+       struct usb_device_descriptor *desc = &serial->dev->descriptor;
+       if (desc->idVendor == cpu_to_le16(0x2C7C))
+       urb->transfer_flags |= URB_ZERO_PACKET;
+       }
+#endif
+
        return urb;
}

2. ril库移植

代码路径:android/device/softwinner/ceres-b6/ceres_b6.mk

diff --git a/android/device/softwinner/ceres-b6/ceres_b6.mk b/android/device/softwinner/ceres-b6/ceres_b6.mk
index 321272978e..8e36d8cd74 100644
--- a/android/device/softwinner/ceres-b6/ceres_b6.mk
+++ b/android/device/softwinner/ceres-b6/ceres_b6.mk
@@ -159,9 +159,9 @@ PRODUCT_PACKAGES += \
#PRODUCT_PACKAGES += AllwinnerGmsIntegration
-############################### 3G Dongle Support ###############################
+############################### 4G Dongle Support ###############################
# Radio Packages and Configuration Flie
-$(call inherit-product-if-exists, vendor/aw/public/prebuild/lib/librild/radio_common.mk)
+$(call inherit-product-if-exists, vendor/quectel/libquectel-ril/radio_common.mk)

代码路径:android/device/softwinner/ceres-b6/configs/manifest.xml

diff --git a/android/device/softwinner/ceres-b6/configs/manifest.xml b/android/device/softwinner/ceres-b6/configs/manifest.xml
index fb82972d59..b9c7cb5178 100644
--- a/android/device/softwinner/ceres-b6/configs/manifest.xml
+++ b/android/device/softwinner/ceres-b6/configs/manifest.xml
@@ -25,6 +25,24 @@
             <name>IUsb</name>
             <instance>default</instance>
         </interface>
+    </hal>
+     <hal format="hidl">
+        <name>android.hardware.radio.deprecated</name>
+        <transport>hwbinder</transport>
+        <version>1.0</version>
+        <interface>
+            <name>IOemHook</name>
+            <instance>slot1</instance>
+        </interface>
+    </hal>
+    <hal format="hidl">
+        <name>android.hardware.radio</name>
+        <transport>hwbinder</transport>
+        <version>1.0</version>
+        <interface>
+            <name>IRadio</name>
+            <instance>slot1</instance>
+        </interface>
     </hal>
     <hal format="hidl">
         <name>android.hardware.audio.effect</name>

代码路径:android/device/softwinner/ceres-b6/init.device.rc

diff --git a/android/device/softwinner/ceres-b6/init.device.rc b/android/device/softwinner/ceres-b6/init.device.rc
index 1f1e569d15..83185821a6 100644
--- a/android/device/softwinner/ceres-b6/init.device.rc
+++ b/android/device/softwinner/ceres-b6/init.device.rc
@@ -1,3 +1,5 @@
+import /vendor/etc/init/rild.rc
+
on init
     # Load persistent dm-verity state
     verity_load_state

代码路径:android/hardware/ril/rild/Android.mk

diff --git a/android/hardware/ril/rild/Android.mk b/android/hardware/ril/rild/Android.mk
index b8ba508ee9..1b3d5bfa83 100644
--- a/android/hardware/ril/rild/Android.mk
+++ b/android/hardware/ril/rild/Android.mk
@@ -29,7 +29,7 @@ endif
LOCAL_MODULE_RELATIVE_PATH := hw
LOCAL_PROPRIETARY_MODULE := true
LOCAL_MODULE:= rild
-LOCAL_VINTF_FRAGMENTS := radio.xml
+#LOCAL_VINTF_FRAGMENTS := radio.xml
ifeq ($(PRODUCT_COMPATIBLE_PROPERTY),true)
LOCAL_INIT_RC := rild.rc
LOCAL_CFLAGS += -DPRODUCT_COMPATIBLE_PROPERTY

3. 添加权限

代码路径:android/device/softwinner/common/sepolicy/vendor/rild.te

diff --git a/android/device/softwinner/common/sepolicy/vendor/rild.te b/android/device/softwinner/common/sepolicy/vendor/rild.te
index 8fdddc57a6..d29b4a2688 100755
--- a/android/device/softwinner/common/sepolicy/vendor/rild.te
+++ b/android/device/softwinner/common/sepolicy/vendor/rild.te
@@ -5,6 +5,7 @@ allow rild vendor_file:file execute_no_trans;
allow rild vendor_ril_prop:file { read getattr open };
allow rild vendor_ril_prop:property_service set;
allow rild vendor_default_prop:file {open read getattr};
+allow rild rild:packet_socket create_socket_perms_no_ioctl;
allow rild vendor_toolbox_exec:file execute_no_trans;
allow rild vendor_shell_exec:file execute_no_trans;

4. ril库存放路径

代码路径:android/vendor/quectel/libquectel-ril/

A133_Android10_b$ ls -l android/vendor/quectel/libquectel-ril/
总用量 224
-rw-rw-r-- 1 fy fy 207092 1230  2020 apns-conf.xml
drwxrwxr-x 2 fy fy   4096 95 14:25 arm64-v8a
drwxrwxr-x 2 fy fy   4096 95 14:25 armeabi
drwxrwxr-x 2 fy fy   4096 95 14:25 doc
-rw-rw-r-- 1 fy fy    959 1224  2020 ql-ril.conf
-rw-rw-r-- 1 fy fy    723 95 14:26 radio_common.mk

libquectel-ril下载链接:https://download.csdn.net/download/weixin_45639314/89774784

二,调试

首先检查电压供电正常;

  • 检查daemon是否运行
getprop init.svc.ril-daemon

在这里插入图片描述

  • 查看so库是否正确配置加载
su
cat /init.rc | grep ril-daemon

在这里插入图片描述

  • 检查permision
ls -l /dev/ttyUSB*

在这里插入图片描述

  • 查看库版本来源
getprop gsm.version.ril-impl

在这里插入图片描述


原文地址:https://blog.csdn.net/weixin_45639314/article/details/142379053

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!