• 欢迎大家分享资料!前往留言板评论即可!

如何在linux 上添加合宙4G 驱动

合宙 模组资料网 5个月前 (05-15) 58次浏览 已收录 0个评论 扫描二维码
                        <p style="color: rgb(51, 51, 51);">&nbsp; &nbsp;Air720正常启动后,通过USB连接到linux设备上,驱动正常加载后会产生如下设备:</p><p style="color: rgb(51, 51, 51);">&nbsp; &nbsp;1.Air720 系列 (1802/1802S)<br></p><p style="color: rgb(51, 51, 51);"><img style="width: 728px;" src="http://oldask.openluat.com/image/show/attachments-2019-10-BqkECMQm5daebf60a1907.jpg" class="img-responsive"></p><p style="color: rgb(51, 51, 51);">2.Air720U系列(8910)</p><p style="color: rgb(51, 51, 51);"><br></p><p style="color: rgb(51, 51, 51);"><br></p><div><h2 style="font-family: "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "WenQuanYi Micro Hei", "Microsoft Yahei", sans-serif; color: rgb(51, 51, 51);"><span style="font-weight: 700;">一、修改驱动</span></h2><h5 style="font-family: "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "WenQuanYi Micro Hei", "Microsoft Yahei", sans-serif; color: rgb(51, 51, 51);">&nbsp;&nbsp;&nbsp;</h5><h5 style="font-family: "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "WenQuanYi Micro Hei", "Microsoft Yahei", sans-serif; color: rgb(51, 51, 51);">&nbsp;&nbsp;&nbsp;&nbsp;首先需要对Linux内核驱动做一定的修改,使操作系统能够支持Air720<span style="font-weight: 700;">。</span></h5><h5 style="font-family: "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "WenQuanYi Micro Hei", "Microsoft Yahei", sans-serif; color: rgb(51, 51, 51);"><span style="font-weight: 700;"><br></span></h5><h4 style="font-family: "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "WenQuanYi Micro Hei", "Microsoft Yahei", sans-serif; color: rgb(51, 51, 51);">&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-weight: 700;">1.Add VID add PID</span></h4><h4 style="font-family: "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "WenQuanYi Micro Hei", "Microsoft Yahei", sans-serif; color: rgb(51, 51, 51);">&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size: 14px;"><font color="#ff0000"><span style="font-weight: 700;">File: [KERNEL]/drivers/usb/serial/option.c</span></font></span></h4><pre style="line-height: 1.42857;">static const struct usb_device_id option_ids[] = {<br><pre>&nbsp; &nbsp; //+add by airm2m for Air72x<br>&nbsp;   { USB_DEVICE(0x1782, 0x4e00) },    /* 720U 系列*/<br>&nbsp; &nbsp; { USB_DEVICE(0x1286, 0x4e3d) },     /* 720 系列*/<br>&nbsp; &nbsp; &nbsp;//-add by airm2m for Air72x</pre><h5 style="line-height: 1.42857;">&nbsp;{ USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) },</h5>&nbsp; &nbsp; { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) },<br>&nbsp; &nbsp; { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_LIGHT) },<br>&nbsp; &nbsp; { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_QUAD) },<br>&nbsp; &nbsp; { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_QUAD_LIGHT) },&nbsp; &nbsp;</pre><h4 style="font-family: "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "WenQuanYi Micro Hei", "Microsoft Yahei", sans-serif; color: rgb(51, 51, 51);">&nbsp;&nbsp;&nbsp;&nbsp;</h4><h4 style="font-family: "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "WenQuanYi Micro Hei", "Microsoft Yahei", sans-serif; color: rgb(51, 51, 51);">&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-weight: 700;">2. Add the Zero Packet Mechanism&nbsp;&nbsp;&nbsp;</span></h4><h5 style="font-family: "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "WenQuanYi Micro Hei", "Microsoft Yahei", sans-serif; color: rgb(51, 51, 51);">&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-weight: 700;">⦁For linux Kernel Version newer than 2.6.34:</span></h5><h5 style="font-family: "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "WenQuanYi Micro Hei", "Microsoft Yahei", sans-serif; color: rgb(51, 51, 51);">&nbsp; &nbsp; &nbsp;<span style="font-weight: 700;"><font color="#ff0000">File: [KERNEL]/drivers/usb/serial/usb_wwan.c</font></span></h5><pre style="line-height: 1.42857;">static struct urb *usb_wwan_setup_urb(struct usb_serial_port *port,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int endpoint,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int dir, void *ctx, char *buf, int len,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; void (*callback) (struct urb *))<br>{<br>&nbsp; &nbsp; struct usb_serial *serial = port->serial;<br>&nbsp; &nbsp; struct urb *urb;<br>&nbsp; &nbsp; urb = usb_alloc_urb(0, GFP_KERNEL); /* No ISO */<br>&nbsp; &nbsp; if (!urb)<br>&nbsp; &nbsp; &nbsp; &nbsp; return NULL;<br>&nbsp; &nbsp; usb_fill_bulk_urb(urb, serial->dev,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; usb_sndbulkpipe(serial->dev, endpoint) | dir,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; buf, len, callback, ctx);<br><pre>&nbsp; &nbsp; //+add by airm2m for Air72x<br>&nbsp; &nbsp; if(dir == USB_DIR_OUT){<br>&nbsp; &nbsp; &nbsp; &nbsp; struct usb_device_descriptor *desc = &serial->dev->descriptor;<br>&nbsp; &nbsp; &nbsp; &nbsp; if((desc->idVendor == cpu_to_le16(0x1286) && desc->idProduct == cpu_to_le16(0x4e3d))   )  /* 720 系列*/<br>&nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; urb->transfer_flags |= URB_ZERO_PACKET;<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; &nbsp; if((desc->idVendor == cpu_to_le16(0x1782) && desc->idProduct == cpu_to_le16(0x4e00))  )   /* 720U 系列*/<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; urb->transfer_flags |= URB_ZERO_PACKET;<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; }<br>&nbsp; &nbsp; //-add by airm2m for Air72x</pre><h5 style="line-height: 1.42857;">&nbsp; &nbsp; &nbsp; &nbsp; {</h5>&nbsp; &nbsp; return urb;<br>}</pre><div style="color: rgb(51, 51, 51);"><span style="font-weight: 700;"><br></span></div><div style="color: rgb(51, 51, 51);">&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-weight: 700;">⦁For linux Kernel Version older than 2.6.35:</span><br></div><h4 style="font-family: "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "WenQuanYi Micro Hei", "Microsoft Yahei", sans-serif; color: rgb(51, 51, 51);">&nbsp;&nbsp;&nbsp;<font color="#ff0000">&nbsp;<span style="font-size: 14px;"><span style="font-weight: 700;">File: [KERNEL]/drivers/usb/serial/option.c</span></span></font></h4><pre style="line-height: 1.42857;">static struct urb *option_setup_urb(struct usb_serial *serial, int endpoint,<br>int dir, void *ctx, char *buf, int len,<br>void (*callback)(struct urb *))<br>{<br>......<br>/* Fill URB using supplied data. */<br>usb_fill_bulk_urb(urb, serial->dev,<br>&nbsp; &nbsp; &nbsp; usb_sndbulkpipe(serial->dev, endpoint) | dir,<br>&nbsp; &nbsp; &nbsp; buf, len, callback, ctx);<br>//+add by airm2m for Air72x<br>if(dir == USB_DIR_OUT)<br>{<br><pre>&nbsp; &nbsp; &nbsp; &nbsp; struct usb_device_descriptor *desc = &serial->dev->descriptor;<br>&nbsp; &nbsp; &nbsp; &nbsp; if(desc->idVendor == cpu_to_le16(0x1286) && desc->idProduct == cpu_to_le16(0x4e3d))     /* 720 系列*/<br>&nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; urb->transfer_flags |= URB_ZERO_PACKET;<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; &nbsp; if(desc->idVendor == cpu_to_le16(0x1782) && desc->idProduct == cpu_to_le16(0x4e00))    /* 720U 系列*/<br>&nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; urb->transfer_flags |= URB_ZERO_PACKET;<br>&nbsp; &nbsp; &nbsp; &nbsp; }</pre><h5 style="line-height: 1.42857;"><br></h5>}<br>//-add by airm2m for Air72x<br>return urb;<br>}</pre><div style="color: rgb(51, 51, 51);"><br></div><h4 style="font-family: "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "WenQuanYi Micro Hei", "Microsoft Yahei", sans-serif; color: rgb(51, 51, 51);">&nbsp; &nbsp; &nbsp;<span style="font-weight: 700;">3. Add Reset Resume</span></h4><h5 style="font-family: "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "WenQuanYi Micro Hei", "Microsoft Yahei", sans-serif; color: rgb(51, 51, 51);">&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-weight: 700;">⦁For linux Kernel Version newer than 3.4:</span></h5><h5 style="font-family: "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "WenQuanYi Micro Hei", "Microsoft Yahei", sans-serif; color: rgb(51, 51, 51);">&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-weight: 700;"><font color="#ff0000">File: [KERNEL]/drivers/usb/serial/option.c</font></span></h5><pre style="line-height: 1.42857;">static struct usb_serial_driver option_1port_device = {<br>&nbsp; &nbsp; .driver = {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; .owner =&nbsp; &nbsp; THIS_MODULE,<br>&nbsp; &nbsp; &nbsp; &nbsp; .name =&nbsp; &nbsp; &nbsp;"option1",<br>&nbsp; &nbsp; },&nbsp; &nbsp;<br>&nbsp; &nbsp; ....<br>#ifdef CONFIG_PM<br>&nbsp; &nbsp; .suspend&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;= usb_wwan_suspend,<br>&nbsp; &nbsp; .resume&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = usb_wwan_resume,
    //+add by airm2m for Air720
    .reset_resume      = usb_wwan_resume,
    //-add by airm2m for Air720

endif

};

    ⦁For linux Kernel Version older than 3.5:
    File: [kernel]/drivers/usb/serial/usb-serial.c
