本文章介绍了在linux系统下,如何修改usb驱动支持移远模块,移远模块正常启动后,通过USB连接到linux设备上,驱动正常加载后会在/dev/下产ttyUSB*设备。
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) },
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) */
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;
}
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
};
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;
}
把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
make ARCH=arm CROSS_COMPILE=arm-hisiv300-linux- uImage
把文件default.script拷贝到/usr/share/udhcpc/下:
把文件resolv.conf拷贝到/var/dvr/下,然后
ln -s /var/dvr/resolv.conf /etc/resolv.conf
编译quectel-CM程序源码,编译出quectel-CM工具进行拨号;
quectel-CM源码下载:https://download.csdn.net/download/u012478275/11185199