Quectel EC200A-CN移植

文章详细介绍了QuectelEC200A-CN模块的USB转串口和USB网卡驱动的配置,包括内核选项设置、源码修改以识别设备的vid和pid,以及相应的测试步骤。在源码修改部分,提到了对option.c文件的多个部分进行修改以支持设备,并在usb_wwan_setup_urb函数中添加了URB_ZERO_PACKET标志。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一:usb转串口

usb-serial-option,USB转串口驱动,生产/dev/ttyUSB0-2,分别是DM,AT,PPP
需要使能内核选项如下:

CONFIG_USB_SERIAL=y
CONFIG_USB_SERIAL_WWAN=y
CONFIG_USB_SERIAL_OPTION=y

在这里插入图片描述
在这里插入图片描述

二:usb网卡驱动

USB网卡驱动,模块可通过AT配置成RNDIS或者ecm,默认是ecm。
需要使能内核选项

USB_USBNET=y
USB_NET_CDCETHER=y        #用ECM  使能此项
USB_NET_RNDIS_HOST=y      #用RNDIS 使能此项

在这里插入图片描述
在这里插入图片描述

三:源码修改

  1. 增加usb vid和pid
    增加vid和pid,设备连接,使用lsusb命令查看设备的vid和pid,如下图所示:
    在这里插入图片描述
vid:3763
pid:3c93

文件修改:linux-3.10/drivers/usb/serial/option.c

static const struct usb_device_id option_ids[] = {
#if 1 //Added by Quectel
        { USB_DEVICE(0x3763, 0x3c93) }, /* Quectel EC200A-CN 内置GPS */
        { USB_DEVICE(0x3c93, 0xffff) }, /* Quectel EC200A-CN 外置GPS*/
#endif

文件修改:linux-3.10/drivers/usb/serial/option.c

1790 #if 1 //Added by Quectel
1791 static void cfmakeraw(struct ktermios *t)
1792 {
1793         t->c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON);
1794         t->c_oflag &= ~OPOST;
1795         t->c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
1796         t->c_cflag &= ~(CSIZE|PARENB);
1797         t->c_cflag |= CS8;
1798         t->c_cc[VMIN] = 1;
1799         t->c_cc[VTIME] = 0;
1800 }
1801 
1802 static void option_init_termios(struct tty_struct *tty)
1803 {
1804         cfmakeraw(&tty->termios);
1805 }
1806 #endif

文件修改:linux-3.10/drivers/usb/serial/option.c:option_1port_device

1813 static struct usb_serial_driver option_1port_device = {
1814         .driver = {
1815                 .owner =        THIS_MODULE,
1816                 .name =         "option1",
1817         },
1818         .description       = "GSM modem (1-port)",
1819         .id_table          = option_ids,
1820         .num_ports         = 1,
1821         .probe             = option_probe,
1822         .open              = usb_wwan_open,
1823         .close             = usb_wwan_close,
1824         .dtr_rts           = usb_wwan_dtr_rts,
1825         .write             = usb_wwan_write,
1826         .write_room        = usb_wwan_write_room,
1827         .chars_in_buffer   = usb_wwan_chars_in_buffer,
1828         .set_termios       = usb_wwan_set_termios,
1829         .tiocmget          = usb_wwan_tiocmget,
1830         .tiocmset          = usb_wwan_tiocmset,
1831         .ioctl             = usb_wwan_ioctl,
1832         .attach            = option_attach,
1833         .release           = option_release,
1834         .port_probe        = usb_wwan_port_probe,
1835         .port_remove       = usb_wwan_port_remove,
1836         .read_int_callback = option_instat_callback,
1837 #ifdef CONFIG_PM
1838         .suspend           = usb_wwan_suspend,
1839         .resume            = usb_wwan_resume,
1840 #if 1 //Added by Quectel
1841         .reset_resume = usb_wwan_resume,
1842 #endif
1843 #endif
1844 };

文件修改:linux-3.10/drivers/usb/serial/option.c:option_probe

