20240107移远的4G模块EC20在Firefly的AIO-3399J开发板的Android11下调通能上网

20240107移远的4G模块EC20在Firefly的AIO-3399J开发板的Android11下调通能上网
2024/1/7 11:17


开发板:Firefly的AIO-3399J【RK3399】
SDK:rk3399-android-11-r20211216.tar.xz【Android11】
Android11.0.tar.bz2.aa【ToyBrick】
Android11.0.tar.bz2.ab
Android11.0.tar.bz2.ac

https://wiki.t-firefly.com/AIO-3399J/prepare_compile_android.html
AIO-3399J产品规格书 立即购买
AIO-3399J 采用 RK3399 六核(A72x2+A53x4) 64 位处理器,主频高达1.8GHz,集成了四核 Mali-T860 GPU,性能优异。


0、简略步骤:
rootroot@rootroot-X99-Turbo:~/3TB$ cat Android11.0.tar.bz2.a* > Android11.0.tar.bz2
rootroot@rootroot-X99-Turbo:~/3TB$ tar jxvf Android11.0.tar.bz2 
rootroot@rootroot-X99-Turbo:~/3TB$ mv Android11.0 64rk3399-android-11
rootroot@rootroot-X99-Turbo:~/3TB$ cd 64rk3399-android-11
rootroot@rootroot-X99-Turbo:~/3TB/64rk3399-android-11$ cd u-boot
rootroot@rootroot-X99-Turbo:~/3TB/64rk3399-android-11/u-boot$ ./make.sh rk3399
rootroot@rootroot-X99-Turbo:~/3TB/64rk3399-android-11/u-boot$ cd ..
rootroot@rootroot-X99-Turbo:~/3TB/64rk3399-android-11$ cd kernel/
rootroot@rootroot-X99-Turbo:~/3TB/64rk3399-android-11/kernel$ make ARCH=arm64 rockchip_defconfig android-11.config -j36
rootroot@rootroot-X99-Turbo:~/3TB/64rk3399-android-11/kernel$ make ARCH=arm64 BOOT_IMG=../rockdev/Image-rk3399_Android11/boot.img rk3399-sapphire-excavator-edp-avb.img -j36
rootroot@rootroot-X99-Turbo:~/3TB/64rk3399-android-11$ source build/envsetup.sh 
rootroot@rootroot-X99-Turbo:~/3TB/64rk3399-android-11$ lunch
     36. rk3399_Android11-userdebug
Which would you like? [aosp_arm-eng] 36
rootroot@rootroot-X99-Turbo:~/3TB/64rk3399-android-11$ 
rootroot@rootroot-X99-Turbo:~/3TB/64rk3399-android-11$ make -j36
rootroot@rootroot-X99-Turbo:~/3TB/64rk3399-android-11$ ./build.sh -u


Android部分:【完全一致/相同】
1、
Z:\rk3399-android-11\device\rockchip\common\4g_modem\manifest.xml
<manifest version="1.0" type="device">
    <hal format="hidl">
        <name>android.hardware.radio</name>
        <transport>hwbinder</transport>
        <fqname>@1.1::IRadio/slot1</fqname>
        <fqname>@1.1::IRadio/slot2</fqname>
        <fqname>@1.2::ISap/slot1</fqname>
    </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.config</name>
        <transport>hwbinder</transport>
        <version>1.0</version>
        <interface>
            <name>IRadioConfig</name>
            <instance>default</instance>
        </interface>
    </hal>
</manifest>


2、复制库文件:【貌似没用?】
chat
dhcpcd
ip-down
ip-up
libmeig-ril.so
libquec-ril.so
libreference-ril-62.so
libreference-ril.so

Z:\rk3399-android-11\device\rockchip\common\ec20\chat
Z:\rk3399-android-11\device\rockchip\common\ec20\dhcpcd
Z:\rk3399-android-11\device\rockchip\common\ec20\ip-down
Z:\rk3399-android-11\device\rockchip\common\ec20\ip-up
Z:\rk3399-android-11\device\rockchip\common\ec20\libmeig-ril.so
Z:\rk3399-android-11\device\rockchip\common\ec20\libquec-ril.so
Z:\rk3399-android-11\device\rockchip\common\ec20\libreference-ril-62.so
Z:\rk3399-android-11\device\rockchip\common\ec20\libreference-ril.so


3、
Z:\rk3399-android-11\device\rockchip\common\BoardConfig.mk


#for rk 4g modem
BOARD_HAS_RK_4G_MODEM ?= false


修改为:
#for rk 4g modem 2024/1/5 23:36
BOARD_HAS_RK_4G_MODEM ?= false

#for ec20 modem 2024/1/5 22:25
BOARD_HAS_EC20_MODEM ?= true

ifeq ($(strip $(BOARD_HAS_EC20_MODEM)),true)
DEVICE_MANIFEST_FILE += device/rockchip/common/4g_modem/manifest.xml
endif

#for ec20 modem 2024/1/7 22:25


4、
Z:\rk3399-android-11\device\rockchip\common\device.mk
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
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

endif
endif

#for ec20 modem 2024/1/5 22:25
ifeq ($(strip $(BOARD_HAS_EC20_MODEM)),true)
PRODUCT_COPY_FILES += \
                      device/rockchip/common/ec20/libquec-ril.so:vendor/lib64/libquec-ril.so \
                      device/rockchip/common/ec20/libmeig-ril.so:vendor/lib64/libmeig-ril.so \
                      device/rockchip/common/ec20/chat:system/bin/chat \
                      device/rockchip/common/ec20/ip-up:system/etc/ppp/ip-up \
                      device/rockchip/common/ec20/ip-down:system/etc/ppp/ip-down \
                      device/rockchip/common/ec20/dhcpcd:$(TARGET_COPY_OUT_VENDOR)/bin/dhcpcd

PRODUCT_COPY_FILES += vendor/rockchip/common/phone/etc/apns-full-conf.xml:$(TARGET_COPY_OUT_PRODUCT)/etc/apns-conf.xml

PRODUCT_PACKAGES += \
                   rild \
                   dhcpcd \
                   CarrierDefaultApp \
                   CarrierConfig

PRODUCT_PROPERTY_OVERRIDES += \
                      ro.boot.noril=false \
                      ro.telephony.default_network=9

PRODUCT_PACKAGES += \
                      android.hardware.radio@1.2-radio-service \
                      android.hardware.radio.config@1.0-service

PRODUCT_PROPERTY_OVERRIDES += \
                      vendor.rild.libpath=/vendor/lib64/libquec-ril.so
endif
#for ec20 modem 2024/1/7 22:25


5、
Z:\rk3399-android-11\device\rockchip\common\ueventd.rockchip.rc

# for serial
/dev/ttyS4                0660   system     system

# for radio
/dev/ttyUSB*              0660   system     radio
/dev/cdc-wdm0             0660   system     radio

# for mali-t764
/dev/mali0                 0666   system        system


修改为:

# for serial
/dev/ttyS4                0660   system     system

#for ec20 modem 2024/1/5 22:25
# for radio
/dev/ttyUSB*              0660   radio     radio
/dev/ttyACM*              0666   radio          radio
/dev/cdc-wdm*             0666   radio          radio
/dev/qcqmi*               0660   radio          radio

#for ec20 modem 2024/1/5 22:25

# for mali-t764
/dev/mali0                 0666   system        system


6、
Z:\rk3399-android-11\device\rockchip\rk3399\rk3399_Android11\overlay\frameworks\base\core\res\res\values\config.xml

<?xml version="1.0" encoding="utf-8"?>
<!--
/*
** Copyright 2009, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
**     http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->

<resources>


    <!-- This string array should be overridden by the device to present a list of network
         attributes.  This is used by the connectivity manager to decide which networks can coexist
         based on the hardware -->
    <!-- An Array of "[Connection name],[ConnectivityManager connection type],
         [associated radio-type],[priority],[restoral-timer(ms)],[dependencyMet]  -->
    <!-- the 5th element "resore-time" indicates the number of milliseconds to delay
         before automatically restore the default connection.  Set -1 if the connection
         does not require auto-restore. -->
    <!-- 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>
<!--add by blb-->
        <item>"pppoe,15,15,5,-1,true"</item>
    </string-array>
    <!-- Flag indicating whether we should enable the automatic brightness in Settings.
         config_hardware_automatic_brightness_available is not set, so we will use software implementation -->
    <bool name="config_automatic_brightness_available">true</bool>


【不用修改】
Z:\rk3399-android-11\device\rockchip\rk3399\device.mk


7、
Z:\rk3399-android-11\kernel\drivers\net\usb\Makefile
# SPDX-License-Identifier: GPL-2.0
#
# Makefile for USB Network drivers
#

obj-$(CONFIG_USB_CATC)        += catc.o
obj-$(CONFIG_USB_KAWETH)    += kaweth.o
obj-$(CONFIG_USB_PEGASUS)    += pegasus.o
obj-$(CONFIG_USB_RTL8150)    += rtl8150.o
obj-$(CONFIG_USB_RTL8152)    += r8152.o
obj-$(CONFIG_USB_HSO)        += hso.o
obj-$(CONFIG_USB_LAN78XX)    += lan78xx.o
obj-$(CONFIG_USB_NET_AX8817X)    += asix.o
asix-y := asix_devices.o asix_common.o ax88172a.o
obj-$(CONFIG_USB_NET_AX88179_178A)      += ax88179_178a.o
obj-$(CONFIG_USB_NET_CDCETHER)    += cdc_ether.o
obj-$(CONFIG_USB_NET_CDC_EEM)    += cdc_eem.o
obj-$(CONFIG_USB_NET_DM9601)    += dm9601.o
obj-$(CONFIG_USB_NET_SR9700)    += sr9700.o
obj-$(CONFIG_USB_NET_SR9800)    += sr9800.o
obj-$(CONFIG_USB_NET_SMSC75XX)    += smsc75xx.o
obj-$(CONFIG_USB_NET_SMSC95XX)    += smsc95xx.o
obj-$(CONFIG_USB_NET_GL620A)    += gl620a.o
obj-$(CONFIG_USB_NET_NET1080)    += net1080.o
obj-$(CONFIG_USB_NET_PLUSB)    += plusb.o
obj-$(CONFIG_USB_NET_RNDIS_HOST)    += rndis_host.o
obj-$(CONFIG_USB_NET_CDC_SUBSET_ENABLE)    += cdc_subset.o
obj-$(CONFIG_USB_NET_ZAURUS)    += zaurus.o
obj-$(CONFIG_USB_NET_MCS7830)    += mcs7830.o
obj-$(CONFIG_USB_USBNET)    += usbnet.o
obj-$(CONFIG_USB_NET_INT51X1)    += int51x1.o
obj-$(CONFIG_USB_CDC_PHONET)    += cdc-phonet.o
obj-$(CONFIG_USB_NET_KALMIA)    += kalmia.o
obj-$(CONFIG_USB_IPHETH)    += ipheth.o
obj-$(CONFIG_USB_SIERRA_NET)    += sierra_net.o
obj-$(CONFIG_USB_NET_CX82310_ETH)    += cx82310_eth.o
obj-$(CONFIG_USB_NET_CDC_NCM)    += cdc_ncm.o
obj-$(CONFIG_USB_NET_HUAWEI_CDC_NCM)    += huawei_cdc_ncm.o
obj-$(CONFIG_USB_VL600)        += lg-vl600.o
#obj-$(CONFIG_USB_NET_QMI_WWAN)    += qmi_wwan.o
obj-$(CONFIG_USB_NET_QMI_WWAN) += qmi_wwan_q.o

obj-$(CONFIG_USB_NET_CDC_MBIM)    += cdc_mbim.o
obj-$(CONFIG_USB_NET_CH9200)    += ch9200.o


Z:\rk3399-android-11\kernel\drivers\net\usb\qmi_wwan_q.c

/*
 * Copyright (c) 2012  Bjørn Mork <bjorn@mork.no>
 *
 * The probing code is heavily inspired by cdc_ether, which is:
 * Copyright (C) 2003-2005 by David Brownell
 * Copyright (C) 2006 by Ole Andre Vadla Ravnas (ActiveSync)
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * version 2 as published by the Free Software Foundation.
 */
 
