全志A133 android10 适配EC20 4G模块

一,移植适配

1. 驱动移植

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

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

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

bash 复制代码
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

bash 复制代码
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

bash 复制代码
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

bash 复制代码
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

bash 复制代码
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/

bash 复制代码
A133_Android10_b$ ls -l android/vendor/quectel/libquectel-ril/
总用量 224
-rw-rw-r-- 1 fy fy 207092 12月 30  2020 apns-conf.xml
drwxrwxr-x 2 fy fy   4096 9月   5 14:25 arm64-v8a
drwxrwxr-x 2 fy fy   4096 9月   5 14:25 armeabi
drwxrwxr-x 2 fy fy   4096 9月   5 14:25 doc
-rw-rw-r-- 1 fy fy    959 12月 24  2020 ql-ril.conf
-rw-rw-r-- 1 fy fy    723 9月   5 14:26 radio_common.mk

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

二,调试

首先检查电压供电正常;

  • 检查daemon是否运行
bash 复制代码
getprop init.svc.ril-daemon
  • 查看so库是否正确配置加载
bash 复制代码
su
cat /init.rc | grep ril-daemon
  • 检查permision
bash 复制代码
ls -l /dev/ttyUSB*
  • 查看库版本来源
bash 复制代码
getprop gsm.version.ril-impl
相关推荐
DOT小文哥18 天前
全志Linux磁盘操作基础命令
linux·全志·gparted·fdisk
智联物联1 个月前
4G工业路由器赋能智能停车场远程监控管理
4g·工业路由器·停车场管理·智能停车场·智慧停车场·物联网路由器
威迪斯特1 个月前
装修装饰行业4G/5G无线视频监控技术方案
5g·视频监控·4g·建筑·无线·装修·装饰
DOT小文哥3 个月前
通过物联网管理多台MQTT设备-基于全志T527开发板
linux·物联网·mqtt·嵌入式·全志·t527
DOT小文哥3 个月前
百问网全志D1h开发板LVGL9移植详细教程
elasticsearch·gui·lvgl·risc-v·全志·显示
DOT小文哥3 个月前
用全志T113做了块多功能卡片电脑,成本只要60块
linux·单片机·电脑·全志·t113·卡片电脑
EasyCVR3 个月前
如何在纯内网环境下,将EasyCVR视频汇聚网关通过4G与第三方公网云平台级联?
音视频·视频编解码·视频汇聚·4g·内网
林政硕(Cohen0415)3 个月前
在镜像中添加Git提交号
git·全志·嵌入式linux·t113
DOT小文哥4 个月前
在全志H616核桃派开发板上进行音频配置的方法详解
ssh·音视频·全志·hdmi·vlc·h616