Linux系统下的移远Quectel系列4G模块驱动移植
前言
本文章介绍了在linux系统下,如何修改usb驱动支持移远模块,移远模块正常启动后,通过USB连接到linux设备上,驱动正常加载后会在/dev/下产ttyUSB*设备。
一、USB串口驱动
1.1 添加VID和PID
linux下通过lsusb就可以查看USB的VID和PID
/#lsusb
Bus 001 Device 011: ID 2C7C:0125
说明这个USB设备的VID为2C7C,PID为0125;
File: [KERNEL]/drivers/usb/serial/option.c
static const struct usb_device_id option_ids[] = {
//Added by Quectel
{ USB_DEVICE(0x2C7C, 0x0125) },
//End by Quectel
{ USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) },
{ USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) },
{ USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_LIGHT) },
{ USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_QUAD) },
{ USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_QUAD_LIGHT) },
1.2 屏蔽冲突
File: [KERNEL]/drivers/usb/serial/qcserial.c
{USB_DEVICE(0x2C7C, 0x0125)}, /* Acer Gobi 2000 Modem device (VP413) */
File: [KERNEL]/drivers/net/usb/qmi_wwan.c
{QMI_GOBI_DEVICE(0x2C7C, 0x0125)}, /* Acer Gobi 2000 Modem device (VP413) */
1.3 添加零包机制
File: [KERNEL]/drivers/usb/serial/usb_wwan.c
static struct urb *usb_wwan_setup_urb(struct usb_serial *serial, int endpoint,
int dir, void *ctx, char *buf, int len,void (*callback) (struct urb *))
{
……
usb_fill_bulk_urb(urb, serial->dev,
usb_sndbulkpipe(serial->dev, endpoint) | dir,buf, len, callback, ctx);
//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(0x2C7C) && desc->idProduct == cpu_to_le16(0x0125))
urb->transfer_flags |= URB_ZERO_PACKET;
}
//End by Quectel for zero packet
return urb;
}
1.4 添加重置
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,
//Added by Quectel
.reset_resume = usb_wwan_resume,
//End by Quectel
#endif
};
1.5 使用添加GobiNet
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;
……
//Added by Quectel
if (serial->dev->descriptor.idVendor == cpu_to_le16(0x2C7C)
&& serial->dev->descriptor.idProduct == cpu_to_le16(0x0125)
&& serial->interface->cur_altsetting->desc.bInterfaceNumber >= 4)
return -ENODEV;
//End by Quectel
/* Store device id so we can use it during attach. */
usb_set_serial_data(serial, (void *)id);
return 0;
}
`
1.6 模块内核配置
二、 GobiNet驱动
2.1 模块添加
2.2 添加程序
把Quectel_WCDMA< E_Linux&Android_GobiNet_Driver_V1.3.0.zip/src/目录下的文件拷贝到 [KERNEL]/drivers/net/usb/ 下,makefile 和Readme.txt不拷贝,源码下载:移远模块Linux下GobinNet驱动
修改[KERNEL]/drivers/net/usb/下的makefile,在文件最后添加
obj-y += GobiNet.o
GobiNet-objs := GobiUSBNet.o QMIDevice.o QMI.o
2.3 编译内核
make ARCH=arm CROSS_COMPILE=arm-hisiv300-linux- uImage
三、 环境变量配置
3.1、udhcpc配置:
把文件default.script拷贝到/usr/share/udhcpc/下:
把文件resolv.conf拷贝到/var/dvr/下,然后
ln -s /var/dvr/resolv.conf /etc/resolv.conf
3.2、拨号:
编译quectel-CM程序源码,编译出quectel-CM工具进行拨号;
quectel-CM源码下载:Linux下 移远4G模块quectel-CM拨号工具
- 分享
- 举报
-
2024-01-16 17:33:40
-
浏览量:4796次2022-10-14 08:34:42
-
浏览量:3014次2020-08-29 21:36:16
-
浏览量:7932次2021-01-08 15:04:53
-
浏览量:6486次2021-01-08 15:16:17
-
浏览量:2381次2020-09-21 19:12:37
-
浏览量:1482次2020-02-26 19:46:35
-
浏览量:2315次2020-02-27 10:32:59
-
浏览量:2672次2022-03-01 09:00:32
-
浏览量:1886次2019-08-20 16:51:26
-
浏览量:1814次2019-02-16 10:58:42
-
浏览量:4145次2021-07-29 13:50:03
-
浏览量:3106次2022-03-29 09:00:21
-
浏览量:559次2023-08-22 13:38:20
-
浏览量:3438次2019-12-05 18:03:06
-
浏览量:2913次2023-07-12 15:18:09
-
浏览量:2585次2022-02-22 09:00:29
-
浏览量:2564次2018-04-19 14:59:43
-
浏览量:32713次2022-06-11 11:06:24
-
广告/SPAM
-
恶意灌水
-
违规内容
-
文不对题
-
重复发帖
老干部
感谢您的打赏,如若您也想被打赏,可前往 发表专栏 哦~
举报类型
- 内容涉黄/赌/毒
- 内容侵权/抄袭
- 政治相关
- 涉嫌广告
- 侮辱谩骂
- 其他
详细说明