#include <linux/module.h>
#include <linux/netdevice.h>
#include <linux/ethtool.h>
#include <linux/etherdevice.h>
#include <linux/mii.h>
#include <linux/usb.h>
#include <linux/usb/cdc.h>
#include <linux/usb/usbnet.h>
#include <linux/usb/cdc-wdm.h>
 
/* This driver supports wwan (3G/LTE/?) devices using a vendor
 * specific management protocol called Qualcomm MSM Interface (QMI) -
 * in addition to the more common AT commands over serial interface
 * management
 *
 * QMI is wrapped in CDC, using CDC encapsulated commands on the
 * control ("master") interface of a two-interface CDC Union
 * resembling standard CDC ECM.  The devices do not use the control
 * interface for any other CDC messages.  Most likely because the
 * management protocol is used in place of the standard CDC
 * notifications NOTIFY_NETWORK_CONNECTION and NOTIFY_SPEED_CHANGE
 *
 * Alternatively, control and data functions can be combined in a
 * single USB interface.
 *
 * Handling a protocol like QMI is out of the scope for any driver.
 * It is exported as a character device using the cdc-wdm driver as
 * a subdriver, enabling userspace applications ("modem managers") to
 * handle it.
 *
 * These devices may alternatively/additionally be configured using AT
 * commands on a serial interface
 */
 
/* driver specific data */
struct qmi_wwan_state {
    struct usb_driver *subdriver;
    atomic_t pmcount;
    unsigned long unused;
    struct usb_interface *control;
    struct usb_interface *data;
};
 
/* default ethernet address used by the modem */
static const u8 default_modem_addr[ETH_ALEN] = {0x02, 0x50, 0xf3};
 
#if 1 //Added by Quectel
#include <linux/etherdevice.h>
#include <net/arp.h>
#include <net/ip.h>
#include <net/ipv6.h>
 
/*
    Quectel_WCDMA&LTE_Linux_USB_Driver_User_Guide_V1.9.pdf
    5.6.    Test QMAP on GobiNet or QMI WWAN
    0 - no QMAP
    1 - QMAP (Aggregation protocol)
    X - QMAP (Multiplexing and Aggregation protocol)
*/
#define QUECTEL_WWAN_QMAP 4
 
#if defined(QUECTEL_WWAN_QMAP)
#define QUECTEL_QMAP_MUX_ID 0x81
 
static uint __read_mostly qmap_mode = 0;
module_param( qmap_mode, uint, S_IRUGO);
module_param_named( rx_qmap, qmap_mode, uint, S_IRUGO );
#endif
 
#ifdef CONFIG_BRIDGE
//#define QUECTEL_BRIDGE_MODE
#endif
 
#ifdef QUECTEL_BRIDGE_MODE
static uint __read_mostly bridge_mode = BIT(0)/*|BIT(1)*/;
module_param( bridge_mode, uint, S_IRUGO );
#endif
 
#if defined(QUECTEL_WWAN_QMAP)
typedef struct sQmiWwanQmap
{
    struct usbnet *mpNetDev;
    atomic_t refcount;
    struct net_device *mpQmapNetDev[QUECTEL_WWAN_QMAP];
    uint link_state;
    uint qmap_mode;
#ifdef QUECTEL_BRIDGE_MODE
    uint bridge_mode;
    uint bridge_ipv4;
    unsigned char bridge_mac[ETH_ALEN];
#endif
} sQmiWwanQmap;
 
struct qmap_priv {
    struct net_device *real_dev;
    u8 offset_id;
#ifdef QUECTEL_BRIDGE_MODE
    uint bridge_mode;
    uint bridge_ipv4;
    unsigned char bridge_mac[ETH_ALEN];
#endif
};
 
struct qmap_hdr {
    u8 cd_rsvd_pad;
    u8 mux_id;
    u16 pkt_len;
} __packed;
 
#ifdef QUECTEL_BRIDGE_MODE
static int is_qmap_netdev(const struct net_device *netdev);
#endif
#endif
 
#ifdef QUECTEL_BRIDGE_MODE
static int bridge_arp_reply(struct net_device *net, struct sk_buff *skb, uint bridge_ipv4) {
    struct arphdr *parp;
    u8 *arpptr, *sha;
    u8  sip[4], tip[4], ipv4[4];
    struct sk_buff *reply = NULL;
 
    ipv4[0]  = (bridge_ipv4 >> 24) & 0xFF;
    ipv4[1]  = (bridge_ipv4 >> 16) & 0xFF;
    ipv4[2]  = (bridge_ipv4 >> 8) & 0xFF;
    ipv4[3]  = (bridge_ipv4 >> 0) & 0xFF;
        
    parp = arp_hdr(skb);
 
    if (parp->ar_hrd == htons(ARPHRD_ETHER)  && parp->ar_pro == htons(ETH_P_IP)
        && parp->ar_op == htons(ARPOP_REQUEST) && parp->ar_hln == 6 && parp->ar_pln == 4) {
        arpptr = (u8 *)parp + sizeof(struct arphdr);
        sha = arpptr;
        arpptr += net->addr_len;    /* sha */
        memcpy(sip, arpptr, sizeof(sip));
        arpptr += sizeof(sip);
        arpptr += net->addr_len;    /* tha */
        memcpy(tip, arpptr, sizeof(tip));
 
        pr_info("%s sip = %d.%d.%d.%d, tip=%d.%d.%d.%d, ipv4=%d.%d.%d.%d\n", netdev_name(net),
            sip[0], sip[1], sip[2], sip[3], tip[0], tip[1], tip[2], tip[3], ipv4[0], ipv4[1], ipv4[2], ipv4[3]);
    //wwan0 sip = 10.151.137.255, tip=10.151.138.0, ipv4=10.151.137.255
        if (tip[0] == ipv4[0] && tip[1] == ipv4[1] && (tip[2]&0xFC) == (ipv4[2]&0xFC) && tip[3] != ipv4[3])
            reply = arp_create(ARPOP_REPLY, ETH_P_ARP, *((__be32 *)sip), net, *((__be32 *)tip), sha, default_modem_addr, sha);
 
        if (reply) {
            skb_reset_mac_header(reply);
            __skb_pull(reply, skb_network_offset(reply));
            reply->ip_summed = CHECKSUM_UNNECESSARY;
            reply->pkt_type = PACKET_HOST;
 
            netif_rx_ni(reply);
        }
        return 1;
    }
 
    return 0;
}
 
static struct sk_buff *bridge_mode_tx_fixup(struct net_device *net, struct sk_buff *skb, uint bridge_ipv4, unsigned char *bridge_mac) {
    struct ethhdr *ehdr;
    const struct iphdr *iph;
    
    skb_reset_mac_header(skb);
    ehdr = eth_hdr(skb);    
 
    if (ehdr->h_proto == htons(ETH_P_ARP)) {
        if (bridge_ipv4)
            bridge_arp_reply(net, skb, bridge_ipv4);
        return NULL;
    }
 
    iph = ip_hdr(skb);
    //DBG("iphdr: ");
    //PrintHex((void *)iph, sizeof(struct iphdr));
 
// 1    0.000000000    0.0.0.0    255.255.255.255    DHCP    362    DHCP Request  - Transaction ID 0xe7643ad7        
    if (ehdr->h_proto == htons(ETH_P_IP) && iph->protocol == IPPROTO_UDP && iph->saddr == 0x00000000 && iph->daddr == 0xFFFFFFFF) {
        //if (udp_hdr(skb)->dest == htons(67)) //DHCP Request
        {
            memcpy(bridge_mac, ehdr->h_source, ETH_ALEN);
            pr_info("%s PC Mac Address: %02x:%02x:%02x:%02x:%02x:%02x\n", netdev_name(net),
                bridge_mac[0], bridge_mac[1], bridge_mac[2], bridge_mac[3], bridge_mac[4], bridge_mac[5]);
        }
    }
        
    if (memcmp(ehdr->h_source, bridge_mac, ETH_ALEN)) {
        return NULL;
    }
 
    return skb;
}
#endif
 
