EC20在Linux下的驱动架构:
默认插上之后没有出来ttyUSB设备,需要在内核中添加EC20的USB设备信息。
1.1. 添加USB设备信息修改文件drivers/usb/serial/option.c。
(1)option_ids数组添加EC20 ID信息
#if 1 //Added by Quectel
{ USB_DEVICE(0x05C6, 0x9090) },
{ USB_DEVICE(0x05C6, 0x9003) },
{ USB_DEVICE(0x2C7C, 0x0125) },
{ USB_DEVICE(0x2C7C, 0x0121) },
{ USB_DEVICE(0x05C6, 0x9215) },
{ USB_DEVICE(0x2C7C, 0x0191) },
{ USB_DEVICE(0x2C7C, 0x0195) },
{ USB_DEVICE(0x2C7C, 0x0306) },
{ USB_DEVICE(0x2C7C, 0x0512) },
{ USB_DEVICE(0x2C7C, 0x0296) },
{ USB_DEVICE(0x2C7C, 0x0435) },
#endif
(3)修改 option_probe 函数,添加EC20相关代码(Use GobiNet or QMI WWAN)
#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 EC25&EC21&EG91&EG95&EG06&EP06&EM06&BG96/AG35'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
(4)修改 option_1port_device 结构体,加入休眠后唤醒接口
#if 1 //Added by Quectel .reset_resume = usb_wwan_resume, #endif1.2. 添加零包处理代码
编辑drivers/usb/serial/usb_wwan.c文件。
修改 usb_wwan_setup_urb 函数,添加零包处理代码:
#if 1 //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;
}
#endif
1.3. 编译内核
编译内核,检查下有无编译错误。
make -j162. 配置Linux内核
(1)使能USB NET功能
(2)使能USB串口GSM、CDMA驱动
(3)使能USB的CDC ACM模式
至此,Linux内核配置完成,将修改的配置保存到开发板配置文件,编译:
make -j163. USB设备测试
使用新的内核启动,可以看到日志:
查看ttyUSB设备节点:
| 设备名称 | 作用 |
|---|---|
| ttyUSB0 | DM |
| ttyUSB1 | GPS的NMEA信息输出接口 |
| ttyUSB2 | AT指令接口 |
| ttyUSB3 | PPP连接或AT指令接口 |
移远为EC20提供了GobiNet驱动,
将所有的c文件和h文件拷贝到Linux内核的 drivers/net/usb目录下:
拷贝完成以后,修改 driver/net/usb/Makefile 文件:
obj-$(CONFIG_USB_GOBI_NET) += GobiNet.o GobiNet-objs := GobiUSBNet.o QMIDevice.o QMI.o
在 drivers/net/usb/Kconfig 文件中加入以下内容:
config USB_GOBI_NET tristate"Gobi USB Net driver for Quectel module" help Support Quectelmodule. A modemmanager with support for GobiNet is recommended. Tocompile this driver as a module, choose M here: the module will be calledGobiNet.
至此,驱动添加完成。
配置后重新编译内核:
make -j164. 测试
启动内核:
查看是否有设备节点:
至此,EC20驱动修改完成,Gobi驱动正常工作。
make CROSS_COMPILE=arm-linux-gnueabihf-
cp quectel-CM ~/develop/imx6ull/rootfs/rootfs-busybox-imx6ull/source_busybox/usr/local/bin4. EC20上网测试
quectel-CM -s cenet &
查看网卡:
查看路由表:
ping外网测试:



