imx6ull下移植Quectel EC20 4G模块

                     imx6ull下移植Quectel EC20 4G模块 一、修改驱动         drivers/usb/serial/option.c:            626 static const struct usb_device_id option_ids[] = {       ...

                     imx6ull下移植Quectel EC20 4G模块

一、修改驱动

        drivers/usb/serial/option.c:

            626 static const struct usb_device_id option_ids[] = {
            627         { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) },
            628         { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) },
            629         { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_LIGHT) },
              ...
            1808         #if 1 //Added by Quectel
            1809         { USB_DEVICE(0x05C6, 0x9090) }, /* Quectel UC15 */
            1810         { USB_DEVICE(0x05C6, 0x9003) }, /* Quectel UC20 */
            1811         { USB_DEVICE(0x2C7C, 0x0125) }, /* Quectel EC25/EC20 R2.0 */
            1812         { USB_DEVICE(0x2C7C, 0x0121) }, /* Quectel EC21 */
            1813         { USB_DEVICE(0x05C6, 0x9215) }, /* Quectel EC20 */
            1814         { USB_DEVICE(0x2C7C, 0x0191) }, /* Quectel EG91 */
            1815         { USB_DEVICE(0x2C7C, 0x0195) }, /* Quectel EG95 */
            1816         { USB_DEVICE(0x2C7C, 0x0306) }, /* Quectel EG06/EP06/EM06 */
            1817         { USB_DEVICE(0x2C7C, 0x0296) }, /* Quectel BG96 */
            1818         #endif
            1830 static struct usb_serial_driver option_1port_device = {
            1831         .driver = {
            1832                 .owner =        THIS_MODULE,
            1833                 .name =         "option1",
            1834         },
            1835         .description       = "GSM modem (1-port)",
            1836         .id_table          = option_ids,
            1837         .num_ports         = 1,
               ...
            1853 #ifdef CONFIG_PM
            1854         .suspend           = usb_wwan_suspend,
            1855         .resume            = usb_wwan_resume,
            1856         #if 1 //Added by Quectel & Air720
            1857         .reset_resume      = usb_wwan_resume,
            1858         #endif

            1859 #endif

    drivers/usb/serial/usb_wwan.c

            474 static struct urb *usb_wwan_setup_urb(struct usb_serial_port *port,
            475                                       int endpoint,
            476                                       int dir, void *ctx, char *buf, int len,
            477                                       void (*callback) (struct urb *))
            478 {
            479         struct usb_serial *serial = port->serial;
            480         struct urb *urb;
             ...
            495#if 1 //Added by Quectel for Zero Packet
            496     if (dir == USB_DIR_OUT) {
            497         struct usb_device_descriptor *desc = &serial->dev->descriptor;
            498         if (desc->idVendor == cpu_to_le16(0x05C6) && desc->idProduct == cpu_to_le16(0x9090))
            499             urb->transfer_flags |= URB_ZERO_PACKET;
            500         if (desc->idVendor == cpu_to_le16(0x05C6) && desc->idProduct == cpu_to_le16(0x9003))
            501             urb->transfer_flags |= URB_ZERO_PACKET;
            502         if (desc->idVendor == cpu_to_le16(0x05C6) && desc->idProduct == cpu_to_le16(0x9215))
            503             urb->transfer_flags |= URB_ZERO_PACKET;
            504         if (desc->idVendor == cpu_to_le16(0x2C7C))
            505             urb->transfer_flags |= URB_ZERO_PACKET;
            506    }
            507 #endif

二、配置kernel

    make menuconfig:

        Device Drivers  --->
            [*] USB support  --->
                <*>   USB Serial Converter support  --->
                    <*>   USB driver for GSM and CDMA modems
            [*] Network device support  --->
                <*>   PPP (point-to-point protocol) support
                <*>     PPP BSD-Compress compression
                <*>     PPP Deflate compression
                [*]     PPP filtering
                <*>     PPP MPPE compression (encryption)
                [*]     PPP multilink support
                <*>     PPP over Ethernet
                <*>     PPP support for async serial ports
                <*>     PPP support for sync tty ports    当系统启动后,可以看到/dev/目录下产生ttyUSB0-3节点,说明驱动移植成功:attachments-2020-04-mTSD21rI5e84370d7579a.png

三、获取环境状态

    获取模块的IMEI号:

        cat /ttyUSB2 &
        echo -e "AT+GSN\r\n" > /dev/ttyUSB2
attachments-2020-04-yaaTZ8OT5e8439e7edec3.png
    判断SIM卡状态:
           cat /ttyUSB2 &

           echo -e "AT+CPIN?\r\n" > /dev/ttyUSB2 

attachments-2020-04-Ig1iROMk5e843ae3dcf86.png        获取信号质量:

            cat /dev/ttyUSB2 &

            echo -e "AT+CSQ\r\n" > /dev/ttyUSB2

attachments-2020-04-3GClP8jb5e843bc3b49ba.png

四、拨号

    在/etc/ppp/目录下创建quectel目录,并在quectel目录下新建 quectel-chat-connect、quectel-ppp、quectel-pppd.sh、quectel-chat-disconnect和quectel-ppp-kill拨号脚本:

attachments-2020-04-698ZURak5e843619e6373.png    拨号测试:

       /etc/ppp/quectel/quectel-pppd.sh

attachments-2020-04-qhjRPOqu5e843bf0abeca.pngattachments-2020-04-9bQG30zE5e843c178c8e8.png

attachments-2020-04-entZqxMT5e843c5505394.png    取消拨号:

        /etc/ppp/quectel/quectel-ppp-kill


五、模块电源管理

    从嵌入式的角度来看,EC20 4G模块的功耗是很高的,因此在我们不需要使用模块的时候,我们可以将模块关闭,达到节能的目的。

    可以通过控制模块的PWR引脚来控制模块的工作状态,在内核中增加实现该功能的驱动(源码参考附件/drivers/misc/ido_4g_ctrl.c)。

    dts的配置:

        ido_4g_ctrl {

                compatible = "quectel,4g_ec20";

                pinctrl-names = "default";

                pinctrl-0 = <&pinctrl_ido_4g_ctrl>;

                gpio-reset = <&gpio3 2 0>;

                gpio-power-en = <&gpio3 0 0>;

                status = "okay";

        };

    测试:
        首先通过/dev/4g_pwr节点来判断该驱动是否加载成功
attachments-2020-04-Df9mKNpn5e843ec261560.png        关闭模块电源:echo OFF > /dev/4g_pwr,/dev/ttyUSB0-3节点将消失
attachments-2020-04-4XsAXZLg5e843fc10b9a3.png        重新打开模块电源:echo ON > /dev/4g_pwr,/dev/ttyUSB0-3节点将重新出现

attachments-2020-04-udezuk3E5e844018b0b6d.png

移植EC20.zip

  • 发表于 2020-04-01 15:26
  • 阅读 ( 51 )
  • 分类:nxp imx6

0 条评论

请先 登录 后评论
ronnie
ronnie

11 篇文章

作家榜 »

  1. ronnie 11 文章
  2. FU 5 文章
  3. toca 4 文章
  4. 大飞 3 文章
  5. Vivek 3 文章
  6. jack-fang 2 文章
  7. 刘崇凯 0 文章
  8. nanluqiao 0 文章