Adapt EC20 module 4G and GPS functions in Android11.0 system
Adapt EC20 module 4G and GPS functions in Android11.0 system
This article mainly describes adapting the EC20 module in RK3568Android11 to enable 4G and GPS functions.
ported 4g
- Add EC20 driver to Kernle
a./kernle/drivers/usb/erial/option.c
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index d83ec0a..7aca33b 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -586,6 +586,32 @@ static void option_instat_callback(struct urb *urb);
static const struct usb_device_id option_ids[] = {
{
USB_DEVICE(0x1286, 0x4e3c) },
+
+#if 1 //Added by Quectel
+ {
USB_DEVICE(0x05C6, 0x9090) }, /* Quectel UC15 */
+ {
USB_DEVICE(0x05C6, 0x9003) }, /* Quectel UC20 */
+ {
USB_DEVICE(0x05C6, 0x9215) }, /* Quectel EC20(MDM9215) */
+ {
USB_DEVICE(0x2C7C, 0x0125) }, /* Quectel EC20(MDM9x07)/EC25/EG25 */
+ {
USB_DEVICE(0x2C7C, 0x0121) }, /* Quectel EC21 */
+ {
USB_DEVICE(0x2C7C, 0x0191) }, /* Quectel EG91 */
+ {
USB_DEVICE(0x2C7C, 0x0195) }, /* Quectel EG95 */
+ {
USB_DEVICE(0x2C7C, 0x0306) }, /* Quectel EG06/EP06/EM06 */
+ {
USB_DEVICE(0x2C7C, 0x030B) }, /* Quectel EG065K/EG060K */
+ {
USB_DEVICE(0x2C7C, 0x0512) }, /* Quectel EG12/EP12/EM12/EG16/EG18 */
+ {
USB_DEVICE(0x2C7C, 0x0296) }, /* Quectel BG96 */
+ {
USB_DEVICE(0x2C7C, 0x0700) }, /* Quectel BG95/BG77/BG600L-M3/BC69 */
+ {
USB_DEVICE(0x2C7C, 0x0435) }, /* Quectel AG35 */
+ {
USB_DEVICE(0x2C7C, 0x0415) }, /* Quectel AG15 */
+ {
USB_DEVICE(0x2C7C, 0x0452) }, /* Quectel AG520 */
+ {
USB_DEVICE(0x2C7C, 0x0455) }, /* Quectel AG550 */
+ {
USB_DEVICE(0x2C7C, 0x0620) }, /* Quectel EG20 */
+ {
USB_DEVICE(0x2C7C, 0x0800) }, /* Quectel RG500/RM500/RG510/RM510 */
+ {
USB_DEVICE(0x2C7C, 0x0801) }, /* Quectel RG520/RM520/SG520 */
+ {
USB_DEVICE(0x2C7C, 0x6026) }, /* Quectel EC200 */
+ {
USB_DEVICE(0x2C7C, 0x6120) }, /* Quectel UC200 */
+ {
USB_DEVICE(0x2C7C, 0x6000) }, /* Quectel EC200/UC200 */
+ {
.match_flags = USB_DEVICE_ID_MATCH_VENDOR, .idVendor = 0x2C7C }, /* Match All Quectel Modules */
+#endif
{
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) },
@@ -2138,6 +2164,9 @@ static struct usb_serial_driver option_1port_device = {
#ifdef CONFIG_PM
.suspend = usb_wwan_suspend,
.resume = usb_wwan_resume,
+#if 1 //Added by Quectel
+ .reset_resume = usb_wwan_resume,
+#endif
#endif
};
@@ -2162,6 +2191,37 @@ static int option_probe(struct usb_serial *serial,
&serial->interface->cur_altsetting->desc;
unsigned long device_flags = id->driver_info;
+#if 1 //Added by Quectel
+ //Quectel UC20's interface 4 can be used as USB Network device
+ if (serial->dev->descriptor.idVendor == cpu_to_le16(0x05C6) && serial->dev->descriptor.idProduct == cpu_to_le16(0x9003)
+ && serial->interface->cur_altsetting->desc.bInterfaceNumber >= 4)
+ return -ENODEV;
+
+ //Quectel EC20(MDM9215)'s interface 4 can be used as USB Network device
+ if (serial->dev->descriptor.idVendor == cpu_to_le16(0x05C6) && serial->dev->descriptor.idProduct == cpu_to_le16(0x9215)
+ && serial->interface->cur_altsetting->desc.bInterfaceNumber >= 4)
+ return -ENODEV;
+
+ 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;
b./kernle/drivers/usb/erial/usb_wwan.c
diff --git a/drivers/usb/serial/usb_wwan.c b/drivers/usb/serial/usb_wwan.c
index c604ff45..49b9b2c 100644
--- a/drivers/usb/serial/usb_wwan.c
+++ b/drivers/usb/serial/usb_wwan.c
@@ -509,11 +509,22 @@ 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;
+ if (serial->dev->descriptor.idVendor == cpu_to_le16(0x05C6) && serial->dev->descriptor.idProduct == cpu_to_le16(0x9090))
+ urb->transfer_flags |= URB_ZERO_PACKET;
+ if (serial->dev->descriptor.idVendor == cpu_to_le16(0x05C6) && serial->dev->descriptor.idProduct == cpu_to_le16(0x9003))
+ urb->transfer_flags |= URB_ZERO_PACKET;
+ if (serial->dev->descriptor.idVendor == cpu_to_le16(0x05C6) && serial->dev->descriptor.idProduct == cpu_to_le16(0x9215))
+ urb->transfer_flags |= URB_ZERO_PACKET;
+ if (serial->dev->descriptor.idVendor == cpu_to_le16(0x2C7C))
+ urb->transfer_flags |= URB_ZERO_PACKET;
}
+#endif
+
return urb;
}
c./kernle/drivers/net/usb/qmi_wwan.c directly replace with the file in the resource package
- Add permissions and configuration
a. Modify /device/rockchip/common/BoardConfig.mk
diff --git a/BoardConfig.mk b/BoardConfig.mk
old mode 100755
new mode 100644
index e28fd4b..d73bee6
--- a/BoardConfig.mk
+++ b/BoardConfig.mk
@@ -59,7 +59,7 @@ BOARD_BOOT_HEADER_VERSION ?= 2
BOARD_MKBOOTIMG_ARGS :=
BOARD_PREBUILT_DTBOIMAGE ?= $(TARGET_DEVICE_DIR)/dtbo.img
BOARD_ROCKCHIP_VIRTUAL_AB_ENABLE ?= false
-BOARD_SELINUX_ENFORCING ?= true
+BOARD_SELINUX_ENFORCING ?= false
# Use the non-open-source parts, if they're present
TARGET_PREBUILT_KERNEL ?= kernel/arch/arm/boot/zImage
@@ -437,11 +437,11 @@ BOARD_BLUETOOTH_LE_SUPPORT ?= true
BOARD_WIFI_SUPPORT ?= true
#for rk 4g modem
-BOARD_HAS_RK_4G_MODEM ?= false
+BOARD_HAS_RK_4G_MODEM ?= true
-ifeq ($(strip $(BOARD_HAS_RK_4G_MODEM)),true)
-DEVICE_MANIFEST_FILE += device/rockchip/common/4g_modem/manifest.xml
-endif
+#ifeq ($(strip $(BOARD_HAS_RK_4G_MODEM)),true)
+#DEVICE_MANIFEST_FILE += device/rockchip/common/4g_modem/manifest.xml
+#endif
#USE_CLANG_PLATFORM_BUILD ?= true
b. Modify /device/rockchip/common/device.mk
diff --git a/device.mk b/device.mk
index 917e8b9..772df6f 100644
--- a/device.mk
+++ b/device.mk
@@ -273,21 +273,15 @@ PRODUCT_PROPERTY_OVERRIDES += \
ro.telephony.default_network=9
ifeq ($(strip $(TARGET_ARCH)), arm64)
-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
else
-PRODUCT_PROPERTY_OVERRIDES += \
- vendor.rild.libpath=/vendor/lib/librk-ril.so
-
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
-
+ $(LOCAL_PATH)/4g_modem/bin32/dhcpcd:$(TARGET_COPY_OUT_VENDOR)/bin/dhcpcd
endif
+
+$(call inherit-product, vendor/quectel/ec20/ec20.mk)
+
endif
ifneq ($(filter atv box, $(strip $(TARGET_BOARD_PLATFORM_PRODUCT))), )
c. Modify /device/rockchip/common/init.rk30board.rc
diff --git a/init.rk30board.rc b/init.rk30board.rc
old mode 100755
new mode 100644
index 6b8f9ec..cf913d1
--- a/init.rk30board.rc
+++ b/init.rk30board.rc
@@ -253,9 +253,9 @@ on property:persist.internet_adb_enable=0
restart adbd
# for telephony function
-on property:ro.boot.noril=true
- setprop ro.radio.noril true
- stop ril-daemon
+#on property:ro.boot.noril=true
+# setprop ro.radio.noril true
+# stop ril-daemon
# set ro.serialno
on property:vendor.serialno=*
d. Modify /device/rockchip/common/ueventd.rockchip.rc
diff --git a/ueventd.rockchip.rc b/ueventd.rockchip.rc
old mode 100755
new mode 100644
index 8b92518..87db2e8
--- a/ueventd.rockchip.rc
+++ b/ueventd.rockchip.rc
@@ -78,6 +78,14 @@
/dev/ttyUSB8 0660 radio radio
/dev/ttyUSB9 0660 radio radio
+# for cdc-wdm0
+/dev/cdc-wdm* 0660 radio radio
+
+# for qcqmi0
+/dev/qcqmi* 0660 radio radio
+/dev/cdc-acm* 0660 radio radio
+/dev/ttyACM* 0660 radio radio
+
# for mali-t764
/dev/mali0 0666 system system
@@ -167,6 +175,8 @@
/sys/bus/iio/devices/iio:device* smd_delay_threshold 0660 system system
/sys/bus/iio/devices/iio:device* smd_delay_threshold2 0660 system system
/sys/bus/iio/devices/iio:device* smd_threshold 0660 system system
+/sys/class/gpio/gpio* direction 0777 system system
+/sys/class/gpio/gpio* value 0777 system system
#for frp function
/dev/block/by-name/frp 0660 system system
- Add 4G modem network configuration, otherwise the SIM card icon and signal indication will not be visible in the status bar
Modify /device/rockchip/rk356x/overlay/frameworks/base/core/res /res/values/config.xml
diff --git a/overlay/frameworks/base/core/res/res/values/config.xml b/overlay/frameworks/base/core/res/res/values/config.xml
old mode 100755
new mode 100644
index 9feb244..2bacfc2
--- a/overlay/frameworks/base/core/res/res/values/config.xml
+++ b/overlay/frameworks/base/core/res/res/values/config.xml
@@ -31,6 +31,14 @@
<!-- the 6th element indicates boot-time dependency-met value. -->
<string-array translatable="false" name="networkAttributes">
<item>"wifi,1,1,2,-1,true"</item>
+ <item>"mobile,0,0,0,-1,true"</item>
+ <item>"mobile_mms,2,0,2,60000,true"</item>
+ <item>"mobile_supl,3,0,2,60000,true"</item>
+ <item>"mobile_dun,4,0,2,60000,true"</item>
+ <item>"mobile_hipri,5,0,3,60000,true"</item>
+ <item>"mobile_fota,10,0,2,60000,true"</item>
+ <item>"mobile_ims,11,0,2,60000,true"</item>
+ <item>"mobile_cbs,12,0,2,60000,true"</item>
<item>"bluetooth,7,7,0,-1,true"</item>
<item>"ethernet,9,9,9,-1,true"</item>
</string-array>
- Modify in the system directory
a. Modify /system/core/init/devices.cpp
diff --git a/init/devices.cpp b/init/devices.cpp
index 9fbec64..3a1914d 100644
--- a/init/devices.cpp
+++ b/init/devices.cpp
@@ -492,6 +492,10 @@ void DeviceHandler::HandleUevent(const Uevent& uevent) {
int device_id = uevent.minor % 128 + 1;
devpath = StringPrintf("/dev/bus/usb/%03d/%03d", bus_id, device_id);
}
+#if 1 //add by quectel for mknod /dev/cdc-wdmo
+ } else if (uevent.subsystem == "usbmisc" && !uevent.device_name.empty()) {
+ devpath = "/dev/" + uevent.device_name;
+#endif
} else if (StartsWith(uevent.subsystem, "usb")) {
// ignore other USB events
return;
b. Modify /system/core/init/init.cpp
diff --git a/init/init.cpp b/init/init.cpp
index 29859c5..2d0da56 100644
--- a/init/init.cpp
+++ b/init/init.cpp
@@ -421,8 +421,10 @@ static bool HandleControlMessage(std::string_view message, const std::string& na
return false;
}
- LOG(INFO) << "Control message: Processed ctl." << message << " for '" << name
- << "' from pid: " << from_pid << " (" << process_cmdline << ")";
+ if(strcmp(name.c_str(),"[email protected]::IRadio/slot1") != 0) {
+ LOG(INFO) << "Control message: Processed ctl." << message << " for '" << name
+ << "' from pid: " << from_pid << " (" << process_cmdline << ")";
+ }
return true;
}
c. Modify /system/hwservicemanager/ServiceManager.cpp
diff --git a/ServiceManager.cpp b/ServiceManager.cpp
index 85d4974..8db1064 100644
--- a/ServiceManager.cpp
+++ b/ServiceManager.cpp
@@ -251,8 +251,10 @@ static void tryStartService(const std::string& fqName, const std::string& name)
// have an 'interface' entry in its .rc file OR if the service is already
// running, then this will be a no-op. So, for instance, if a service is
// deadlocked during startup, you will see this message repeatedly.
- LOG(INFO) << "Since " << fqName << "/" << name
- << " is not registered, trying to start it as a lazy HAL.";
+ if(strcmp(fqName.c_str(),"[email protected]::IRadio") != 0) {
+ LOG(INFO) << "Since " << fqName << "/" << name
+ << " is not registered, trying to start it as a lazy HAL.";
+ }
std::thread([=] {
(void)SetProperty("ctl.interface_start", fqName + "/" + name);
d. Modify /system/libhidl/transport/ServiceManagement.cpp
diff --git a/transport/ServiceManagement.cpp b/transport/ServiceManagement.cpp
index a7e9626..b0a8c84 100644
--- a/transport/ServiceManagement.cpp
+++ b/transport/ServiceManagement.cpp
@@ -626,7 +626,9 @@ struct Waiter : IServiceNotification {
break;
}
- LOG(WARNING) << "Waited one second for " << mInterfaceName << "/" << mInstanceName;
+ if(strcmp(mInterfaceName.c_str(),"[email protected]::IRadio") != 0) {
+ LOG(WARNING) << "Waited one second for " << mInterfaceName << "/" << mInstanceName;
+ }
} while (!timeout);
}
@@ -800,7 +802,9 @@ sp<::android::hidl::base::V1_0::IBase> getRawServiceInternal(const std::string&
if (vintfLegacy || !retry) break;
if (waiter != nullptr) {
- ALOGI("getService: Trying again for %s/%s...", descriptor.c_str(), instance.c_str());
+ if(strcmp(descriptor.c_str(),"[email protected]::IRadio") != 0) {
+ ALOGI("getService: Trying again for %s/%s...", descriptor.c_str(), instance.c_str());
+ }
waiter->wait(true /* timeout */);
}
}
- Modify service startup configuration in hardware
Modify /hardware/ril/rild/rild.rc
diff --git a/rild/rild.rc b/rild/rild.rc
index f6beb54..7c2b1af 100644
--- a/rild/rild.rc
+++ b/rild/rild.rc
@@ -1,5 +1,5 @@
-service vendor.ril-daemon /vendor/bin/hw/rild
+service ril-daemon /vendor/bin/hw/rild -l /vendor/lib64/hw/libreference-ril-ec20.so
class main
- user radio
- group radio cache inet misc audio log readproc wakelock
+ user root
+ group radio cache inet misc audio sdcard_rw log
capabilities BLOCK_SUSPEND NET_ADMIN NET_RAW
- Add EC20 driver files in vendor
Add the driver file directory to the /vendor directory, as follows:
- Package flash machine for verification
- How to check the running status of the 4G module
a.adb shell Enter the device and execute getprop |grep gsm. The results are as follows:
b.adb shell Enter the device and execute getprop |grep ril. The results are as follows:
Transplant GPS
- Add the GPS driver in the Vendor directory, as shown below;
- Add configuration and modify /device/rockchip/rk356x/BoardConfig.mk
diff --git a/BoardConfig.mk b/BoardConfig.mk
index e2773c1..dfa41ba 100644
--- a/BoardConfig.mk
+++ b/BoardConfig.mk
@@ -65,7 +65,7 @@ ENABLE_CPUSETS := true
WITH_DEXPREOPT := true
BOARD_NFC_SUPPORT := false
-BOARD_HAS_GPS := false
+BOARD_HAS_GPS := true
BOARD_GRAVITY_SENSOR_SUPPORT := true
BOARD_COMPASS_SENSOR_SUPPORT := false
3. Because [email protected] is used, the check_vintf compatibility_matrix version error will be reported during compilation. Modify /hardware/interfaces/compatibility_matrices/compatibility_matrix.5.xml
diff --git a/compatibility_matrices/compatibility_matrix.5.xml b/compatibility_matrices/compatibility_matrix.5.xml
index a535a2a..03b395b 100644
--- a/compatibility_matrices/compatibility_matrix.5.xml
+++ b/compatibility_matrices/compatibility_matrix.5.xml
@@ -202,7 +202,7 @@
</hal>
<hal format="hidl" optional="true">
<name>android.hardware.gnss</name>
- <version>2.0-1</version>
+ <version>1.0</version>
<interface>
<name>IGnss</name>
<instance>default</instance>
Configuration file ec20.mk of the driver file
# Quectel EC20
DEVICE_MANIFEST_FILE += vendor/quectel/ec20/rild/manifest.xml
PRODUCT_PROPERTY_OVERRIDES += \
vendor.rild.libpath=/vendor/lib64/hw/libreference-ril-ec20.so
PRODUCT_COPY_FILES += \
vendor/quectel/ec20/rild/ip-down:system/etc/ppp/ip-down \
vendor/quectel/ec20/rild/ip-up:system/etc/ppp/ip-up \
vendor/quectel/ec20/rild/chat:system/bin/chat \
vendor/quectel/ec20/rild/libreference-ril-ec20.so:vendor/lib64/hw/libreference-ril-ec20.so \
vendor/quectel/ec20/rild/librk-ril.so:vendor/lib64/librk-ril.so \
vendor/quectel/ec20/rild/ql-ril.conf:system/etc/ql-ril.conf
#GPS
ifeq ($(strip $(BOARD_HAS_GPS)),true)
PRODUCT_PACKAGES += \
[email protected] \
[email protected]
PRODUCT_COPY_FILES += \
vendor/quectel/ec20/gps/arm64-v8a/gps.default.so:$(TARGET_COPY_OUT_VENDOR)/lib64/hw/gps.default.so\
vendor/quectel/ec20/gps/gps_cfg.inf:$(TARGET_COPY_OUT_VENDOR)/etc/gps_cfg.inf
endif