当前位置:   article > 正文

T31开发笔记:EC200T-CN 4G模块调试

ec200t-cn

若该文为原创文章,转载请注明原文出处 

一、硬件和开发环境

1、硬件:T31X+SC5235 + EC200T-CN

2、开发环境: ubuntu16.04-64bit

3、编译器:mips-gcc540-glibc222-32bit-r3.3.0.tar.gz

注:板子和4G模块某淘上淘的,uboot和内核是自己裁剪移植的,没有移植wifi,所以USB接口未使用; EC200T-CN使用的是USB接口,电源外供5V,注意4G模块电源。

二、内核文件修改、配置及编译

1、内核中需要修改的代码

主要修改下面四个文件的代码:

drivers/net/usb/qmi_wwan.c

drivers/usb/serial/option.c

drivers/usb/serial/qcserial.c

drivers/usb/serial/usb_wwan.c

A、  修改drivers/net/usb/qmi_wwan.c代码:

  1. diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
  2. index 5645921..f8f0020 100644
  3. --- a/drivers/net/usb/qmi_wwan.c
  4. +++ b/drivers/net/usb/qmi_wwan.c
  5. @@ -614,7 +614,7 @@ static const struct usb_device_id products[] = {
  6. {QMI_GOBI_DEVICE(0x05c6, 0x9225)}, /* Sony Gobi 2000 Modemdevice (N0279, VU730) */
  7. {QMI_GOBI_DEVICE(0x05c6, 0x9245)}, /* Samsung Gobi 2000 Modemdevice (VL176) */
  8. {QMI_GOBI_DEVICE(0x03f0, 0x251d)}, /* HP Gobi 2000 Modemdevice (VP412) */
  9. - {QMI_GOBI_DEVICE(0x05c6, 0x9215)}, /* Acer Gobi 2000 Modemdevice (VP413) */
  10. +// {QMI_GOBI_DEVICE(0x05c6, 0x9215)}, /* Acer Gobi 2000 Modemdevice (VP413) */
  11. {QMI_GOBI_DEVICE(0x05c6, 0x9265)}, /* Asus Gobi 2000 Modemdevice (VR305) */
  12. {QMI_GOBI_DEVICE(0x05c6, 0x9235)}, /* Top Global Gobi 2000Modem device (VR306) */
  13. {QMI_GOBI_DEVICE(0x05c6, 0x9275)}, /* iRex Technologies Gobi2000 Modem device (VR307) *}

B、 drivers/usb/serial/option.c

  1. --- a/drivers/usb/serial/option.c
  2. +++ b/drivers/usb/serial/option.c
  3. @@ -530,6 +530,22 @@ static const struct option_blacklist_info
  4. telit_le920_blacklist = {
  5. };
  6. static const struct usb_device_id option_ids[] = {
  7. +#if 1 //Added by Quectel
  8. + { USB_DEVICE(0x05C6, 0x9090) }, /* Quectel UC15 */
  9. + { USB_DEVICE(0x05C6, 0x9003) }, /* Quectel UC20 */
  10. + { USB_DEVICE(0x2C7C, 0x0125) }, /* Quectel EC25 */
  11. + { USB_DEVICE(0x2C7C, 0x0121) }, /* Quectel EC21 */
  12. + { USB_DEVICE(0x05C6, 0x9215) }, /* Quectel EC20 */
  13. + { USB_DEVICE(0x2C7C, 0x0191) }, /* Quectel EG91 */
  14. + { USB_DEVICE(0x2C7C, 0x0195) }, /* Quectel EG95 */
  15. + { USB_DEVICE(0x2C7C, 0x0306) }, /* Quectel EG06/EP06/EM06 */
  16. + { USB_DEVICE(0x2C7C, 0x0296) }, /* Quectel BG96 */
  17. + { USB_DEVICE(0x2C7C, 0x0435) }, /* Quectel AG35 */
  18. + { USB_DEVICE(0x2C7C, 0x0512) }, /* Quectel EG12/EG18 */
  19. + { USB_DEVICE(0x2C7C, 0x6026) }, /* Quectel EC200 */
  20. + { USB_DEVICE(0x2C7C, 0x6120) }, /* Quectel UC200 */
  21. + { USB_DEVICE(0x2C7C, 0x6000) }, /* Quectel EC200/UC200 */
  22. +#endif
  23. { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) },
  24. { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) },
  25. { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_LIGHT) },
  26. @@ -1377,6 +1393,9 @@ static struct usb_serial_driver
  27. option_1port_device = {
  28. #ifdef CONFIG_PM
  29. .suspend = usb_wwan_suspend,
  30. .resume = usb_wwan_resume,
  31. +#if 1 //add by Quectel
  32. + .reset_resume = usb_wwan_resume,
  33. +#endif
  34. #endif
  35. };
  36. @@ -1421,6 +1440,27 @@ static int option_probe(struct usb_serial
  37. *serial,
  38. &serial->interface->cur_altsetting->desc;
  39. struct usb_device_descriptor *dev_desc =
  40. &serial->dev->descriptor;
  41. +#if 1 //Added by Quectel
  42. + //Quectel UC20's interface 4 can be used as USB Network device
  43. + if (serial->dev->descriptor.idVendor == cpu_to_le16(0x05C6) &&
  44. serial->dev->descriptor.idProduct ==
  45. + cpu_to_le16(0x9003) &&
  46. serial->interface->cur_altsetting->desc.bInterfaceNumber >= 4)
  47. + return -ENODEV;
  48. + //Quectel EC20's interface 4 can be used as USB Network device
  49. + if (serial->dev->descriptor.idVendor == cpu_to_le16(0x05C6) &&
  50. serial->dev->descriptor.idProduct ==
  51. + cpu_to_le16(0x9215) &&
  52. serial->interface->cur_altsetting->desc.bInterfaceNumber >= 4)
  53. + return -ENODEV;
  54. + if (serial->dev->descriptor.idVendor == cpu_to_le16(0x2C7C)) {
  55. + __u16 idProduct =
  56. le16_to_cpu(serial->dev->descriptor.idProduct);
  57. +
  58. + //Quectel EC200&UC200's interface 0 can be used as USB
  59. Network device (ecm, rndis)
  60. + if
  61. (serial->interface->cur_altsetting->desc.bInterfaceClass != 0xFF)
  62. + return -ENODEV;
  63. + //Quectel
  64. EC25&EC21&EG91&EG95&EG06&EP06&EM06&BG96&AG35&EG12&EG18's interface 4 can be
  65. used as USB network device (qmi,ecm,mbim)
  66. + if ((idProduct != 0x6026 && idProduct != 0x6126) &&
  67. serial->interface->cur_altsetting->desc.bInterfaceNumber >= 4)
  68. + return -ENODEV;
  69. + }
  70. +#endif
  71. +
  72. /* Never bind to the CD-Rom emulation interface */
  73. if (iface_desc->bInterfaceClass == 0x08)
  74. return -ENODEV;

C、 drivers/usb/serial/qcserial.c 
 

  1. --- a/drivers/usb/serial/qcserial.c
  2. +++ b/drivers/usb/serial/qcserial.c
  3. @@ -53,7 +53,7 @@ static const struct usb_device_id id_table[] = {
  4. {DEVICE_G1K(0x05c6, 0x9202)}, /* Generic Gobi Modem device */
  5. {DEVICE_G1K(0x05c6, 0x9203)}, /* Generic Gobi Modem device */
  6. {DEVICE_G1K(0x05c6, 0x9222)}, /* Generic Gobi Modem device */
  7. - {DEVICE_G1K(0x05c6, 0x9008)}, /* Generic Gobi QDL device */
  8. +// {DEVICE_G1K(0x05c6, 0x9008)}, /* Generic Gobi QDL device */
  9. {DEVICE_G1K(0x05c6, 0x9009)}, /* Generic Gobi Modem device */
  10. {DEVICE_G1K(0x05c6, 0x9201)}, /* Generic Gobi QDL device */
  11. {DEVICE_G1K(0x05c6, 0x9221)}, /* Generic Gobi QDL device */

D、 drivers/usb/serial/usb_wwan.c
 

  1. --- a/drivers/usb/serial/usb_wwan.c
  2. +++ b/drivers/usb/serial/usb_wwan.c
  3. @@ -456,8 +456,22 @@ static struct urb *usb_wwan_setup_urb(struct
  4. usb_serial_port *port,
  5. /* Fill URB using supplied data. */
  6. usb_fill_bulk_urb(urb, serial->dev,
  7. - usb_sndbulkpipe(serial->dev, endpoint) | dir,
  8. - buf, len, callback, ctx);
  9. + usb_sndbulkpipe(serial->dev, endpoint) | dir,
  10. + buf, len, callback, ctx);
  11. +
  12. +#if 1 //Added by Quectel for Zero Packet
  13. + if (dir == USB_DIR_OUT) {
  14. + struct usb_device_descriptor *desc =
  15. &serial->dev->descriptor;
  16. + if (desc->idVendor == cpu_to_le16(0x05C6) &&
  17. desc->idProduct == cpu_to_le16(0x9090))
  18. + urb->transfer_flags |= URB_ZERO_PACKET;
  19. + if (desc->idVendor == cpu_to_le16(0x05C6) &&
  20. desc->idProduct == cpu_to_le16(0x9003))
  21. + urb->transfer_flags |= URB_ZERO_PACKET;
  22. + if (desc->idVendor == cpu_to_le16(0x05C6) &&
  23. desc->idProduct == cpu_to_le16(0x9215))
  24. + urb->transfer_flags |= URB_ZERO_PACKET;
  25. + if (desc->idVendor == cpu_to_le16(0x2C7C))
  26. + urb->transfer_flags |= URB_ZERO_PACKET;
  27. + }
  28. +#endif
  29. return urb;
  30. }

2、内核配置

在终端执行 make menuconfig, 开始配置内核:

A、 配置 ppp

  1. 配置路径如下:
  2. Device Drivers ---> Network device support --->
  3. PPP (point-to-point protocol) support
  4. PPP BSD-Compress compression
  5. PPP Deflate compression PPP filtering
  6. PPP MPPE compression (encryption) PPP multilink support
  7. PPP over Ethernet
  8. PPP support for async serial ports
  9. PPP support for sync tty ports

B、配置支持USBNET 

  1. 配置路径如下:
  2. Device Drivers ---> Network device support --->
  3. USB Network Adapters --->
  4. Multi-purpose USB Networking Framework

C、使能 USB 串口 GSM、CDMA 驱动

  1. 配置路径如下:
  2. Device Drivers ---> USB support --->
  3. USB Serial Converter support --->
  4. USB driver for GSM and CDMA modems

 配置完成后,重新编译内核,然后使用新的内核启动开发板。如果配置成功开发板启动后会有如下信息打印:

 三、PPP  软件包编译

A、ppp-2.4.4.tar.gz编译

1、拷贝 ppp-2.4.4.tar.gz 到 Ubuntu 下,然后执行下面的命令解压:
tar -xvf ppp-2.4.4.tar.gz
解压完成得到 ppp-2.4.4 目录,进入 ppp-2.4.4 目录如图 所示:

2、使用 configure 进行配置,命令如下:
./configure
结果如图 所示:


配置完成后,使用下面的命令进行编译:
make CC=mips-linux-gnu-gcc
“CC=mips-linux-gnu”指定编译器,和开发板内核使用同一个编译器。

编译完成后,分别在 chat、pppd、pppdump、pppstats 四个目录下生成 chat、pppd、pppdump、pppstats可执行文件。

把可执行文件全部拷贝到开发板的bin目录 下。

B、自动ppp拨号

使用文件为linux-ppp-scripts_v1.2.zip,解压后获取的文件如下:

在开发板下新建/etc/ppp/peers目录:        

拷贝 quectel-chat-connect、quectel-chat-disconnect、quectel-ppp、quectel-ppp-kill 到 /etc/ppp/peers 目录下。
拷贝ip-up文到/etc/ppp目录下,请确保该文件在你的系统里有可执行权限。

修改串口:

需要修改串口,修改文件 quectel-ppp 里的串口,默认文件是ttyUSB3,修改成ttyUSB2

其他文件未修改,linux-ppp-scripts_v1.2.zip文件是购买EC200T-CN模块厂家给的驱动,网上可自行下载。

C、拨号测试:

  1. 启动 ppp 拨号:
  2. quectel-pppd.sh &

输出信息跟方案一输出一样,同样会生成/etc/ppp/resolv.conf文件,并获得IP地址:

D、挂断拨号

quectel-ppp-kill 用来挂断拨号的,pppd必须被正常的挂断,否则可能会导致你下次ppp拨号失败。

使用下面方式来调用这个脚本

./quectel-ppp-kill 

注:
在进行拨号之前一定要确保没有默认网关,如果已经设置了其他网卡的默认网关了,则4G模块没法正常上网,需要删除原来的默认网关,现以网卡eth0为例:

  1. route del default
  2. route del -host 255.255.255.255 dev eth0

如果去掉默认网关,可以直接ping www.baidu.com

四、上电自启动ppp拨号上网

在/etc目录下新建ec200t.sh
内容如下:

  1. ls /dev/ |grep ttyUSB
  2. if [ "$?" == "0" ]; then
  3.         echo "4g init ..."
  4.         cd /etc/ppp/peers/
  5.         pppd call quectel-ppp &
  6. fi

修改ec200t.sh权限 

chmod +x ec200t.sh

修改/etc/init.d/rcS,增加上电就自启动ppp拨号上网:

./etc/ec200t.sh

五、结束:

移植过程还算顺利,在测试的时候卡没有放对,插反了,在此感谢模块厂家,也感谢网友。

移植所使用的文件及测试下载地址:君正T31EC200T-CN调试-Linux文档类资源-CSDN下载

主要参考的博文:

Linux下EC20实现ppp拨号_Ahren.zhao的博客-CSDN博客_ppp拨号

如何使用4G模块实现上网功能 - 嵌入式学习小组 - 电子技术论坛 - 广受欢迎的专业电子论坛!

如有侵权,请及时联系博主删除,VX:18750903063

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/602278
推荐阅读
相关标签
  

闽ICP备14008679号