首先 是在kernel中添加支持simcom的驱动
在kernel/drivers/usb/serial/option.c中添加
/*SIMCom product*/
#define SIMCOM_WCDMA_VENDOR_ID 0x0E8D
#define SIMCOM_WCDMA_PRODUCT_ID 0x00A5
static const struct usb_device_id option_ids[] = {
{ USB_DEVICE(SIMCOM_WCDMA_VENDOR_ID, SIMCOM_WCDMA_PRODUCT_ID)},
。。。。。。
}
static struct usb_driver option_driver = {
.name = "option",
.probe = usb_serial_probe,
.disconnect = usb_serial_disconnect,
#ifdef CONFIG_PM
.suspend = usb_serial_suspend,
.resume = usb_serial_resume,
.reset_resume = usb_serial_resume,//simcom
.supports_autosuspend = 1,
#endif
.id_table = option_ids,
.no_dynamic_id = 1,
};
1619 /* Don't bind network interface on mt6229, it is handled by a separate module */
1620 if (serial->dev->descriptor.idVendor == MT6229_VENDOR_ID &&
1621 serial->dev->descriptor.idProduct == MT6229_PRODUCT_ID)
1622 {
1623 printk("%s:mt6229 exit\n",__func__);
1624 return -ENODEV;
1625 }
1626
1627 //simcom
1628 if(serial->dev->descriptor.idVendor == SIMCOM_WCDMA_VENDOR_ID &&
1629 serial->dev->descriptor.idProduct == SIMCOM_WCDMA_PRODUCT_ID)
1630 {
1631 #ifdef CONFIG_PM
1632 //serial->interface->needs_remote_wakeup = 1;/*autosuspend (15s delay)*/
1633 //device_init_wakeup(&serial->interface->dev,1);
1634 //serial->dev->autosuspend_delay = 15 * HZ;
1635 printk("erial->dev->descriptor.idVendor == SIMCOM_WCDMA_VENDOR_ID &&\n");
1636 pm_runtime_set_autosuspend_delay(&serial->dev,12*1000);
1637 usb_enable_autosuspend(serial->dev);
1638 #endif
1639 }
1640
1641 data = serial->private = kzalloc(sizeof(struct usb_wwan_intf_private), GFP_KERNEL);
在kernel/drivers/usb/serial/usb_wwan.c中添加
514 /* outdat endpoints */
515 for (j = 0; j < N_OUT_URB; ++j) {
516 portdata->out_urbs[j] = usb_wwan_setup_urb(serial,
517 port->
518 bulk_out_endpointAddress,
519 USB_DIR_OUT,
520 port,
521 portdata->
522 out_buffer
523 [j],
524 OUT_BUFLEN,
525 usb_wwan_outdat_callback);
526 portdata->out_urbs[j]->transfer_flags |= URB_ZERO_PACKET;//simcom
527 }
528 }
529 }
在make menuconfig中usb serial support中选择支持 USB driver for GSM and CDMA modems
在Generic Driver Options中选择支持 Automount devtmpfs at /dev,after the kernel mounted the rootfs
然后编译内核,烧写到板子中如果打印中有
[ 45.116680] option 3-1.3:1.2: GSM modem (1-port) converter detected
[ 45.125095] usb 3-1.3: GSM modem (1-port) converter now attached to ttyUSB0
[ 45.132469] option 3-1.3:1.3: GSM modem (1-port) converter detected
[ 45.140969] usb 3-1.3: GSM modem (1-port) converter now attached to ttyUSB1
[ 45.148499] option 3-1.3:1.4: GSM modem (1-port) converter detected
[ 45.157293] usb 3-1.3: GSM modem (1-port) converter now attached to ttyUSB2
[ 45.164948] option 3-1.3:1.5: GSM modem (1-port) converter detected
[ 45.173682] usb 3-1.3: GSM modem (1-port) converter now attached to ttyUSB3
ls /dev/ttyUSB*
/dev/ttyUSB0
/dev/ttyUSB1
/dev/ttyUSB2
/dev/ttyUSB3
驱动就加载好了。
上网拨号功能:
在网上下载pppd源码,编译,拷贝pppd和chat工具到板子中,拨号具体使用dial和mo_3gmodule.dial
dial
connect '/system/usr/sbin/chat -v -s -r "/sbin/chat.log" -f /system/etc/ppp/peers/mo_3gmodule.dial'
/dev/ttyUSB0
novj
novjccomp
disconnect '/system/usr/sbin/chat -r "/sbin/chat.log" -e -v "" +++ath'
921600
mru 2048
user card
password card
nocrtscts
defaultroute
xonxoff
#plugin /usr/lib/pppd/winbind.so
usepeerdns
#usepeerwins
noipdefault
noauth
debug
pap-max-authreq 20
pap-restart 10
lcp-echo-failure 0
mo_3gmodule.dial
TIMEOUT 100
'' ate0
OK at
OK ats0=5
OK at+cgdcont=1,"IP","3gnet"
OK at+cgauto=0
OK at+CRC=1
OK ''
'' ATD*99#
CONNECT
执行pppd call dial
logcat看打印信息,如果出现如下打印
D/pppd ( 1728): rcvd [IPCP ConfRej id=0x2d]
D/pppd ( 1728): sent [IPCP ConfReq id=0x2e <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]
D/pppd ( 1728): rcvd [IPCP ConfRej id=0x2e]
D/pppd ( 1728): sent [IPCP ConfReq id=0x2f <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]
D/pppd ( 1728): rcvd [IPCP ConfRej id=0x2f]
D/pppd ( 1728): sent [IPCP ConfReq id=0x30 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]
D/pppd ( 1728): rcvd [IPCP ConfRej id=0x30]
D/pppd ( 1728): sent [IPCP ConfReq id=0x31 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]
D/pppd ( 1728): rcvd [IPCP ConfRej id=0x31]
D/pppd ( 1728): sent [IPCP ConfReq id=0x32 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]
D/pppd ( 1728): rcvd [IPCP ConfRej id=0x32]
D/pppd ( 1728): sent [IPCP ConfReq id=0x33 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]
D/pppd ( 1728): rcvd [IPCP ConfRej id=0x33]
D/pppd ( 1728): sent [IPCP ConfReq id=0x34 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]
D/pppd ( 1728): rcvd [IPCP ConfNak id=0x34 <addr 10.26.166.204> <ms-dns1 123.123.123.123> <ms-dns3 123.123.123.124>]
D/pppd ( 1728): sent [IPCP ConfReq id=0x35 <addr 10.26.166.204> <ms-dns1 123.123.123.123> <ms-dns3 123.123.123.124>]
D/pppd ( 1728): rcvd [IPCP ConfAck id=0x35 <addr 10.26.166.204> <ms-dns1 123.123.123.123> <ms-dns3 123.123.123.124>]
W/pppd ( 1728): Could not determine remote IP address: defaulting to 10.64.64.64
I/pppd ( 1728): local IP address 10.26.166.204
I/pppd ( 1728): remote IP address 10.64.64.64
I/pppd ( 1728): primary DNS address 123.123.123.123
I/pppd ( 1728): secondary DNS address 123.123.123.124
D/pppd ( 1728): Script /etc/ppp/ip-up started (pid 1735)
D/pppd ( 1728): Script /etc/ppp/ip-up finished (pid 1735), status = 0x0
拨号已经成功。
问题分析:
1.E/pppd ( 2118): Connect script failed
首先使用AT指令排除是硬件的问题
ATE0
AT+CSQ
检查dial和mo_3gmodule.dial 两个脚本是否有错误;通道通信的问题,用AT指令检查是否用的不是/dev/ttyUSB0;确保这两个脚本和pppd,chat工具具有可执行权限。