参考了手册和网上的文章。做下记录。
内核版本:linux-3.10
1. Add VID and PID
在/drivers/usb/serial/option.c添加:
static const struct usb_device_id option_ids[] = {
#if 1 //Added by Quectel
{ USB_DEVICE(0x05C6, 0x9090) }, /* Quectel UC15 */
{ USB_DEVICE(0x05C6, 0x9003) }, /* Quectel UC20 */
{ USB_DEVICE(0x05C6, 0x9215) }, /* Quectel EC20 */
{ USB_DEVICE(0x2C7C, 0x0125) }, /* Quectel EC25/EC20 R2.0 */
{ USB_DEVICE(0x2C7C, 0x0121) }, /* Quectel EC21 */
#endif
然后在/drivers/usb/serial/qcserial.c 和/drivers/usb/serial/qcserial.c两个文件中注释掉如下语句
{USB_DEVICE(0x05c6, 0x9215)}, /* Acer Gobi 2000 Modem device (VP413) */
网上说是由于历史的原因,导致VID和PID重复了。
2. Add the Zero Packet Mechanism
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 urb *urb;urb = usb_alloc_urb(0, GFP_KERNEL); /* No ISO */if (urb == NULL) {dev_dbg(&serial->interface->dev,"%s: alloc for endpoint %d failed.\n", __func__,endpoint);return NULL;}/* Fill URB using supplied data. */usb_fill_bulk_urb(urb, serial->dev,usb_sndbulkpipe(serial->dev, endpoint) | dir,buf, len, callback, ctx);//ADD bye sky for zero packetif (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;}//===return urb;
}
3. Add Reset Resume
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,#if 1 //Added by Quectel
.reset_resume = usb_wwan_resume,
#endif#endif
};
4. Use GobiNet or QMI WWAN
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;
……
#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'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;
//Quectel EC21&EC25&EC20 R2.0's interface 4 can be used as USB Network device
if (serial->dev->descriptor.idVendor == cpu_to_le16(0x2C7C)
&& serial->interface->cur_altsetting->desc.bInterfaceNumber >= 4)
return -ENODEV;
#endif
/* Store device id so we can use it during attach. */
usb_set_serial_data(serial, (void *)id);
return 0;
}
5.Enable CONFIG_USB_SERIAL_OPTION
重新烧写内核,然后将模块连接到USB HOST上。 重新上电稍等一下就可以检测到模块了。
在dev下发现:
用AT命令测试下:
cat /dev/ttyUSB2 &
echo "AT\r\n" >/dev/ttyUSB2
如果可以看到有数据返回,那就表明驱动已将OK了。硬件连接也没有问题了。。
6. GobiNet Driver for UC20/EC20/EC21/EC25/EC20 R2.0
下一步就是:GobiNet Driver for UC20/EC20/EC21/EC25/EC20 R2.0
类似这样的效果,会创建一个eht1的网卡设备。
将一些代码文件拷贝到“[KERNEL]/drivers/net/usb/目录下,代码来自官网,或者网上找找。
修改目录下的[KERNEL]/drivers/net/usb/Makefile文件 加入:
然后重新编译内核,并烧写内核。
上电后加载的驱动信息:
然后输入ifconfig -a查看
7 . Test GobiNet
编译quectel-CM
make CROSS-COMPILE=arm-linux-