/* Driver structure we register with the USB core */
static struct usb_driver usb_serial_driver = {
.name ="usbserial",
.probe =usb_serial_probe,
.disconnect =usb_serial_disconnect,
.suspend =usb_serial_suspend,
.resume =usb_serial_resume,
 //+add by airm2m for Air72x
          .reset_resume      = usb_serial_resume,
          //-add by airm2m for Air72x

.no_dynamic_id = 1,
};

    4. Modify Kernel Configuration

    Step 1:
    cd 
    Step 2:
    make menuconfig
    Step 3:Enable CONFIG_USB_SERIAL_OPTION
[*] Device Drivers →
  [*] USB Support →
    [*] USB Serial Converter support →
      [*] USB driver for GSM and CDMA modems

如何在linux 上添加合宙4G 驱动

    Step 4:Configure Kernel to Support PPP
[*] Device Drivers →
  [*] Network device support →
    [*] PPP (point-to-point protocol) support
如何在linux 上添加合宙4G 驱动


   5.编译内核

    make    
    将编译好的内核下载到开发板。

    

 二、模块测试

    将重新编译好的内核下载到开发板之后,待系统重新启动,如果是带RNDIS网卡的驱动,在/dev/目录下会出现如下设备节点:

如何在linux 上添加合宙4G 驱动

Air720的AT端口是/dev/ttyUSB2,现在你可以使用UART端口工具如“minicom”或“busybox microcom”测试AT功能,结果如下:
如何在linux 上添加合宙4G 驱动

转载请注明原文链接:如何在linux 上添加合宙4G 驱动
喜欢 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址