移远EC20 4G模块Linux驱动移植和测试
PS:要转载请注明出处,本人版权所有。
PS: 这个只是基于《我自己》的理解,
如果和你的原则及想法相冲突,请谅解,勿喷。
前置说明
本文作为本人csdn blog的主站的备份。(BlogID=046)
本文发布于 2017-11-21 10:28:14,现用MarkDown+图床做备份更新。blog原图已丢失,使用csdn所存的图进行更新。(BlogID=046)
环境说明
无
前言
无
EC20 驱动移植与测试
EC20简介
EC20是一个全网通的4G模块,并提供了详细的驱动移植资料(源码+文档),我也仅仅是照着文档,一点点的改,并建立起来一个可用的环境。
EC20驱动移植准备
- 首先你会从厂家拿到一个资料文件,并解压(类似Quectel_GobiNetSR01A02V16.zip)
- 你会找到一个用户手册的PDF打开(类似Quectel_WCDMA<E_Linux_USB_Driver_User_Guide_V1.6.pdf)
- 这里还有一个Readme.txt告诉你需要阅读上文pdf的哪些内容。可能如下:
About GobiNet driver, please refer to the chapter 3.2、3.4、5.4、6
About ConnectManager,please refer to the chapter 5.4
- 按照pdf指示如下。
EC20 Linux驱动移植
- 增加PID&VID(对着两个不了解的,建议去找找资料来看看,这个的意思可以简单理解为这个设备的唯一标识)
[KERNEL]/drivers/usb/serial/option.c
static const struct usb_device_id option_ids[] = {
#if 1 //Added by Sky
{ 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
这里其实只需要{ USB_DEVICE(0x05C6, 0x9215) }, /* Quectel EC20 */ 这一项,其他是无关紧要的,可以不放进去。option_ids[]就是一usb serial的设备pid,vid表。
- 注释掉冲突的vid以及pid设备(我猜存在相同的vid和pid是历史的原因)
[KERNEL]/drivers/usb/serial/qcserial.c
//Comment by Sky,
//{USB_DEVICE(0x05c6, 0x9215)}, /* Acer Gobi 2000 Modem device (VP413) */
[KERNEL]/drivers/net/usb/qmi_wwan.c
//comment by Sky
//{QMI_GOBI_DEVICE(0x05c6, 0x9215)}, /* Acer Gobi 2000 Modem device (VP413) */
注意这里貌似只有EC20的冲突了。
- 添加零包处理(这个和usb 协议中的批量传输有关)
For Linux Kernel Version newer than 2.6.34:
File: [KERNEL]/drivers/usb/serial/usb_wwan.c
usb_fill_bulk_urb(urb, serial->dev, usb_sndbulkpipe(serial->dev, endpoint) | dir, buf, len, callback, ctx);
#if 1 //Added by Sky 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
注意,pdf上还有For Linux Kernel Version older than 2.6.35的内容,请自行根据内核版本查看。
- 增加休眠后唤醒接口
For Linux Kernel Version newer than 3.4:
File: [KERNEL]/drivers/usb/serial/option.c
static struct usb_serial_driver option_1port_device = {
.driver = {
.owner = THIS_MODULE,
.name = "option1",
},
.description = "GSM modem (1-port)",
.id_table = option_ids,
.num_ports = 1,
.probe = option_probe,
.open = usb_wwan_open,
.close = usb_wwan_close,
.dtr_rts = usb_wwan_dtr_rts,
.write = usb_wwan_write,
.write_room = usb_wwan_write_room,
.chars_in_buffer = usb_wwan_chars_in_buffer,
.set_termios = usb_wwan_set_termios,
.tiocmget = usb_wwan_tiocmget,
.tiocmset = usb_wwan_tiocmset,
.ioctl = usb_wwan_ioctl,
.attach = option_attach,
.release = option_release,
.port_probe = usb_wwan_port_probe,
.port_remove = usb_wwan_port_remove,
.read_int_callback = option_instat_callback,
#ifdef CONFIG_PM
.suspend = usb_wwan_suspend,
.resume = usb_wwan_resume,
#if 1 //Added by Sky
.reset_resume = usb_wwan_resume,
#endif
#endif
};
- 如果要使用 GobiNet or QMI WWAN,需要阻止第四个接口注册为串口。
For Linux Kernel Version newer than 2.6.30:
File: [KERNEL]/drivers/usb/serial/option.c
static int option_probe(struct usb_serial *serial,
const struct usb_device_id *id)
{
struct usb_interface_descriptor *iface_desc =
&serial->interface->cur_altsetting->desc;
struct usb_device_descriptor *dev_desc = &serial->dev->descriptor;
/* Never bind to the CD-Rom emulation interface */
if (iface_desc->bInterfaceClass == 0x08)
return -ENODEV;
/*
* Don't bind reserved interfaces (like network ones) which often have
* the same class/subclass/protocol as the serial interfaces. Look at
* the Windows driver .INF files for reserved interface numbers.
*/
if (is_blacklisted(
iface_desc->bInterfaceNumber,
OPTION_BLACKLIST_RESERVED_IF,
(const struct option_blacklist_info *) id->driver_info))
return -ENODEV;
/*
* Don't bind network interface on Samsung GT-B3730, it is handled by
* a separate module.
*/
if (dev_desc->idVendor == cpu_to_le16(SAMSUNG_VENDOR_ID) &&
dev_desc->idProduct == cpu_to_le16(SAMSUNG_PRODUCT_GT_B3730) &&
iface_desc->bInterfaceClass != USB_CLASS_CDC_DATA)
return -ENODEV;
#if 1 //Added by Sky
//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;
}
- 修改内核配置,并编译内核,刷入新内核
添加USB 串口 GSM 和 CDMA 驱动选项
启用USB网络支持
添加驱动代码
//Step 5: Please add the following statements to file "[KERNEL]/drivers/net/usb/Makefile" ([KERNEL]/drivers/usb/net/Makefile if the kernel version is older than 2.6.22).
obj-y += GobiNet.o
GobiNet-objs := GobiUSBNet.o QMIDevice.o QMI.o
- quectel-CM 测试
//交叉编译quectel-CM
/*quectel-CM will call busybox udhpc to obtain IP and NDS, and busybox udhpc will call script file /usr/share/udhcpc/default.script to set IP/DNS/Routing table for Linux board. You can download this tool’s source code from https://busybox.net/. You should enable CONFIG_UDHCPC in busybox menuconfig,and copy the script file [BUSYBOX]/examples/udhcp/simple.script to your Linux board (renamed as /usr/share/udhcpc/default.script). */
quectel-CM –s ctnet &
[01-01_00:26:45:355] Quectel_ConnectManager_SR01A01V10
[01-01_00:26:45:356] ./quectel-CM profile = ctnet///, pincode =
[01-01_00:26:45:357] Find qmichannel = /dev/qcqmi2
[01-01_00:26:45:358] Find usbnet_adapter = eth2
[01-01_00:26:45:368] Get clientWDS = 7
[01-01_00:26:45:400] Get clientDMS = 8
[01-01_00:26:45:432] Get clientNAS = 9
[01-01_00:26:45:464] Get clientWDA = 10
[01-01_00:26:45:496] requestBaseBandVersion EC20CQAR02A03E2G_BETA0914 1 [Sep 14 2015 13:51:27]
[01-01_00:26:45:560] requestGetSIMStatus SIMStatus: SIM_READY
[01-01_00:26:45:624] requestGetProfile ctnet///0
[01-01_00:26:45:656] requestRegistrationState MCC: 460, MNC: 11, PS: Attached, DataCap: LTE
[01-01_00:26:45:688] requestQueryDataCall ConnectionStatus: DISCONNECTED
[01-01_00:26:45:720] requestRegistrationState MCC: 460, MNC: 11, PS: Attached, DataCap: LTE
[01-01_00:26:45:752] requestQueryDataCall ConnectionStatus: DISCONNECTED
[01-01_00:26:45:816] requestSetupDataCall WdsConnectionIPv4Handle: 0x43cc4478
[01-01_00:26:45:912] requestQueryDataCall ConnectionStatus: CONNECTED
[01-01_00:26:45:937] udhcpc (v1.20.2) started
[01-01_00:26:45:956] Sending discover...
[01-01_00:26:45:960] Sending select for 10.172.27.151...
[01-01_00:26:45:964] Lease of 10.172.27.151 obtained, lease time 7200
[01-01_00:26:45:984] deleting routers
route: SIOCDELRT: No such process
[01-01_00:26:46:003] adding dns 61.132.163.68
[01-01_00:26:46:003] adding dns 202.102.213.68
注意,这里需要UDHCPC ,检测你的busybox是否有这个东西,如果不存在,你需要重新移植busybox,启用CONFIG_UDHCPC选项。还需要配置一个配置文件,注意检查。
特别提示,其中很多关于内核源码修改,以及内核配置修改,不同的版本有不同的写法,文档里面都有详细说明,请使用时,特别注意。
后记
无
参考文献
- 无
打赏、订阅、收藏、丢香蕉、硬币,请关注公众号(攻城狮的搬砖之路)
PS: 请尊重原创,不喜勿喷。
PS: 要转载请注明出处,本人版权所有。
PS: 有问题请留言,看到后我会第一时间回复。
移远EC20 4G模块Linux驱动移植和测试的更多相关文章
- 海思3531添加移远EC20 4g模块(转)
源: 海思3531添加移远EC20 4g模块 Hi3798移植4G模块(移远EC20)
- I.MX6 SHT20 Linux 驱动移植
/*********************************************************************** * I.MX6 SHT20 Linux 驱动移植 * ...
- RK3399 4G模块移远EC20移植调试
转载请注明出处:https://www.cnblogs.com/lialong1st/p/11266330.html CPU:RK3399 系统:Android 7.1 1.通过串口打印或者adb获取 ...
- linux驱动移植
1.1 开发前准备 1.1.1 Linux 驱动(面向对象) 1).Linux 驱动框架 思想:写驱动的时候,只提供操作硬件设备的函数接口 文件存放磁盘: open ,read ,write ,clo ...
- linux驱动移植的重要数据结构
转载:http://www.embeddedlinux.org.cn/html/jishuzixun/201304/14-2538.html 对于嵌入式 Linux 系统来说,有各种体系结构的处理器和 ...
- 移远EC20的使用
一 发短信 3. 推荐短信流程3.1 查询 短信存储区AT+CPMS?+CPMS: "ME",19,255,"ME",19,255,"ME" ...
- linux驱动移植问题点
1.I2C地址是否和其它IC冲突.通过改地址解决 ——通常,以下三种情况的log表现相同:1.ic没连接到主板:2.i2c地址错误:3.该器件I2C地址与同组其它器件冲突 2.I2C通信是否受到其它s ...
- arm Linux 驱动LED子系统 测试
Linux内核在3.0以上引入了设备树概念(具体哪个版本不清楚)在编译内核后需要将与之对应的dtb文件也下载人板子上才能使内核与硬件关联起来. dtb文件是有dts文件编译后生成的:例如 /* * C ...
- 将移远通信的EC20驱动移植到NUC972上(转)
源: 将移远通信的EC20驱动移植到NUC972上
- [原创]移远RM500U-CN模组驱动移植
1. 简介 中国广电正式放号了,为了支持广电700MHz的5G基站,需要换用新的5G模组.移远通信的RM500U模组正好可以满足我们的使用要求; 我们选用该模组的原因:双卡单待 支持SIM卡热插拔 支 ...
随机推荐
- 【题解】U405180 计算平方和
\(\bold{Part\ 0}\) 目录 \(/\ \bold{Contents}\) \(\bold{Part\ 1}\) 题目大意 \(/\ \bold{Item\ content}\) \(\ ...
- .NET Core开发实战(第23课:静态文件中间件:前后端分离开发合并部署骚操作)--学习笔记(下)
23 | 静态文件中间件:前后端分离开发合并部署骚操作 这里还有一个比较特殊的用法 一般情况下,我们前后端分离的架构,前端会编译成一个 index.html 文件和若干个 CSS 文件和 JavaSc ...
- google三驾马车之一:Bigtable解读(英文版)
本文重点关注了系统设计相关的内容,paper后半部分的具体应用此处没有过多涉及.从个人笔记修改而来,因此为英文版本. Bigtable: A Distributed Storage System fo ...
- EGF:指数型生成函数
对于一个数列 \(<a_n>\),定义其指数型生成函数(EGF)\(\hat{a}(x)=\displaystyle\sum_{n\ge 0}\dfrac{a_n}{n!}x^n\). 例 ...
- CF739A Alyona and mex 题解
题目传送门 前置知识 贪心 | 构造 解法 从贪心的角度分析,最小的 \(\operatorname{mex}\) 仅会与长度最小的区间有关:另外为使得 \(\operatorname{mex}\) ...
- Linux中查看dmesg中 ata1对应的盘符,以及SATA/NVME SSD的rescan/delete操作方法
1.查看dmesg 中ata1 对应的盘符: Step1; lsscsi -s 查看盘符(bdf) 对应的host Id: Step2: ll /sys/class/scsi_host 可以找到不 ...
- Linux学习资料锦集
Linux 学习资料链接: (1)Linux常见命令及其用法_STM32李逼的博客-CSDN博客 (2)Linux命令了解_STM32李逼的博客-CSDN博客 3)Linux使用编辑器_STM32李 ...
- 【Android】使用Exoplayer播放视频
1 前言 ExoPlayer 是 google 开源的应用级媒体播放器,github源码 → https://github.com/google/ExoPlayer.相较于 MediaPlayer ...
- 利用LiveReload插件实现vscode和谷歌浏览器实时刷新
说明 最近在研究CSS希望可以提升一个层次.在写DEMO练习的时候老是需要去谷歌浏览器手动刷新页面才能看到更改后的效果次数多了 我也受不了,这不我又请来了个帮手: LiveReload,名如其人,这家 ...
- Java Http客户端选型
JDK自带 HTTPURLConnect:功能单一 Apache HttpClient https://hc.apache.org/index.html 是一个比较古老的HTTP框架,使用非常普遍. ...