#if defined(QUECTEL_WWAN_QMAP)
static ssize_t qmap_mode_show(struct device *dev, struct device_attribute *attr, char *buf) {
    struct net_device *netdev = to_net_dev(dev);
    struct usbnet * usbnetdev = netdev_priv( netdev );
    struct qmi_wwan_state *info = (void *)&usbnetdev->data;
    sQmiWwanQmap *pQmapDev = (sQmiWwanQmap *)info->unused;
 
    return snprintf(buf, PAGE_SIZE, "%d\n",  pQmapDev->qmap_mode);
}
 
static DEVICE_ATTR(qmap_mode, S_IRUGO, qmap_mode_show, NULL);
 
static ssize_t link_state_show(struct device *dev, struct device_attribute *attr, char *buf) {
    struct net_device *netdev = to_net_dev(dev);
    struct usbnet * usbnetdev = netdev_priv( netdev );
    struct qmi_wwan_state *info = (void *)&usbnetdev->data;
    sQmiWwanQmap *pQmapDev = (sQmiWwanQmap *)info->unused;
 
    return snprintf(buf, PAGE_SIZE, "0x%x\n",  pQmapDev->link_state);
}
 
static ssize_t link_state_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) {
    struct net_device *netdev = to_net_dev(dev);
    struct usbnet * usbnetdev = netdev_priv( netdev );
    struct qmi_wwan_state *info = (void *)&usbnetdev->data;
    sQmiWwanQmap *pQmapDev = (sQmiWwanQmap *)info->unused;
    unsigned link_state = 0;
    unsigned old_link = pQmapDev->link_state;
 
    link_state = simple_strtoul(buf, NULL, 0);
    if (pQmapDev->qmap_mode == 1)
        pQmapDev->link_state = !!link_state;
    else if (pQmapDev->qmap_mode > 1) {
        if (0 < link_state && link_state <= pQmapDev->qmap_mode)
            pQmapDev->link_state |= (1 << (link_state - 1));
        else if (0x80 < link_state && link_state <= (0x80 + pQmapDev->qmap_mode))
            pQmapDev->link_state &= ~(1 << ((link_state&0xF) - 1));
    }
 
    if (old_link != pQmapDev->link_state)
        dev_info(dev, "link_state 0x%x -> 0x%x\n", old_link, pQmapDev->link_state);
 
    return count;
}
 
#ifdef QUECTEL_BRIDGE_MODE
static ssize_t bridge_mode_show(struct device *dev, struct device_attribute *attr, char *buf) {
    struct net_device *netdev = to_net_dev(dev);
    uint bridge_mode = 0;
 
    if (is_qmap_netdev(netdev)) {
        struct qmap_priv *priv = netdev_priv(netdev);
        bridge_mode = priv->bridge_mode;    
    }
    else {
        struct usbnet * usbnetdev = netdev_priv( netdev );
        struct qmi_wwan_state *info = (void *)&usbnetdev->data;
        sQmiWwanQmap *pQmapDev = (sQmiWwanQmap *)info->unused;
        bridge_mode = pQmapDev->bridge_mode;
    }
 
    return snprintf(buf, PAGE_SIZE, "%u\n", bridge_mode);
}
 
static ssize_t bridge_ipv4_show(struct device *dev, struct device_attribute *attr, char *buf) {
    struct net_device *netdev = to_net_dev(dev);
    unsigned int bridge_ipv4 = 0;
    unsigned char ipv4[4];
 
    if (is_qmap_netdev(netdev)) {
        struct qmap_priv *priv = netdev_priv(netdev);
        bridge_ipv4 = priv->bridge_ipv4;    
    }
    else {
        struct usbnet * usbnetdev = netdev_priv( netdev );
        struct qmi_wwan_state *info = (void *)&usbnetdev->data;
        sQmiWwanQmap *pQmapDev = (sQmiWwanQmap *)info->unused;
        bridge_ipv4 = pQmapDev->bridge_ipv4;    
    }
 
    ipv4[0]  = (bridge_ipv4 >> 24) & 0xFF;
    ipv4[1]  = (bridge_ipv4 >> 16) & 0xFF;
    ipv4[2]  = (bridge_ipv4 >> 8) & 0xFF;
    ipv4[3]  = (bridge_ipv4 >> 0) & 0xFF;
    
    return snprintf(buf, PAGE_SIZE, "%d.%d.%d.%d\n",  ipv4[0], ipv4[1], ipv4[2], ipv4[3]);
}
 
static ssize_t bridge_ipv4_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) {
    struct net_device *netdev = to_net_dev(dev);
 
    if (is_qmap_netdev(netdev)) {
        struct qmap_priv *priv = netdev_priv(netdev);
        priv->bridge_ipv4 = simple_strtoul(buf, NULL, 16);
    }
    else {
        struct usbnet * usbnetdev = netdev_priv( netdev );
        struct qmi_wwan_state *info = (void *)&usbnetdev->data;
        sQmiWwanQmap *pQmapDev = (sQmiWwanQmap *)info->unused;
        pQmapDev->bridge_ipv4 = simple_strtoul(buf, NULL, 16);
    }
 
    return count;
}
#endif
 
static DEVICE_ATTR(link_state, S_IWUSR | S_IRUGO, link_state_show, link_state_store);
#ifdef QUECTEL_BRIDGE_MODE
static DEVICE_ATTR(bridge_mode,  S_IRUGO, bridge_mode_show, NULL);
static DEVICE_ATTR(bridge_ipv4, S_IWUSR | S_IRUGO, bridge_ipv4_show, bridge_ipv4_store);
#endif
 
static struct attribute *qmi_wwan_sysfs_attrs[] = {
    &dev_attr_link_state.attr,
    &dev_attr_qmap_mode.attr,
#ifdef QUECTEL_BRIDGE_MODE
    &dev_attr_bridge_mode.attr,
    &dev_attr_bridge_ipv4.attr,
#endif
    NULL,
};
 
static struct attribute_group qmi_wwan_sysfs_attr_group = {
    .attrs = qmi_wwan_sysfs_attrs,
};
 
#ifdef QUECTEL_BRIDGE_MODE
static struct attribute *qmi_qmap_sysfs_attrs[] = {
    &dev_attr_bridge_mode.attr,
    &dev_attr_bridge_ipv4.attr,
    NULL,
};
 
static struct attribute_group qmi_qmap_sysfs_attr_group = {
    .attrs = qmi_qmap_sysfs_attrs,
};
#endif
 
static int qmap_open(struct net_device *dev)
{
    struct qmap_priv *priv = netdev_priv(dev);
    struct net_device *real_dev = priv->real_dev;
 
    if (!(priv->real_dev->flags & IFF_UP))
        return -ENETDOWN;
 
    if (netif_carrier_ok(real_dev))
        netif_carrier_on(dev);
    return 0;
}
 
static int qmap_stop(struct net_device *pNet)
{
    netif_carrier_off(pNet);
    return 0;
}
 
static int qmap_start_xmit(struct sk_buff *skb, struct net_device *pNet)
{
    int err;
    struct qmap_priv *priv = netdev_priv(pNet);
    unsigned int len;
    struct qmap_hdr *hdr;
 
    skb_reset_mac_header(skb);
 
#ifdef QUECTEL_BRIDGE_MODE
    if (priv->bridge_mode && bridge_mode_tx_fixup(pNet, skb, priv->bridge_ipv4, priv->bridge_mac) == NULL) {
          dev_kfree_skb_any (skb);
          return NETDEV_TX_OK;
    }
#endif
 
    if (skb_pull(skb, ETH_HLEN) == NULL) {
          dev_kfree_skb_any (skb);
          return NETDEV_TX_OK;
       }
   
    len = skb->len;
    hdr = (struct qmap_hdr *)skb_push(skb, sizeof(struct qmap_hdr));
    hdr->cd_rsvd_pad = 0;
    hdr->mux_id = QUECTEL_QMAP_MUX_ID + priv->offset_id;
    hdr->pkt_len = cpu_to_be16(len);
 
    skb->dev = priv->real_dev;
    err = dev_queue_xmit(skb);
    if (err == NET_XMIT_SUCCESS) {
        pNet->stats.tx_packets++;
        pNet->stats.tx_bytes += skb->len;
    } else {
        pNet->stats.tx_errors++;
    }
 
    return err;
}
 
static const struct net_device_ops qmap_netdev_ops = {
    .ndo_open       = qmap_open,
    .ndo_stop       = qmap_stop,
    .ndo_start_xmit = qmap_start_xmit,
};
 
static int qmap_register_device(sQmiWwanQmap * pDev, u8 offset_id)
{
    struct net_device *real_dev = pDev->mpNetDev->net;
    struct net_device *qmap_net;
    struct qmap_priv *priv;
    int err;
 
    qmap_net = alloc_etherdev(sizeof(*priv));
    if (!qmap_net)
        return -ENOBUFS;
 
    SET_NETDEV_DEV(qmap_net, &real_dev->dev);
    priv = netdev_priv(qmap_net);
    priv->offset_id = offset_id;
    priv->real_dev = real_dev;
    sprintf(qmap_net->name, "%s.%d", real_dev->name, offset_id + 1);
    qmap_net->netdev_ops = &qmap_netdev_ops;
    memcpy (qmap_net->dev_addr, real_dev->dev_addr, ETH_ALEN);
 
#ifdef QUECTEL_BRIDGE_MODE
    priv->bridge_mode = !!(pDev->bridge_mode & BIT(offset_id));
    qmap_net->sysfs_groups[0] = &qmi_qmap_sysfs_attr_group;
#endif
 
    err = register_netdev(qmap_net);
    if (err < 0)
        goto out_free_newdev;
    netif_device_attach (qmap_net);
 
    pDev->mpQmapNetDev[offset_id] = qmap_net;
    qmap_net->flags |= IFF_NOARP;
 
    dev_info(&real_dev->dev, "%s %s\n", __func__, qmap_net->name);
 
    return 0;
 
out_free_newdev:
    free_netdev(qmap_net);
    return err;
}
 
static void qmap_unregister_device(sQmiWwanQmap * pDev, u8 offset_id) {
    struct net_device *net = pDev->mpQmapNetDev[offset_id];
    if (net != NULL) {
        netif_carrier_off( net );
        unregister_netdev (net);
        free_netdev(net);
    }
}
 
#ifdef CONFIG_ANDROID
static int qmap_ndo_do_ioctl(struct net_device *dev,struct ifreq *ifr, int cmd) {
    int rc = -EOPNOTSUPP;
    uint link_state = 0;
 
    switch (cmd) {
    case 0x89F1: //SIOCDEVPRIVATE
        rc = copy_from_user(&link_state, ifr->ifr_ifru.ifru_data, sizeof(link_state));
        if (!rc) {
            char buf[32];
            snprintf(buf, sizeof(buf), "%u", link_state);
            link_state_store(&dev->dev, NULL, buf, strlen(buf));
        }
    break;
 
    default:
    break;
    }
 
    return rc;
}
#endif
 
#ifdef QUECTEL_BRIDGE_MODE
static int is_qmap_netdev(const struct net_device *netdev) {
    return netdev->netdev_ops == &qmap_netdev_ops;
}
#endif
#endif
 
static struct sk_buff *qmi_wwan_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags) {
    //MDM9x07,MDM9628,MDM9x40,SDX20,SDX24 only work on RAW IP mode
    if ((dev->driver_info->flags & FLAG_NOARP) == 0)
        return skb;
 
    // Skip Ethernet header from message
    if (dev->net->hard_header_len == 0)
        return skb;
    else
        skb_reset_mac_header(skb);
 
#ifdef QUECTEL_BRIDGE_MODE
{
    struct qmi_wwan_state *info = (void *)&dev->data;
    sQmiWwanQmap *pQmapDev = (sQmiWwanQmap *)info->unused;
 
    if (pQmapDev->bridge_mode && bridge_mode_tx_fixup(dev->net, skb, pQmapDev->bridge_ipv4, pQmapDev->bridge_mac) == NULL) {
          dev_kfree_skb_any (skb);
          return NULL;
    }
}
#endif
 
    if (skb_pull(skb, ETH_HLEN)) {
        return skb;
    } else {
        dev_err(&dev->intf->dev,  "Packet Dropped ");
    }
 
    // Filter the packet out, release it
    dev_kfree_skb_any(skb);
    return NULL;
}
#endif
 
/* Make up an ethernet header if the packet doesn't have one.
 *
 * A firmware bug common among several devices cause them to send raw
 * IP packets under some circumstances.  There is no way for the
 * driver/host to know when this will happen.  And even when the bug
 * hits, some packets will still arrive with an intact header.
 *
 * The supported devices are only capably of sending IPv4, IPv6 and
 * ARP packets on a point-to-point link. Any packet with an ethernet
 * header will have either our address or a broadcast/multicast
 * address as destination.  ARP packets will always have a header.
 *
 * This means that this function will reliably add the appropriate
 * header iff necessary, provided our hardware address does not start
 * with 4 or 6.
 *
 * Another common firmware bug results in all packets being addressed
 * to 00:a0:c6:00:00:00 despite the host address being different.
 * This function will also fixup such packets.
 */
static int qmi_wwan_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
{
    __be16 proto;
#ifdef QUECTEL_BRIDGE_MODE
    struct qmi_wwan_state *info = (void *)&dev->data;
    sQmiWwanQmap *pQmapDev = (sQmiWwanQmap *)info->unused;
#endif
    
    /* This check is no longer done by usbnet */
    if (skb->len < dev->net->hard_header_len)
        return 0;
 
    switch (skb->data[0] & 0xf0) {
    case 0x40:
        proto = htons(ETH_P_IP);
        break;
    case 0x60:
        proto = htons(ETH_P_IPV6);
        break;
    case 0x00:
        if (is_multicast_ether_addr(skb->data))
            return 1;
        /* possibly bogus destination - rewrite just in case */
        skb_reset_mac_header(skb);
        goto fix_dest;
    default:
        /* pass along other packets without modifications */
        return 1;
    }
    if (skb_headroom(skb) < ETH_HLEN)
        return 0;
    skb_push(skb, ETH_HLEN);
    skb_reset_mac_header(skb);
    eth_hdr(skb)->h_proto = proto;
    memset(eth_hdr(skb)->h_source, 0, ETH_ALEN);
#if 1 //Added by Quectel
    //some kernel will drop ethernet packet which's souce mac is all zero
    memcpy(eth_hdr(skb)->h_source, default_modem_addr, ETH_ALEN);
#endif
#ifdef QUECTEL_BRIDGE_MODE    
    if (pQmapDev->bridge_mode) {
        memcpy(eth_hdr(skb)->h_dest, pQmapDev->bridge_mac, ETH_ALEN);
    }
#endif
 
fix_dest:
    memcpy(eth_hdr(skb)->h_dest, dev->net->dev_addr, ETH_ALEN);
    return 1;
}
 
#if defined(QUECTEL_WWAN_QMAP)
static struct sk_buff *qmap_qmi_wwan_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags) {
    struct qmi_wwan_state *info = (void *)&dev->data;
    sQmiWwanQmap *pQmapDev = (sQmiWwanQmap *)info->unused;
    struct qmap_hdr *qhdr;
 
    if (unlikely(pQmapDev == NULL)) {
        goto drop_skb;
    } else if (unlikely(pQmapDev->qmap_mode && !pQmapDev->link_state)) {
        dev_dbg(&dev->net->dev, "link_state 0x%x, drop skb, len = %u\n", pQmapDev->link_state, skb->len);
        goto drop_skb;
    } else if (pQmapDev->qmap_mode == 0) {
        return qmi_wwan_tx_fixup(dev, skb, flags);
    }
    else if (pQmapDev->qmap_mode > 1) {
        qhdr = (struct qmap_hdr *)skb->data;
        if (qhdr->cd_rsvd_pad != 0) {
            goto drop_skb;
        }
        if ((qhdr->mux_id&0xF0) != 0x80) {
            goto drop_skb;
        }
        return skb;
    }
    else {
        if (qmi_wwan_tx_fixup(dev, skb, flags)) {
            qhdr = (struct qmap_hdr *)skb_push(skb, sizeof(struct qmap_hdr));
            qhdr->cd_rsvd_pad = 0;
            qhdr->mux_id = QUECTEL_QMAP_MUX_ID;
            qhdr->pkt_len = cpu_to_be16(skb->len - sizeof(struct qmap_hdr));
 
                    return skb;
        }
        else {
            return NULL;
        }
    }
 
drop_skb:
    dev_kfree_skb_any (skb);
    return NULL;
}
 
static int qmap_qmi_wwan_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
{
    struct qmi_wwan_state *info = (void *)&dev->data;
    sQmiWwanQmap *pQmapDev = (sQmiWwanQmap *)info->unused;
    static int debug_len = 0;
    int debug_pkts = 0;
    int update_len = skb->len;
 
    if (pQmapDev->qmap_mode == 0)
        return qmi_wwan_rx_fixup(dev, skb);
 
    while (skb->len > sizeof(struct qmap_hdr)) {
        struct qmap_hdr *qhdr = (struct qmap_hdr *)skb->data;
        struct net_device *qmap_net;
        struct sk_buff *qmap_skb;
#ifdef QUECTEL_BRIDGE_MODE
        uint bridge_mode = 0;
        unsigned char *bridge_mac;
#endif
        __be16 proto;
        int pkt_len;
        u8 offset_id = 0;
        int err;
        unsigned len = (be16_to_cpu(qhdr->pkt_len) + sizeof(struct qmap_hdr));
 
        if (skb->len < (be16_to_cpu(qhdr->pkt_len) + sizeof(struct qmap_hdr))) {
            dev_info(&dev->net->dev, "drop qmap unknow pkt, len=%d, pkt_len=%d\n", skb->len, be16_to_cpu(qhdr->pkt_len));
            goto out;
        }
 
        debug_pkts++;
 
        if (qhdr->cd_rsvd_pad & 0x80) {
            dev_info(&dev->net->dev, "drop qmap command packet %x\n", qhdr->cd_rsvd_pad);
            goto skip_pkt;;
        }
 
        offset_id = qhdr->mux_id - QUECTEL_QMAP_MUX_ID;
        if (offset_id >= pQmapDev->qmap_mode) {
            dev_info(&dev->net->dev, "drop qmap unknow mux_id %x\n", qhdr->mux_id);
            goto skip_pkt;
        }
 
        qmap_net = pQmapDev->mpQmapNetDev[offset_id];
 
        if (qmap_net == NULL) {
            dev_info(&dev->net->dev, "drop qmap unknow mux_id %x\n", qhdr->mux_id);
            goto skip_pkt;
        }
 
        switch (skb->data[sizeof(struct qmap_hdr)] & 0xf0) {
            case 0x40:
                proto = htons(ETH_P_IP);
            break;
            case 0x60:
                proto = htons(ETH_P_IPV6);
            break;
            default:
                goto skip_pkt;
        }
 
        pkt_len = be16_to_cpu(qhdr->pkt_len) - (qhdr->cd_rsvd_pad&0x3F);
        qmap_skb = netdev_alloc_skb(qmap_net, ETH_HLEN + pkt_len);
        if (qmap_skb == NULL) {
            dev_info(&dev->net->dev, "fail to alloc skb, pkt_len = %d\n", pkt_len);
            return 0;
        }
 
        skb_reset_mac_header(qmap_skb);
        memcpy(eth_hdr(qmap_skb)->h_source, default_modem_addr, ETH_ALEN);
        memcpy(eth_hdr(qmap_skb)->h_dest, qmap_net->dev_addr, ETH_ALEN);
        eth_hdr(qmap_skb)->h_proto = proto;        
        memcpy(skb_put(qmap_skb, ETH_HLEN + pkt_len) + ETH_HLEN, skb->data + sizeof(struct qmap_hdr), pkt_len);
#ifdef QUECTEL_BRIDGE_MODE
        if (pQmapDev->qmap_mode > 1) {
            struct qmap_priv *priv = netdev_priv(qmap_net);
            bridge_mode = priv->bridge_mode;
            bridge_mac = priv->bridge_mac;
        }
        else {
            bridge_mode = pQmapDev->bridge_mode;
            bridge_mac = pQmapDev->bridge_mac;
        }
            if (bridge_mode) {
                memcpy(eth_hdr(qmap_skb)->h_dest, bridge_mac, ETH_ALEN);
            }
#endif
 
        if (pQmapDev->qmap_mode > 1) {
            qmap_skb->protocol = eth_type_trans (qmap_skb, qmap_net);
            memset(qmap_skb->cb, 0, sizeof(struct skb_data));
            err = netif_rx(qmap_skb);
            if (err == NET_RX_SUCCESS) {
                qmap_net->stats.rx_packets++;
                qmap_net->stats.rx_bytes += qmap_skb->len;
            } else {
                qmap_net->stats.rx_errors++;
            }
        }
        else {
            usbnet_skb_return(dev, qmap_skb);
        }
 
        skip_pkt:
        skb_pull(skb, len);
    }
 
out:
    if (update_len > debug_len) {
        debug_len = update_len;
        dev_info(&dev->net->dev, "rx_pkts=%d, rx_len=%d\n", debug_pkts, debug_len);
    }
    
    return 0;
}
#endif
 
