嵌入式设备路由网络共享开发(2):移远Quectel系列4G模块驱动移值

前言

本文章介绍了在linux系统下,如何修改usb驱动支持移远模块,移远模块正常启动后,通过USB连接到linux设备上,驱动正常加载后会在/dev/下产ttyUSB*设备。

一、USB串口驱动

1.1 添加VID和PID   

linux下通过lsusb就可以查看USB的VID和PID

#lsusb

Bus 001 Device 011: ID 2C7C:0125

说明这个USB设备的VID为2C7C,PID为0125;

File: [KERNEL]/drivers/usb/serial/option.c

static const struct usb_device_id option_ids[] = {
//Added by Quectel
{ USB_DEVICE(0x2C7C, 0x0125) }, 
//End by Quectel
{ 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) },
{ USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_QUAD) },
{ USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_QUAD_LIGHT) },

1.2 屏蔽冲突

File: [KERNEL]/drivers/usb/serial/qcserial.c

{USB_DEVICE(0x2C7C, 0x0125)}, /* Acer Gobi 2000 Modem device (VP413) */

File: [KERNEL]/drivers/net/usb/qmi_wwan.c

{QMI_GOBI_DEVICE(0x2C7C, 0x0125)}, /* Acer Gobi 2000 Modem device (VP413) */

1.3 添加零包机制

File: [KERNEL]/drivers/usb/serial/usb_wwan.c

static struct urb *usb_wwan_setup_urb(struct usb_serial *serial, int endpoint,
int dir, void *ctx, char *buf, int len,void (*callback) (struct urb *))
{
……
    usb_fill_bulk_urb(urb, serial->dev,
    usb_sndbulkpipe(serial->dev, endpoint) | dir,buf, len, callback, ctx);
    //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) && desc->idProduct == cpu_to_le16(0x0125))
        urb->transfer_flags |= URB_ZERO_PACKET;
    }
    //End by Quectel for zero packet
    return urb;
}

1.4 添加重置

File: [KERNEL]/drivers/usb/serial/option.c

static struct usb_serial_driver option_1port_device = {
……
#ifdef CONFIG_PM
.suspend = usb_wwan_suspend,
.resume = usb_wwan_resume,
//Added by Quectel
    .reset_resume = usb_wwan_resume,
//End by Quectel
#endif
};

1.5 使用添加GobiNet

File: [KERNEL]/drivers/usb/serial/option.c

static int option_probe(struct usb_serial *serial, const struct usb_device_id *id) {
struct usb_wwan_intf_private *data;
……
//Added by Quectel
if (serial->dev->descriptor.idVendor == cpu_to_le16(0x2C7C) 
&& serial->dev->descriptor.idProduct == cpu_to_le16(0x0125)
&& serial->interface->cur_altsetting->desc.bInterfaceNumber >= 4)
    return -ENODEV;
//End by Quectel
/* Store device id so we can use it during attach. */
usb_set_serial_data(serial, (void *)id);
return 0;
}

1.6 模块内核配置

嵌入式设备路由网络共享开发(2):移远Quectel系列4G模块驱动移值_第1张图片

 

二、  GobiNet驱动

2.1 模块添加

嵌入式设备路由网络共享开发(2):移远Quectel系列4G模块驱动移值_第2张图片

2.2 添加程序

把Quectel_WCDMA<E_Linux&Android_GobiNet_Driver_V1.3.0.zip/src/目录下的文件拷贝到 [KERNEL]/drivers/net/usb/ 下,makefile Readme.txt不拷贝,源码下载:https://download.csdn.net/download/u012478275/11002420

修改[KERNEL]/drivers/net/usb/下的makefile在文件最后添加

obj-y += GobiNet.o
GobiNet-objs := GobiUSBNet.o QMIDevice.o QMI.o

2.3 编译内核

make ARCH=arm CROSS_COMPILE=arm-hisiv300-linux- uImage

 

三、  环境变量配置

3.1、udhcpc配置:

把文件default.script拷贝到/usr/share/udhcpc/下:

把文件resolv.conf拷贝到/var/dvr/下,然后

ln  -s  /var/dvr/resolv.conf    /etc/resolv.conf

3.2、拨号:

编译quectel-CM程序源码,编译出quectel-CM工具进行拨号;

quectel-CM源码下载:https://download.csdn.net/download/u012478275/11185199

 

 

 

 

 

 

 

 

 

你可能感兴趣的:(嵌入式通讯模块开发)