i.MX6ULL驱动开发 | 30 - 使用EC20 4G网卡(移植移远GobiNet驱动)

一、EC20


EC20在Linux下的驱动架构:

二、Linux内核中USB驱动的修改与配置

1. EC20 USB驱动修改

默认插上之后没有出来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) }, /* Quectel UC15 */
	{
    
     USB_DEVICE(0x05C6, 0x9003) }, /* Quectel UC20 */
	{
    
     USB_DEVICE(0x2C7C, 0x0125) }, /* Quectel EC25 */
	{
    
     USB_DEVICE(0x2C7C, 0x0121) }, /* Quectel EC21 */
	{
    
     USB_DEVICE(0x05C6, 0x9215) }, /* Quectel EC20 */
	{
    
     USB_DEVICE(0x2C7C, 0x0191) }, /* Quectel EG91 */
	{
    
     USB_DEVICE(0x2C7C, 0x0195) }, /* Quectel EG95 */
	{
    
     USB_DEVICE(0x2C7C, 0x0306) }, /* Quectel EG06/EP06/EM06 */
	{
    
     USB_DEVICE(0x2C7C, 0x0512) }, /* Quectel EG12/EP12/EM12/EG16/EG18 */
	{
    
     USB_DEVICE(0x2C7C, 0x0296) }, /* Quectel BG96 */
	{
    
     USB_DEVICE(0x2C7C, 0x0435) }, /* Quectel AG35 */
#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,
#endif

1.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 -j16

2. 配置Linux内核

(1)使能USB NET功能

(2)使能USB串口GSM、CDMA驱动

(3)使能USB的CDC ACM模式

至此,Linux内核配置完成,将修改的配置保存到开发板配置文件,编译:

make -j16

3. USB设备测试

使用新的内核启动,可以看到日志:

查看ttyUSB设备节点:

设备名称 作用
ttyUSB0 DM
ttyUSB1 GPS的NMEA信息输出接口
ttyUSB2 AT指令接口
ttyUSB3 PPP连接或AT指令接口

在这里插入图片描述

三、添加移远官方的GobiNet驱动

1. 驱动源码

移远为EC20提供了GobiNet驱动,

2. 添加驱动到内核中

将所有的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.


至此,驱动添加完成。

3. 配置内核,开启驱动


配置后重新编译内核:

make -j16

4. 测试

启动内核:

查看是否有设备节点:

至此,EC20驱动修改完成,Gobi驱动正常工作。

四、移植quectel-CM工具

1. 工具源码

2. 交叉编译

make CROSS_COMPILE=arm-linux-gnueabihf-


3. 拷贝到开发板根文件系统

cp quectel-CM ~/develop/imx6ull/rootfs/rootfs-busybox-imx6ull/source_busybox/usr/local/bin 

4. EC20上网测试

quectel-CM -s cenet &


查看网卡:

查看路由表:

ping外网测试:

猜你喜欢

转载自blog.csdn.net/Mculover666/article/details/125740257