if (serial->dev->descriptor.idVendor == cpu_to_le16(0x3c93))
{
        __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;
        }
}
if (serial->dev->descriptor.idVendor == cpu_to_le16(0x3763))
{
        __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;
        }
}
  1. linux-3.10/drivers/usb/serial/usb_wwan.c:usb_wwan_setup_urb
    usb_wwan_setup_urb函数中添加如下内容
 //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(0x05C6) && desc->idProduct == cpu_to_le16(0x9090))
         urb->transfer_flags |= URB_ZERO_PACKET;
 if (desc->idVendor == cpu_to_le16(0x05C6) && desc->idProduct == cpu_to_le16(0x9003))
         urb->transfer_flags |= URB_ZERO_PACKET;
 if (desc->idVendor == cpu_to_le16(0x05C6) && desc->idProduct == cpu_to_le16(0x9215))
         urb->transfer_flags |= URB_ZERO_PACKET;
 if (desc->idVendor == cpu_to_le16(0x2C7C))
         urb->transfer_flags |= URB_ZERO_PACKET;
 if (desc->idVendor == cpu_to_le16(0x3c93))
         urb->transfer_flags |= URB_ZERO_PACKET;
 if (desc->idVendor == cpu_to_le16(0x3763))
         urb->transfer_flags |= URB_ZERO_PACKET;
 }

四:测试

  1. 查看usb网卡是否生成
ifconfig -a

在这里插入图片描述

  1. 测试方法一
busybox microcom /dev/ttyUSB2

在这里插入图片描述
3. 测试方法二

cat /dev/ttyUSB2 &
echo AT > /dev/ttyUSB2
频段: LTE-FDD: B1/B3/B5/B8 LTE-TDD: B34/B38/B39/B40/B41 GSM: 900/1800 MHz 数据 LTE: LTE-FDD: 最大 10 Mbps (DL)/最大 5 Mbps (UL) LTE-TDD: 最大 7.5 Mbps (DL)/最大 1 Mbps (UL) GSM: EDGE: 最大236.8 Kbps (DL)/最大236.8 Kbps (UL) GPRS: 最大 85.6 Kbps (DL)/最大 85.6 Kbps (UL) 接口 1 个 USB 2.0 高速接口 1 个数字语音 PCM 接口(可选) 1 个 1.8 V/3.0 V (U)SIM 接口 2 个 NETLIGHT 接口( NET_STATUS 和 NET_MODE) 2 个 UART 接口(主串口和调试串口) 2 个 ADC 接口 2 个 SDIO 接口(用于连接 SD 卡*和 Wi-Fi*) RESET(低电平有效) PWRKEY(低电平有效) 主天线 突出特性 FOTA(空中下载固件升级) (U)SIM 卡检测 用于连接 SD 卡*和 Wi-Fi*功能的 SDIO 接口 电气参数 输出功率: Class 3 (23 dBm ±2 dB) for LTE-FDD bands Class 3 (23 dBm ±2 dB) for LTE-TDD bands Class E2 (27 dBm ±3 dB) for EGSM900 8-PSK Class E2 (26 dBm ±3 dB) for DCS1800 8-PSK Class 4 (33 dBm ±2 dB) for EGSM900 Class 1 (30 dBm ±2 dB) for DCS1800 功耗: 11 μA @关机 TBD @LTE 休眠(PF=128) TBD @LTE 休眠(PF=256) 30 mA @空闲 灵敏度: FDD B1: -97.5 dBm FDD B3: -94.3 dBm FDD B5: -97 dBm FDD B8: -96.5 dBm TDD B34: -96.3 dBm TDD B38: -97 dBm TDD B39: -96.3 dBm TDD B40: -97 dBm TDD B41: -96 dBm EGSM900: -105 dBm DCS1800: -106 dBm 软件特性 USB 虚拟串口驱动: Windows 7/8/8.1/10、 Linux 2.6~5.4、 Android 4.x/5.x/6.x/7.x/9.x RIL 驱动: Android 4.x/5.x/6.x/7.x/8.x/9.x RNDIS 驱动: Windows 7/8/8.1/10, Linux 2.6~5.4 ECM 驱动Linux 2.6~5.4 协议栈: TCP/UDP/PPP/FTP/HTTP/FILE/MQTT/PING*/ CMUX*/NTP*/NITZ*/HTTPS*/FTPS*/SSL*/ MMS*/SMTP*/SMTPS* 一般特性 扩展温度范围: -40 °C ~ +85 °C 模块尺寸: 29.0 mm × 32.0 mm × 2.4 mm 重量: TBD LCC 封装 供电电压: 3.4~4.5 V,典型值 3.8 V 带宽: 1.4/3/5/10/15/20MHz 3GPP TS 27.007, 27.005 定义的命令,以及移远 通信增强型 AT 命令
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值