/* very simplistic detection of IPv4 or IPv6 headers */
static bool possibly_iphdr(const char *data)
{
    return (data[0] & 0xd0) == 0x40;
}
 
/* disallow addresses which may be confused with IP headers */
static int qmi_wwan_mac_addr(struct net_device *dev, void *p)
{
    int ret;
    struct sockaddr *addr = p;
 
    ret = eth_prepare_mac_addr_change(dev, p);
    if (ret < 0)
        return ret;
    if (possibly_iphdr(addr->sa_data))
        return -EADDRNOTAVAIL;
    eth_commit_mac_addr_change(dev, p);
    return 0;
}
 
static const struct net_device_ops qmi_wwan_netdev_ops = {
    .ndo_open        = usbnet_open,
    .ndo_stop        = usbnet_stop,
    .ndo_start_xmit        = usbnet_start_xmit,
    .ndo_tx_timeout        = usbnet_tx_timeout,
    .ndo_change_mtu        = usbnet_change_mtu,
    .ndo_set_mac_address    = qmi_wwan_mac_addr,
    .ndo_validate_addr    = eth_validate_addr,
#if defined(QUECTEL_WWAN_QMAP) && defined(CONFIG_ANDROID)
    .ndo_do_ioctl = qmap_ndo_do_ioctl,
#endif
};
 
/* using a counter to merge subdriver requests with our own into a
 * combined state
 */
static int qmi_wwan_manage_power(struct usbnet *dev, int on)
{
    struct qmi_wwan_state *info = (void *)&dev->data;
    int rv;
 
    dev_dbg(&dev->intf->dev, "%s() pmcount=%d, on=%d\n", __func__,
        atomic_read(&info->pmcount), on);
 
    if ((on && atomic_add_return(1, &info->pmcount) == 1) ||
        (!on && atomic_dec_and_test(&info->pmcount))) {
        /* need autopm_get/put here to ensure the usbcore sees
         * the new value
         */
        rv = usb_autopm_get_interface(dev->intf);
        dev->intf->needs_remote_wakeup = on;
        if (!rv)
            usb_autopm_put_interface(dev->intf);
    }
    return 0;
}
 
static int qmi_wwan_cdc_wdm_manage_power(struct usb_interface *intf, int on)
{
    struct usbnet *dev = usb_get_intfdata(intf);
 
    /* can be called while disconnecting */
    if (!dev)
        return 0;
    return qmi_wwan_manage_power(dev, on);
}
 
/* collect all three endpoints and register subdriver */
static int qmi_wwan_register_subdriver(struct usbnet *dev)
{
    int rv;
    struct usb_driver *subdriver = NULL;
    struct qmi_wwan_state *info = (void *)&dev->data;
 
    /* collect bulk endpoints */
    rv = usbnet_get_endpoints(dev, info->data);
    if (rv < 0)
        goto err;
 
    /* update status endpoint if separate control interface */
    if (info->control != info->data)
        dev->status = &info->control->cur_altsetting->endpoint[0];
 
    /* require interrupt endpoint for subdriver */
    if (!dev->status) {
        rv = -EINVAL;
        goto err;
    }
 
    /* for subdriver power management */
    atomic_set(&info->pmcount, 0);
 
    /* register subdriver */
    subdriver = usb_cdc_wdm_register(info->control, &dev->status->desc,
                     4096, &qmi_wwan_cdc_wdm_manage_power);
    if (IS_ERR(subdriver)) {
        dev_err(&info->control->dev, "subdriver registration failed\n");
        rv = PTR_ERR(subdriver);
        goto err;
    }
 
    /* prevent usbnet from using status endpoint */
    dev->status = NULL;
 
    /* save subdriver struct for suspend/resume wrappers */
    info->subdriver = subdriver;
 
err:
    return rv;
}
 
static int qmi_wwan_bind(struct usbnet *dev, struct usb_interface *intf)
{
    int status = -1;
    u8 *buf = intf->cur_altsetting->extra;
    int len = intf->cur_altsetting->extralen;
    struct usb_interface_descriptor *desc = &intf->cur_altsetting->desc;
    struct usb_cdc_union_desc *cdc_union = NULL;
    struct usb_cdc_ether_desc *cdc_ether = NULL;
    u32 found = 0;
    struct usb_driver *driver = driver_of(intf);
    struct qmi_wwan_state *info = (void *)&dev->data;
 
    BUILD_BUG_ON((sizeof(((struct usbnet *)0)->data) <
              sizeof(struct qmi_wwan_state)));
 
    /* set up initial state */
    info->control = intf;
    info->data = intf;
 
    /* and a number of CDC descriptors */
    while (len > 3) {
        struct usb_descriptor_header *h = (void *)buf;
 
        /* ignore any misplaced descriptors */
        if (h->bDescriptorType != USB_DT_CS_INTERFACE)
            goto next_desc;
 
        /* buf[2] is CDC descriptor subtype */
        switch (buf[2]) {
        case USB_CDC_HEADER_TYPE:
            if (found & 1 << USB_CDC_HEADER_TYPE) {
                dev_dbg(&intf->dev, "extra CDC header\n");
                goto err;
            }
            if (h->bLength != sizeof(struct usb_cdc_header_desc)) {
                dev_dbg(&intf->dev, "CDC header len %u\n",
                    h->bLength);
                goto err;
            }
            break;
        case USB_CDC_UNION_TYPE:
            if (found & 1 << USB_CDC_UNION_TYPE) {
                dev_dbg(&intf->dev, "extra CDC union\n");
                goto err;
            }
            if (h->bLength != sizeof(struct usb_cdc_union_desc)) {
                dev_dbg(&intf->dev, "CDC union len %u\n",
                    h->bLength);
                goto err;
            }
            cdc_union = (struct usb_cdc_union_desc *)buf;
            break;
        case USB_CDC_ETHERNET_TYPE:
            if (found & 1 << USB_CDC_ETHERNET_TYPE) {
                dev_dbg(&intf->dev, "extra CDC ether\n");
                goto err;
            }
            if (h->bLength != sizeof(struct usb_cdc_ether_desc)) {
                dev_dbg(&intf->dev, "CDC ether len %u\n",
                    h->bLength);
                goto err;
            }
            cdc_ether = (struct usb_cdc_ether_desc *)buf;
            break;
        }
 
        /* Remember which CDC functional descriptors we've seen.  Works
         * for all types we care about, of which USB_CDC_ETHERNET_TYPE
         * (0x0f) is the highest numbered
         */
        if (buf[2] < 32)
            found |= 1 << buf[2];
 
next_desc:
        len -= h->bLength;
        buf += h->bLength;
    }
 
    /* Use separate control and data interfaces if we found a CDC Union */
    if (cdc_union) {
        info->data = usb_ifnum_to_if(dev->udev,
                         cdc_union->bSlaveInterface0);
        if (desc->bInterfaceNumber != cdc_union->bMasterInterface0 ||
            !info->data) {
            dev_err(&intf->dev,
                "bogus CDC Union: master=%u, slave=%u\n",
                cdc_union->bMasterInterface0,
                cdc_union->bSlaveInterface0);
            goto err;
        }
    }
 
    /* errors aren't fatal - we can live with the dynamic address */
    if (cdc_ether) {
        dev->hard_mtu = le16_to_cpu(cdc_ether->wMaxSegmentSize);
        usbnet_get_ethernet_addr(dev, cdc_ether->iMACAddress);
    }
 
    /* claim data interface and set it up */
    if (info->control != info->data) {
        status = usb_driver_claim_interface(driver, info->data, dev);
        if (status < 0)
            goto err;
    }
 
    status = qmi_wwan_register_subdriver(dev);
    if (status < 0 && info->control != info->data) {
        usb_set_intfdata(info->data, NULL);
        usb_driver_release_interface(driver, info->data);
    }
 
    /* Never use the same address on both ends of the link, even
     * if the buggy firmware told us to.
     */
    if (ether_addr_equal(dev->net->dev_addr, default_modem_addr))
        eth_hw_addr_random(dev->net);
 
    /* make MAC addr easily distinguishable from an IP header */
    if (possibly_iphdr(dev->net->dev_addr)) {
        dev->net->dev_addr[0] |= 0x02;    /* set local assignment bit */
        dev->net->dev_addr[0] &= 0xbf;    /* clear "IP" bit */
    }
    dev->net->netdev_ops = &qmi_wwan_netdev_ops;
 
#if 1 //Added by Quectel
    if (dev->driver_info->flags & FLAG_NOARP) {        
        dev_info(&intf->dev, "Quectel EC25&EC21&EG91&EG95&EG06&EP06&EM06&EG12&EP12&EM12&EG16&EG18&BG96&AG35 work on RawIP mode\n");
        dev->net->flags |= IFF_NOARP;
        usb_control_msg(
            interface_to_usbdev(intf),
            usb_sndctrlpipe(interface_to_usbdev(intf), 0),
            0x22, //USB_CDC_REQ_SET_CONTROL_LINE_STATE
            0x21, //USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE
            1, //active CDC DTR
            intf->cur_altsetting->desc.bInterfaceNumber,
            NULL, 0, 100);
    }
 
    //to advoid module report mtu 1460, but rx 1500 bytes IP packets, and cause the customer's system crash
    //next setting can make usbnet.c:usbnet_change_mtu() do not modify rx_urb_size according to hard mtu
    dev->rx_urb_size = ETH_DATA_LEN + ETH_HLEN + 6;
 
#if defined(QUECTEL_WWAN_QMAP)
    if (qmap_mode > QUECTEL_WWAN_QMAP)
        qmap_mode = QUECTEL_WWAN_QMAP;
 
    if (!status)
    {
        sQmiWwanQmap *pQmapDev = (sQmiWwanQmap *)kzalloc(sizeof(sQmiWwanQmap), GFP_KERNEL);
 
        if (pQmapDev == NULL)
            return -ENODEV;
 
#ifdef QUECTEL_BRIDGE_MODE
        pQmapDev->bridge_mode = bridge_mode;
#endif
        pQmapDev->mpNetDev = dev;
        pQmapDev->link_state = 1;
        
        if (dev->driver_info->flags & FLAG_NOARP)
        {
            int idProduct = le16_to_cpu(dev->udev->descriptor.idProduct);
            int lte_a = (idProduct == 0x0306 || idProduct == 0x0512 || idProduct == 0x0620 || idProduct == 0x0800);
 
            pQmapDev->qmap_mode = qmap_mode;
            if (lte_a || dev->udev->speed == USB_SPEED_SUPER) {
                if (pQmapDev->qmap_mode == 0) {
                    pQmapDev->qmap_mode = 1; //force use QMAP
                    if(qmap_mode == 0)
                        qmap_mode = 1; //old quectel-CM only check sys/module/wwan0/parameters/qmap_mode
                }
            }
 
            if (pQmapDev->qmap_mode) {
                if (idProduct == 0x0121 || idProduct == 0x0125 || idProduct == 0x0435) //MDM9x07
                    dev->rx_urb_size = 4*1024;
                else if (lte_a || dev->udev->speed == USB_SPEED_SUPER)
                    dev->rx_urb_size = 32*1024;
                else
                    dev->rx_urb_size = 32*1024;
 
                //for these modules, if send pakcet before qmi_start_network, or cause host PC crash, or cause modules crash
                if (lte_a || dev->udev->speed == USB_SPEED_SUPER)
                    pQmapDev->link_state = 0;
            }
        }
 
        info->unused = (unsigned long)pQmapDev;        
        dev->net->sysfs_groups[0] = &qmi_wwan_sysfs_attr_group;
 
        dev_info(&intf->dev, "rx_urb_size = %zd\n", dev->rx_urb_size);
    }
#endif
#endif
 
err:
    return status;
}
 
static void qmi_wwan_unbind(struct usbnet *dev, struct usb_interface *intf)
{
    struct qmi_wwan_state *info = (void *)&dev->data;
    struct usb_driver *driver = driver_of(intf);
    struct usb_interface *other;
 
    if (info->subdriver && info->subdriver->disconnect)
        info->subdriver->disconnect(info->control);
 
    /* allow user to unbind using either control or data */
    if (intf == info->control)
        other = info->data;
    else
        other = info->control;
 
    /* only if not shared */
    if (other && intf != other) {
        usb_set_intfdata(other, NULL);
        usb_driver_release_interface(driver, other);
    }
 
    info->subdriver = NULL;
    info->data = NULL;
    info->control = NULL;
}
 
/* suspend/resume wrappers calling both usbnet and the cdc-wdm
 * subdriver if present.
 *
 * NOTE: cdc-wdm also supports pre/post_reset, but we cannot provide
 * wrappers for those without adding usbnet reset support first.
 */
static int qmi_wwan_suspend(struct usb_interface *intf, pm_message_t message)
{
    struct usbnet *dev = usb_get_intfdata(intf);
    struct qmi_wwan_state *info = (void *)&dev->data;
    int ret;
 
    /* Both usbnet_suspend() and subdriver->suspend() MUST return 0
     * in system sleep context, otherwise, the resume callback has
     * to recover device from previous suspend failure.
     */
    ret = usbnet_suspend(intf, message);
    if (ret < 0)
        goto err;
 
    if (intf == info->control && info->subdriver &&
        info->subdriver->suspend)
        ret = info->subdriver->suspend(intf, message);
    if (ret < 0)
        usbnet_resume(intf);
err:
    return ret;
}
 
static int qmi_wwan_resume(struct usb_interface *intf)
{
    struct usbnet *dev = usb_get_intfdata(intf);
    struct qmi_wwan_state *info = (void *)&dev->data;
    int ret = 0;
    bool callsub = (intf == info->control && info->subdriver &&
            info->subdriver->resume);
 
    if (callsub)
        ret = info->subdriver->resume(intf);
    if (ret < 0)
        goto err;
    ret = usbnet_resume(intf);
    if (ret < 0 && callsub)
        info->subdriver->suspend(intf, PMSG_SUSPEND);
err:
    return ret;
}
 
static int qmi_wwan_reset_resume(struct usb_interface *intf)
{
    dev_info(&intf->dev, "device do not support reset_resume\n");
    intf->needs_binding = 1;
    return -EOPNOTSUPP;
}
 
static const struct driver_info    qmi_wwan_info = {
    .description    = "WWAN/QMI device",
    .flags        = FLAG_WWAN,
    .bind        = qmi_wwan_bind,
    .unbind        = qmi_wwan_unbind,
    .manage_power    = qmi_wwan_manage_power,
    .rx_fixup       = qmi_wwan_rx_fixup,
};
 
static const struct driver_info qmi_wwan_raw_ip_info = {
    .description    = "WWAN/QMI device",
    .flags        = FLAG_WWAN | FLAG_RX_ASSEMBLE | FLAG_NOARP | FLAG_SEND_ZLP,
    .bind        = qmi_wwan_bind,
    .unbind        = qmi_wwan_unbind,
    .manage_power    = qmi_wwan_manage_power,
#if defined(QUECTEL_WWAN_QMAP)
    .tx_fixup       = qmap_qmi_wwan_tx_fixup,
    .rx_fixup       = qmap_qmi_wwan_rx_fixup,
#else
    .tx_fixup       = qmi_wwan_tx_fixup,
    .rx_fixup       = qmi_wwan_rx_fixup,
#endif
};
 
 
/* map QMI/wwan function by a fixed interface number */
#define QMI_FIXED_INTF(vend, prod, num) \
    USB_DEVICE_INTERFACE_NUMBER(vend, prod, num), \
    .driver_info = (unsigned long)&qmi_wwan_info
 
#define QMI_FIXED_RAWIP_INTF(vend, prod, num) \
    USB_DEVICE_INTERFACE_NUMBER(vend, prod, num), \
    .driver_info = (unsigned long)&qmi_wwan_raw_ip_info
 
static const struct usb_device_id products[] = {
#if 1 //Added by Quectel
    { QMI_FIXED_INTF(0x05C6, 0x9003, 4) },  /* Quectel UC20 */
    { QMI_FIXED_INTF(0x05C6, 0x9215, 4) },  /* Quectel EC20 (MDM9215) */
    { QMI_FIXED_RAWIP_INTF(0x2C7C, 0x0125, 4) },  /* Quectel EC20 (MDM9X07)/EC25/EG25 */
    { QMI_FIXED_RAWIP_INTF(0x2C7C, 0x0121, 4) },  /* Quectel EC21 */
    { QMI_FIXED_RAWIP_INTF(0x2C7C, 0x0191, 4) },  /* Quectel EG91 */
    { QMI_FIXED_RAWIP_INTF(0x2C7C, 0x0195, 4) },  /* Quectel EG95 */
    { QMI_FIXED_RAWIP_INTF(0x2C7C, 0x0306, 4) },  /* Quectel EG06/EP06/EM06 */
    { QMI_FIXED_RAWIP_INTF(0x2C7C, 0x0512, 4) },  /* Quectel EG12/EP12/EM12/EG16/EG18 */
    { QMI_FIXED_RAWIP_INTF(0x2C7C, 0x0296, 4) },  /* Quectel BG96 */
    { QMI_FIXED_RAWIP_INTF(0x2C7C, 0x0435, 4) },  /* Quectel AG35 */
    { QMI_FIXED_RAWIP_INTF(0x2C7C, 0x0620, 4) },  /* Quectel EG20 */
    { QMI_FIXED_RAWIP_INTF(0x2C7C, 0x0800, 4) },  /* Quectel RG500 */
#endif
    { }                    /* END */
};
MODULE_DEVICE_TABLE(usb, products);
 
static int qmi_wwan_probe(struct usb_interface *intf,
              const struct usb_device_id *prod)
{
    struct usb_device_id *id = (struct usb_device_id *)prod;
 
    /* Workaround to enable dynamic IDs.  This disables usbnet
     * blacklisting functionality.  Which, if required, can be
     * reimplemented here by using a magic "blacklist" value
     * instead of 0 in the static device id table
     */
    if (!id->driver_info) {
        dev_dbg(&intf->dev, "setting defaults for dynamic device id\n");
        id->driver_info = (unsigned long)&qmi_wwan_info;
    }
 
    if (intf->cur_altsetting->desc.bInterfaceClass != 0xff) {
        dev_info(&intf->dev,  "Quectel module not qmi_wwan mode! please check 'at+qcfg=\"usbnet\"'\n");
        return -ENODEV;
    }
 
    return usbnet_probe(intf, id);
}
 
#if defined(QUECTEL_WWAN_QMAP)
static int qmap_qmi_wwan_probe(struct usb_interface *intf,
              const struct usb_device_id *prod)
{
    int status = qmi_wwan_probe(intf, prod);
    
    if (!status) {
        struct usbnet *dev = usb_get_intfdata(intf);
        struct qmi_wwan_state *info = (void *)&dev->data;        
        sQmiWwanQmap *pQmapDev = (sQmiWwanQmap *)info->unused;
        unsigned i;
 
        if (pQmapDev) {
            if (pQmapDev->qmap_mode == 1) {
                pQmapDev->mpQmapNetDev[0] = dev->net;
            }
            else if (pQmapDev->qmap_mode > 1) {
                for (i = 0; i < pQmapDev->qmap_mode; i++) {
                    qmap_register_device(pQmapDev, i);
                }
            }
        }
    }
 
    return status;
}
 
