赞
踩
内核下宏支持:
ppp: CONFIG_PPP=y CONFIG_PPP_BSDCOMP=y CONFIG_PPP_DEFLATE=y CONFIG_PPP_FILTER=y CONFIG_PPP_MPPE=y CONFIG_PPP_MULTILINK=y CONFIG_PPPOE=y CONFIG_PPPOLAC=y CONFIG_PPPOPNS=y CONFIG_PPP_ASYNC=y CONFIG_PPP_SYNC_TTY=y CONFIG_SLIP=y CONFIG_SLHC=y rndis: CONFIG_USB_USBNET=y CONFIG_USB_NET_CDCETHER=y CONFIG_USB_NET_RNDIS_HOST=y options: CONFIG_USB_SERIAL=y CONFIG_USB_SERIAL_WWAN=y CONFIG_USB_SERIAL_OPTION=y
kernel下涉及文件:
drivers/usb/serial/option.c
drivers/usb/serial/usb_wwan.c
添加模块的vid和pid,找到drivers/usb/serial/option.c文件中option_ids数组
static const struct usb_device_id option_ids[] = {
{ USB_DEVICE(0x2C7C, 0x0900) },
.....
{}
}
重新编译内核,烧写到开发板,可以看到模块默认为ncm,但加载的节点只有两个,且发送不了at指令。
将drivers/usb/serial/option.c文件中option_probe函数做如下修改:
#if 0 //Added by Quectel 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; 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); __u8 bInterfaceNumber = serial->interface->cur_altsetting->desc.bInterfaceNumber; //Quectel module's some interfaces can be used as USB Network device (ecm, rndis, mbim) if (serial->interface->cur_altsetting->desc.bInterfaceClass != 0xFF) return -ENODEV; if ((idProduct&0xF000) == 0x6000) { //ASR interface 4 is modem port } else if ((idProduct&0xF000) == 0x8000) { //HISI interface 0 is NCM if (bInterfaceNumber == 0) return -ENODEV; } else if ((idProduct&0xF000) == 0x0000) { //MDM interface 4 is QMI if (bInterfaceNumber >= 4) { return -ENODEV; } } } #endif
添加零包机制,在drivers/usb/serial/usb_wwan.c,做如下修改:
找到usb_wwan_setup_urb函数: --- a/drivers/usb/serial/usb_wwan.c +++ b/drivers/usb/serial/usb_wwan.c @@ -504,7 +504,13 @@ static struct urb *usb_wwan_setup_urb(struct usb_serial_port *port, usb_fill_bulk_urb(urb, serial->dev, usb_sndbulkpipe(serial->dev, endpoint) | dir, buf, len, callback, ctx); - + #if 1 + if (dir == USB_DIR_OUT) { + struct usb_device_descriptor *desc = &serial->dev->descriptor; + if (desc->idVendor == cpu_to_le16(0x2C7C)) + urb->transfer_flags |= URB_ZERO_PACKET; + } + #endif return urb; }
做完以上步骤重新编译,烧写到开发板,将会看到完整加载后的ttyUSB节点和usb0网卡节点
一切准备就绪可以通过以下命令来进行测试网络。
直接进行拨号:dhclient -v usb0 或者 udhcpc -i usb0
如果有问题的话可通过at指令来配置。
(1)at指令配置:
at+qcfg="ethernet",0 //配置成USB模式
at+qcfg="nat",0 //配置成网卡模式
at+qcfg="usbnet",5 //配置NCM拨号方式
at+qcfg="usbnet",1 //ecm
AT+QCFG="usbnet",3 //rndis
重启生效,发送at指令at+cfun=1,1
(2) at+qeng=”servingcell”确认是否注网,注网后,at+qnetdevctl=1,1,1执行拨号
(3) ifconfig –a查看网卡,route –n查看路由表,然后用ping命令测试网络
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。