概述
一.在调试之前连接好EC200模块,命令: lsusb 查询模块vid pid
如果lsusb查询没有如图所示vid pid:表示EC200T硬件没有被识别,检测原因,可能供电不足.,硬件有问题
二. usb-serial-option, USB转串口驱动,生成/dev/ttyUSB0~2. 总共3个串口,分别是DM、AT、PPP.
ttyUSB0 --》 DM ttyUSB1 --》 AT 指令 ttyUSB2 -》 PPP拨号和AT指令
usb-serial-option usb串口驱动与公司其他高通平台模块的兼容
UC200&EC200和其他高通模块,都是用usb-serial-option驱动,但是USB interface的顺序不同. 所以如果客户之前移植过 EC20/EC25的代码,会导致UC200&EC200的PPP口识别不到. (ttyUSB2无法识别)
最简单方法,把原来移植的EC20/EC25代码去除,重新移植.
三,内核中需要配置的文件
--》1.add VID and PID :usb设备的硬件识别号码
static const struct usb_device_id option_ids[] = {
#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, 0x0296) }, /* Quectel BG96 */
{ USB_DEVICE(0x2C7C, 0x0435) }, /* Quectel AG35 */
{ USB_DEVICE(0x2C7C, 0x0512) }, /* Quectel EG12/EG18 */
{ USB_DEVICE(0x2C7C, 0x6026) }, /* Quectel EC200 t*/ //新增一个EC200T
{ USB_DEVICE(0x2C7C, 0x6000) }, /* Quectel EC200/UC200 */
#endif
{ 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) },
---》2.部分USB主机控制器/USB集线器在MCU进入suspend/sleep模式时会断电或复位,MCU 退出suspend/sleep模式时无法恢复USB设备;相反,他们将重新启动“重启”
static struct usb_serial_driver option_1port_device = {
#ifdef CONFIG_PM
.suspend = usb_wwan_suspend,
.resume = usb_wwan_resume,
#if 1 //add by Quectel
.reset_resume = usb_wwan_resume, //新增
#endif
#endif
};
-----》3.use GobiNet or QMI WWAN :这里我们只是用GobiNet
必须添加如下语句,防止模块接口4被用于USB串行设备
static int option_probe(struct usb_serial *serial, const struct usb_device_id *id){
struct usb_device_descriptor *dev_desc = &serial->dev->descriptor;
const struct option_blacklist_info *blacklist;
#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;
if (serial->dev->descriptor.idVendor == cpu_to_le16(0x2C7C)) {
__u16 idProduct = le16_to_cpu(serial->dev->descriptor.idProduct);
//Quectel EC200&UC200's interface 0 can be used as USB Network device (ecm, rndis)
if (serial->interface->cur_altsetting->desc.bInterfaceClass != 0xFF)
return -ENODEV;
//QuectelEC25&EC21&EG91&EG95&EG06&EP06&EM06&BG96&AG35&EG12&EG18's //interface 4 can be used as USB network device (qmi,ecm,mbim)
if ((idProduct != 0x6026 && idProduct != 0x6126)
&& serial->interface->cur_altsetting->desc.bInterfaceNumber >= 4)
return -ENODEV;
}
#endif
}
----》4.注意:在linux内核中会有一些与EC20添加的VID ,PID冲突,必须删除.
[KERNEL]/drivers/usb/serial/qcserial.c
static const struct usb_device_id id_table[] = {
{DEVICE_G1K(0x05c6, 0x9202)}, /* Generic Gobi Modem device */
{DEVICE_G1K(0x05c6, 0x9203)}, /* Generic Gobi Modem device */
{DEVICE_G1K(0x05c6, 0x9222)}, /* Generic Gobi Modem device */
//{DEVICE_G1K(0x05c6, 0x9008)}, /* Generic Gobi QDL device */ 屏蔽
{USB_DEVICE(0x03f0, 0x241d)}, /* HP Gobi 2000 QDL device (VP412) */
{USB_DEVICE(0x03f0, 0x251d)}, /* HP Gobi 2000 Modem device (VP412) */
{USB_DEVICE(0x05c6, 0x9214)}, /* Acer Gobi 2000 QDL device (VP413) */
//{USB_DEVICE(0x05c6, 0x9215)}, /*Acer Gobi 2000 Modem device (VP413) 屏蔽*/
{USB_DEVICE(0x05c6, 0x9264)}, /* Asus Gobi 2000 QDL device (VR305) */
{USB_DEVICE(0x05c6, 0x9265)}, /* Asus Gobi 2000 Modem device (VR305) */
{USB_DEVICE(0x05c6, 0x9234)}, /* Top Global Gobi 2000 QDL device (VR306) */
--->5. 添加零包处理机制
根据USB协议的要求,您需要添加在批量输出传输期间处理零数据包的机制。
FILE: [KERNEL]/drivers/usb/serial/usb_wwan.c
static struct urb *usb_wwan_setup_urb(struct usb_serial_port *port,
usb_sndbulkpipe(serial->dev, endpoint) | dir,buf, len, callback, ctx);
#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
return urb;
}
---》6.选择内核配置
usb 串口驱动编译到内核中:
执行命令:
source build/envsetup.sh
make linux_config -à 其实是make menuconfig
这个驱动就是在linux内核中虚拟出/dev/ttyUSB0 ,/dev/ttyUSB1 /dev/ttyUSB2等等设备
注意:我们还可以将配置选项 [M]USB driver for GSM and CDMA modems,编译为模块option.ko文件,动态加载驱动.
选择usb网络设备驱动支持:
这个驱动的作用让内核支持USB网络设备,如果使用ppp拨号工具或者GobiNet工具拨号,能在系统中虚拟出一个网络设备,供 上层socket操作.
配置成功后:从新编译内核烧入
make linux; make pack //这里是我联咏SDK编译; 等价于-----------》 make uImge
插入后打印如下信息:
[17738.104336] usb 1-1.4: new high-speed USB device number 5 using ehci-pci
[17738.215240] usb 1-1.4: New USB device found, idVendor=2c7c, idProduct=6026
[17738.215243] usb 1-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[17738.215246] usb 1-1.4: Product: EC26
[17738.215248] usb 1-1.4: Manufacturer: Quectel
[17738.215250] usb 1-1.4: SerialNumber: 200806006809080000
[17738.217710] rndis_host 1-1.4:1.0 eth0: register 'rndis_host' at usb-0000:00:1a.0-1.4, RNDIS device, ac:af:fc:d4:e0:61
[17738.218236] option 1-1.4:1.2: GSM modem (1-port) converter detected
[17738.218485] usb 1-1.4: GSM modem (1-port) converter now attached to ttyUSB0
[17738.218729] option 1-1.4:1.3: GSM modem (1-port) converter detected
[17738.218843] usb 1-1.4: GSM modem (1-port) converter now attached to ttyUSB1
[17738.219089] option 1-1.4:1.4: GSM modem (1-port) converter detected
[17738.219186] usb 1-1.4: GSM modem (1-port) converter now attached to ttyUSB2
在终端输入: ls /dev 查看有 ttyUSB0 ttyUSB1 ttyUSB2 说明4G模块驱动部分已经成功添加.
---》7.可以使用 microcom 测试AT指令
# microcom -s 115200 /dev/ttyUSB2 // 打开/dev/ttyUSB2 microcom工具是busybox中自带的,没有需要配置编译出来
AT+CGMI 给出模块厂商的标识
AT+CGMM 获得模块标识。这个命令用来得到支持的频带(GSM 900,DCS 1800 或PCS 1900)。当模块有多频 带时,回应可能是不同频带的结合
AT+CGMR 获得模块的软件版本
AT+CGSN 获得 GSM 模块的 IMEI(国际移动设备标识)序列号
AT+CSQ 信号质量检测
AT+COPS? 服务商查询
+COPS: 0,0,"CHN-UNICOM",7 返回中国联通
AT+CREG=1 网络注册
AT+CREG? 获得手机的注册状态
AT+CPIN? 检测SIM卡是否就绪
+CPIN: READY 识别到SIM卡
+CPIN: NOT READY 无卡
Ctrl+x 退出AT指令测试模式
四. EC200T只能用ppp拨号实现上网:不能用quectel-CM工具拨号哦
---> 1.从新配置kernel :增加support ppp
[*] Device Drivers →
[*] Network device support →
[*] PPP (point-to-point protocol) support
要重新编译内核哦: make uImage
---》2.下载ppp-2.4.4.tar.gz源码解压:
配置编译:
cd ppp-2.4.4
./configure --host= 你自己的交叉编译工具指定
make
然后就可以拷贝pppd/pppd chat/chat 到文件系统/sbin目录下了.
---》3.ppp拨号方法:先下载quectel-ec20t.tar.bz2
copy ppp to $(rootfs)/etc //这里需要根据自己实际目录拷贝,我是放在文件系统/etc目录下面
copy chat and pppd to $(rootfs)/sbin
两种方法,方法一:执行如下命令: pppd call quectel-ppp &
如果拨号成功会有以下信息打印出来:
[root@zx64352 peers]# pppd call quectel-ppp
pppd options in effect:
debug # (from /etc/ppp/peers/quectel-ppp)
nodetach # (from /etc/ppp/peers/quectel-ppp)
dump # (from /etc/ppp/peers/quectel-ppp)
noauth # (from /etc/ppp/peers/quectel-ppp)
user test # (from /etc/ppp/peers/quectel-ppp)
password ?????? # (from /etc/ppp/peers/quectel-ppp)
remotename 3gppp # (from /etc/ppp/peers/quectel-ppp)
/dev/ttyUSB3 # (from /etc/ppp/peers/quectel-ppp)
115200 # (from /etc/ppp/peers/quectel-ppp)
lock # (from /etc/ppp/peers/quectel-ppp)
connect chat -s -v -f /etc/ppp/peers/quectel-chat-connect # (from /etc/ppp/peers/quectel-ppp)
disconnect chat -s -v -f /etc/ppp/peers/quectel-chat-disconnect # (from /etc/ppp/peers/quectel-ppp)
nocrtscts # (from /etc/ppp/peers/quectel-ppp)
modem # (from /etc/ppp/peers/quectel-ppp)
hide-password # (from /etc/ppp/peers/quectel-ppp)
novj # (from /etc/ppp/peers/quectel-ppp)
novjccomp # (from /etc/ppp/peers/quectel-ppp)
ipcp-accept-local # (from /etc/ppp/peers/quectel-ppp)
ipcp-accept-remote # (from /etc/ppp/peers/quectel-ppp)
ipparam 3gppp # (from /etc/ppp/peers/quectel-ppp)
noipdefault # (from /etc/ppp/peers/quectel-ppp)
ipcp-max-failure 30 # (from /etc/ppp/peers/quectel-ppp)
defaultroute # (from /etc/ppp/peers/quectel-ppp)
usepeerdns # (from /etc/ppp/peers/quectel-ppp)
noccp # (from /etc/ppp/peers/quectel-ppp)
rcvd [IPCP ConfReq id=0x1]
sent [IPCP ConfAck id=0x1]
rcvd [IPCP ConfAck id=0x2 <addr 10.35.149.45> <ms-dns1 218.4.4.4> <ms-dns2 218.2.2.2>]
Could not determine remote IP address: defaulting to 10.64.64.64
local IP address 10.35.149.45
remote IP address 10.64.64.64
primary DNS address 218.4.4.4
secondary DNS address 218.2.2.2
此时也会在/etc/ppp/目录下生成resolv.conf文件,存放pppd拨号获取到的DNS,可以将改文件拷贝到/etc/目录下,这样便可以进行DNS解析了,至此开发板也可以通过EC20模块连接到互联网了
方法二
方法一中的端口号、APN、用户名、密码等都是直接写在配置文件中,这样如果要更换这些内容的话要频繁修改配置文件,既消耗时间,又不太方便。所以便将几个配置文件融合到一个脚本中,并且可以通过传递参数那样修改需要修改的内容,脚本内容如下:
/etc/ppp/peers/quectel-pppd.sh /dev/ttyUSB2
这里注意:EC200T是ttyUSB2用于ppp拨号.
输出信息跟方法一输出一样,同样会生成/etc/ppp/resolv.conf文件,
ifconfig查看
ping www.baidu.com 通了就大功告成了.
注意: 在进行拨号之前一定要确保没有默认网关,如果已经设置了其他网卡的默认网关了,则4G模块没法正常上网,需要删除原来的默认网关,现以网卡eth0为例:
route del default
route del -host 255.255.255.255 dev eth0
ppp-2.4.4.tar.gz源码和 quectel-ec20t.tar.bz2拨号脚本代码.如下面链接可下载:
https://download.csdn.net/download/delores_lc/12894405
最后
以上就是动听世界为你收集整理的移远EC200T模块应用移植的全部内容,希望文章能够帮你解决移远EC200T模块应用移植所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复