static void qmap_qmi_wwan_disconnect(struct usb_interface *intf)
{
    struct usbnet *dev = usb_get_intfdata(intf);
    struct qmi_wwan_state *info = (void *)&dev->data;
    sQmiWwanQmap *pQmapDev = (sQmiWwanQmap *)info->unused;
 
    if (pQmapDev) {
        if (pQmapDev->qmap_mode > 1) {
            unsigned i;
 
            for (i = 0; i < pQmapDev->qmap_mode; i++) {
                qmap_unregister_device(pQmapDev, i);
            }    
        }
        
        kfree(pQmapDev);
    }
 
    usbnet_disconnect(intf);
}
#endif
 
static struct usb_driver qmi_wwan_driver = {
    .name              = "qmi_wwan_q",
    .id_table          = products,
    .probe              = qmi_wwan_probe,
#if defined(QUECTEL_WWAN_QMAP)
    .probe              = qmap_qmi_wwan_probe,
    .disconnect          = qmap_qmi_wwan_disconnect,
#else
    .probe              = qmi_wwan_probe,
    .disconnect          = usbnet_disconnect,
#endif
    .suspend          = qmi_wwan_suspend,
    .resume              =    qmi_wwan_resume,
    .reset_resume         = qmi_wwan_reset_resume,
    .supports_autosuspend = 1,
    .disable_hub_initiated_lpm = 1,
};
 
module_usb_driver(qmi_wwan_driver);
 
MODULE_AUTHOR("Bjørn Mork <bjorn@mork.no>");
MODULE_DESCRIPTION("Qualcomm MSM Interface (QMI) WWAN driver");
MODULE_LICENSE("GPL");
#define QUECTEL_WWAN_VERSION "Quectel_Linux&Android_QMI_WWAN_Driver_V1.1"
MODULE_VERSION(QUECTEL_WWAN_VERSION);

 


8、
Z:\rk3399-android-11\kernel\drivers\usb\serial\option.c

static int option_probe(struct usb_serial *serial,
            const struct usb_device_id *id)
{
    struct usb_interface_descriptor *iface_desc =
                &serial->interface->cur_altsetting->desc;
    unsigned long device_flags = id->driver_info;

    /*simcom*/
    if(serial->dev->descriptor.idVendor == SIMCOM_PRODUCT_VID_1E0E && 
       serial->dev->descriptor.idProduct == SIMCOM_PRODUCT_PID_9001 && 
       serial->interface->cur_altsetting->desc.bInterfaceNumber >= 4)
        return -ENODEV;

    printk("idVendor:%x,idProduct:%x,bInterfaceNumber:%d\n",serial->dev->descriptor.idVendor,serial->dev->descriptor.idProduct,serial->interface->cur_altsetting->desc.bInterfaceNumber);
    if (serial->dev->descriptor.idVendor == QUECTEL_VENDOR_ID && 
            serial->dev->descriptor.idProduct == QUECTEL_PRODUCT_EC25 &&
        serial->interface->cur_altsetting->desc.bInterfaceNumber >= 4)
        return -ENODEV;

    printk("ckkkkkkkkkk\n");

    /* Never bind to the CD-Rom emulation interface    */
    if (iface_desc->bInterfaceClass == USB_CLASS_MASS_STORAGE)
        return -ENODEV;

    /*
     * Don't bind reserved interfaces (like network ones) which often have
     * the same class/subclass/protocol as the serial interfaces.  Look at
     * the Windows driver .INF files for reserved interface numbers.
     */
    if (iface_is_reserved(device_flags, iface_desc->bInterfaceNumber))
        return -ENODEV;

    /*
     * Allow matching on bNumEndpoints for devices whose interface numbers
     * can change (e.g. Quectel EP06).
     */
    if (device_flags & NUMEP2 && iface_desc->bNumEndpoints != 2)
        return -ENODEV;

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

    return 0;
}

【几乎没有改动】
Z:\rk3399-android-11\kernel\drivers\usb\serial\qcserial.c


Z:\rk3399-android-11\kernel\drivers\usb\serial\usb_wwan.c

static struct urb *usb_wwan_setup_urb(struct usb_serial_port *port,
                      int endpoint,
                      int dir, void *ctx, char *buf, int len,
                      void (*callback) (struct urb *))
{
    struct usb_serial *serial = port->serial;
    struct usb_wwan_intf_private *intfdata = usb_get_serial_data(serial);
    struct urb *urb;
    struct usb_device_descriptor *desc = &serial->dev->descriptor;

    urb = usb_alloc_urb(0, GFP_KERNEL);    /* No ISO */
    if (!urb)
        return NULL;

    usb_fill_bulk_urb(urb, serial->dev,
              usb_sndbulkpipe(serial->dev, endpoint) | dir,
              buf, len, callback, ctx);

    

    if (intfdata->use_zlp && dir == USB_DIR_OUT)
        urb->transfer_flags |= URB_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 (desc->idVendor == cpu_to_le16(0x2c7c))
            urb->transfer_flags |= URB_ZERO_PACKET;    

    }
    return urb;
}

修改为:
static struct urb *usb_wwan_setup_urb(struct usb_serial_port *port,
                      int endpoint,
                      int dir, void *ctx, char *buf, int len,
                      void (*callback) (struct urb *))
{
    struct usb_serial *serial = port->serial;
    struct usb_wwan_intf_private *intfdata = usb_get_serial_data(serial);
    struct urb *urb;
    struct usb_device_descriptor *desc = &serial->dev->descriptor;

    urb = usb_alloc_urb(0, GFP_KERNEL);    /* No ISO */
    if (!urb)
        return NULL;

    usb_fill_bulk_urb(urb, serial->dev,
              usb_sndbulkpipe(serial->dev, endpoint) | dir,
              buf, len, callback, ctx);

    if (intfdata->use_zlp && dir == USB_DIR_OUT)
        urb->transfer_flags |= URB_ZERO_PACKET;

    if (dir == USB_DIR_OUT) {
#define DEV_MATCH(udesc, vid, pid) \
    (udesc->idVendor == cpu_to_le16(vid) && desc->idProduct == cpu_to_le16(pid))
        if (DEV_MATCH(desc, 0x1286, 0x4e3c) ||
            DEV_MATCH(desc, 0x05C6, 0x9090) ||
            DEV_MATCH(desc, 0x05C6, 0x9003) ||
            DEV_MATCH(desc, 0x05C6, 0x9215) ||
            (desc->idVendor == cpu_to_le16(0x2C7C)))
            urb->transfer_flags |= URB_ZERO_PACKET;
#undef DEV_MATCH

    }

    return urb;
}


9、
Z:\rk3399-android-11\system\core\init\devices.cpp
void DeviceHandler::HandleUevent(const Uevent& uevent) {
    if (uevent.action == "add" || uevent.action == "change" || uevent.action == "online") {
        FixupSysPermissions(uevent.path, uevent.subsystem);
    }

    // if it's not a /dev device, nothing to do
    if (uevent.major < 0 || uevent.minor < 0) return;

    std::string devpath;
    std::vector<std::string> links;
    bool block = false;

    if (uevent.subsystem == "block") {
        block = true;
        devpath = "/dev/block/" + Basename(uevent.path);

        if (StartsWith(uevent.path, "/devices")) {
            links = GetBlockDeviceSymlinks(uevent);
        }
    } else if (const auto subsystem =
                   std::find(subsystems_.cbegin(), subsystems_.cend(), uevent.subsystem);
               subsystem != subsystems_.cend()) {
        devpath = subsystem->ParseDevPath(uevent);
    } else if (uevent.subsystem == "usb") {
        if (!uevent.device_name.empty()) {
            devpath = "/dev/" + uevent.device_name;
        } else {
            // This imitates the file system that would be created
            // if we were using devfs instead.
            // Minors are broken up into groups of 128, starting at "001"
            int bus_id = uevent.minor / 128 + 1;
            int device_id = uevent.minor % 128 + 1;
            devpath = StringPrintf("/dev/bus/usb/%03d/%03d", bus_id, device_id);
        }

    // add by quectel for mknod /dev/cdc-wdm0
    } else if (uevent.subsystem == "usbmisc" && !uevent.device_name.empty()) {
        devpath = "/dev/" + uevent.device_name;


    } else if (uevent.subsystem == "usbmisc" && !uevent.device_name.empty()) {
           devpath = "/dev/" + uevent.device_name;
           
           //PLOG(ERROR) << "Failed to symlink " << devpath << " to " << link << ", which already links to: " << link_path;
           PLOG(ERROR) << "2024/1/5 22:56 wenyuanbo " << devpath ;

    } else if (StartsWith(uevent.subsystem, "usb")) {
        // ignore other USB events
        return;
    } else {
        devpath = "/dev/" + Basename(uevent.path);
    }

    mkdir_recursive(Dirname(devpath), 0755);

    HandleDevice(uevent.action, devpath, block, uevent.major, uevent.minor, links);

    // Duplicate /dev/ashmem device and name it /dev/ashmem<boot_id>.
    // TODO(b/111903542): remove once all users of /dev/ashmem are migrated to libcutils API.
    HandleAshmemUevent(uevent);
}


参考资料:
https://download.csdn.net/download/seasonfangjing/86247556
RK356X android11 移远EC20 modem支持

对应工程设置BOARD_HAS_EC20_MODEM := true

device/rockchip/rk356x/itx68/BoardConfig.mk
BOARD_HAS_EC20_MODEM := true


system/core/init
diff --git a/init/devices.cpp b/init/devices.cpp
index 9fbec641b..e3c823d05 100644
--- a/init/devices.cpp
+++ b/init/devices.cpp
@@ -492,7 +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);
         }
