栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

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

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

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) }, 
	{ 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,
#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设备节点:

设备名称作用
ttyUSB0DM
ttyUSB1GPS的NMEA信息输出接口
ttyUSB2AT指令接口
ttyUSB3PPP连接或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外网测试:

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/1013564.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号