-    } else if (StartsWith(uevent.subsystem, "usb")) {
+    } else if (uevent.subsystem == "usbmisc" && !uevent.device_name.empty()) {
+           devpath = "/dev/" + uevent.device_name;
+    }
+     else if (StartsWith(uevent.subsystem, "usb")) {
         // ignore other USB events
         return;
     } else {


device/rockchip
--- 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>


【可选参考】
https://blog.csdn.net/longmin96/article/details/122687865
RK3568-ANDROID11-4G-EC20-系统篇(移远模块)

【可选参考,需要会员下载库文件】
https://blog.csdn.net/yjz_0314/article/details/134142847
Android11.0系统中适配EC20模块4G及GPS功能


参考资料:
http://www.friendlyelec.com.cn/agent.asp
http://www.friendlyelec.com.cn/
https://download.friendlyelec.com/NanoPC-T4
https://wiki.friendlyelec.com/wiki/index.php/NanoPC-T4/zh#.E4.B8.8B.E8.BD.BDAndroid10.E6.BA.90.E4.BB.A3.E7.A0.81


https://item.taobao.com/item.htm?spm=a1z09.2.0.0.37562e8dcotDm6&id=570312633249&_u=7ju3ku004a
友善NanoPC-T4瑞芯微RK3399开发板ROS双摄4K播放开源AI智能安卓10

WiKi维基教程(固件介绍,使用说明,操作步骤等)
http://wiki.friendlyelec.com/wiki/index.php/NanoPC-T4
系统固件下载
https://dl.friendlyelec.com/nanopct4
原理图(pdf格式)
http://wiki.friendlyelec.com/wiki/images/e/e0/NanoPC-T4-1902-Schematic.pdf
尺寸图(dxf格式)
http://wiki.friendlyelec.com/wiki/images/b/bc/NanoPC-T4_1802_Drawing%28dxf%29.zip


http://www.friendlyelec.com.cn/nanopi-m4.asp
NanoPi M4 | NanoPi M4V2

https://wiki.friendlyelec.com/wiki/index.php/NanoPi_M4/zh
15.3 编译Android10源代码
15.3.1 下载Android10源代码
有以下两种途径获取 Android10 的源代码,都需要联网:

使用网盘里的git repo压缩包
网盘下载地址: 点击进入

https://download.friendlyelec.com/NanoPiM4
https://pan.baidu.com/share/init?surl=oBLn9H31hILJKEPQXgrUog
提取码:yn6r

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/235285.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

麦芯(MachCore)开发教程1 --- 设备软件中间件

黄国强 2024/1/10 acloud163.com 对任何公司来说&#xff0c;在短时间内开发一款高质量设备专用软件&#xff0c;是一件不太容易做到的事情。麦芯是笔者发明的一款设备软件中间件产品。麦芯致力于给设备厂商提供一个开发工具和平台&#xff0c;让客户快速高效的开发自己的设备专…

Android通过Recyclerview实现流式布局自适应列数及高度

调用 FlowAdapter 跟普通recyclerview一样使用 RecyclerView rvLayout holder.getView(R.id.spe_tag_layout); FlowAdapter rvAdapter new FlowAdapter(); FlowLayoutManager flowLayoutManager new FlowLayoutManager(); rvLayout.setLayoutManager(flowLayoutManager); r…

PHP开发日志 ━━ php8.3安装与使用组件Xdebug

今天开头写点历史&#xff1a; 二十年前流行asp&#xff0c;当时用vb整合常用函数库写了一个dll给asp调用&#xff0c;并在此基础上开发一套仿windows界面的后台管理系统&#xff1b;后来asp逐渐没落&#xff0c;于是在十多年前转投php&#xff0c;不久后用php写了一套mvc框架&…

CSS3实现轮播效果

在我们不使用JS的情况下&#xff0c;是否也可以实现轮播功能呢&#xff1f; 答应是可以的 上代码&#xff1a; <!DOCTYPE html> <html lang"en"> <head><meta charset"UTF-8"><title>轮播</title><style>.boss…

在 WinForms 应用程序中实现 FTP 文件操作及模式介绍

在 WinForms 应用程序中实现 FTP 文件操作及模式介绍 简介 在许多应用程序中&#xff0c;能够从远程服务器获取文件是一个非常有用的功能。本文将详细介绍如何在 Windows Forms (WinForms) 应用程序中使用 FTP 协议进行文件操作&#xff0c;包括连接到 FTP 服务器、列出目录、…

初识 Elasticsearch 应用知识,一文读懂 Elasticsearch 知识文集(2)

&#x1f3c6;作者简介&#xff0c;普修罗双战士&#xff0c;一直追求不断学习和成长&#xff0c;在技术的道路上持续探索和实践。 &#x1f3c6;多年互联网行业从业经验&#xff0c;历任核心研发工程师&#xff0c;项目技术负责人。 &#x1f389;欢迎 &#x1f44d;点赞✍评论…

《SPSS统计学基础与实证研究应用精解》视频讲解:SPSS的功能特色

《SPSS统计学基础与实证研究应用精解》1.2 SPSS的功能特色 视频为《SPSS统计学基础与实证研究应用精解》张甜 杨维忠著 清华大学出版社 一书的随书赠送视频讲解1.2节内容。本书已正式出版上市&#xff0c;当当、京东、淘宝等平台热销中&#xff0c;搜索书名即可。本书旨在手把手…

服务器感染了.pings勒索病毒,如何确保数据文件完整恢复?

导言&#xff1a; 随着科技的不断进步&#xff0c;网络犯罪也在不断演变。其中之一的.pings勒索病毒是一种危险的恶意软件&#xff0c;它能够加密用户的数据文件&#xff0c;并要求支付赎金以解密这些文件。在本文中&#xff0c;91数据恢复将介绍.pings勒索病毒&#xff0c;以…

React 基本使用

create-react-app 创建 react 项目的脚手架。 React 基本用法 jsx 语法 变量、表达式 import React from react;class JSXBaseDemo extends React.Component {constructor(props) {super(props);this.state {name: 章三};}render() {// 获取变量 插值const pElem <p&…

MR实战:网址去重

文章目录 一、实战概述二、提出任务三、完成任务&#xff08;一&#xff09;准备数据1、在虚拟机上创建文本文件2、上传文件到HDFS指定目录 &#xff08;二&#xff09;实现步骤1、创建Maven项目2、添加相关依赖3、创建日志属性文件4、创建网址去重映射器类5、创建网址去重归并…

【JaveWeb教程】(18) MySQL数据库开发之 MySQL数据库设计-DDL 如何查询、创建、使用、删除数据库数据表 详细代码示例讲解

目录 2. 数据库设计-DDL2.1 项目开发流程2.2 数据库操作2.2.1 查询数据库2.2.2 创建数据库2.2.3 使用数据库2.2.4 删除数据库 2.3 图形化工具2.3.1 介绍2.3.2 安装2.3.3 使用2.2.3.1 连接数据库2.2.3.2 操作数据库 2.3 表操作2.3.1 创建2.3.1.1 语法2.3.1.2 约束2.3.1.3 数据类…

Python爬虫之Scrapy框架系列(24)——分布式爬虫scrapy_redis完整实战【XXTop250完整爬取】

目录&#xff1a; 1.使用分布式爬取XX电影信息&#xff08;1&#xff09;settings.py文件中的配置&#xff1a;&#xff08;2&#xff09;spider文件的更改&#xff1a;&#xff08;3&#xff09;items.py文件&#xff08;两个项目一致&#xff01;&#xff09;&#xff1a;&am…

vue前端开发自学demo-input标签数据双向绑定

vue前端开发自学demo-input标签数据双向绑定&#xff01;今天为大家 展示的内容是&#xff0c;前端开发常见的&#xff0c;form表单里面的&#xff0c;一些输入数据的元素&#xff0c;动态绑定数据的案例。比如input,以及checkbox的状态绑定案例。 首先&#xff0c;老规矩&…

如何正确使用高速探头前端--probe head

目前市面上的高速有源探头种类丰富&#xff0c;使用灵活&#xff0c;如下图所示&#xff0c;结构多为放大器焊接前端的组合&#xff0c;以E2677B探头前端为例&#xff0c;其焊接前端电阻有三种选择&#xff0c;91ohm时可实现全带宽使用&#xff08;12GHz&#xff09;&#xff0…

从生活入手学编程(1):Edge浏览器设置自动刷新专业教程

一、前言 我们都知道&#xff0c;Edge浏览器运行时的速度卡的实在是感人…… 于是今天&#xff0c;我就突发奇想&#xff0c;来看一看怎么刷新并且还能保留页面内容。 二、探索 首先&#xff0c;我在此提醒您&#xff0c;在使用这种方法时要非常小心。因为更改网页源代…

面试算法110:所有路径

题目 一个有向无环图由n个节点&#xff08;标号从0到n-1&#xff0c;n≥2&#xff09;组成&#xff0c;请找出从节点0到节点n-1的所有路径。图用一个数组graph表示&#xff0c;数组的graph[i]包含所有从节点i能直接到达的节点。例如&#xff0c;输入数组graph为[[1&#xff0c…

直播预告丨看零售场,如何玩转 MaaS

今年&#xff0c;有一个被频繁提及的词是MaaS 这类工具正在帮助千行百业实现大模型落地产业 在零售场&#xff0c;特别是像京东这样拥有超高并发、超复杂协同的电商场内 也沉淀出了一套通用的AI基础设施——九数算法中台 从提升客户服务体验、平台效率出发&#xff0c;训练各…

【JVM】本地方法接口 Native Interface

一、JNI简介 JVM本地方法接口&#xff08;Java Native Interface&#xff0c;JNI&#xff09;是一种允许Java代码调用本地方法&#xff08;如C或C编写的方法&#xff09;的机制。这种技术通常用于实现高性能的计算密集型任务&#xff0c;或者与底层系统库进行交互。 二、JNI组…

华为面经总结

为了帮助大家更好的应对面试&#xff0c;我整理了往年华为校招面试的题目&#xff0c;供大家参考~ 面经1 技术一面 自我介绍说下项目中的难点volatile和synchronized的区别&#xff0c; 问的比较细大顶堆小顶堆怎么删除根节点CSRF攻击是什么&#xff0c;怎么预防线程通信方式…

CMU15-445-Spring-2023-Project #2 - B+Tree

前置知识&#xff1a;参考上一篇博文 CMU15-445-Spring-2023-Project #2 - 前置知识&#xff08;lec07-010&#xff09; CHECKPOINT #1 Task #1 - BTree Pages 实现三个page class来存储B树的数据。 BTree Page internal page和leaf page继承的基类&#xff0c;只包含两个…