- 论坛徽章:
- 0
|
使用之前在网上看了很多人的教程和经验。一开始用的是wvdial系列工具自动拨号的,后来自己做了个配置文件手动运行pppd也成功。系统环境:
2.6.30.9-96.fc11.i686.PAE #1 SMP Tue Nov 3 23:41:33 EST 2009 i686 i686 i386 GNU/Linux
大概原理就是将USB设备转为串口猫设备,然后通过chat、pppd来拨号产生ppp0设备。所以需要内核支持:
Device Drivers--->
Network device support--->
PPP (point-to-point protocol)Support
PPP multilink support (EXPERIMENTAL)
PPP filtering
PPP support for async serial ports
PPP support for sync tty ports
PPP Deflate compression
PPP BSD-Compress compression
PPP MPPE compression (encryption) (EXPERIMENTAL)
PPP over Ethernet (EXPERIMENTAL)
PPP over ATM
PPP over L2TP (EXPERIMENTAL)
USB support--->
USB Serial Converter support--->
USB driver for GSM and CDMA modems
插入3G上网卡后发现识别为cdrom设备:
#dmesg
........
........
usb 5-2: new full speed USB device using uhci_hcd and address 5
usb 5-2: device descriptor read/64, error -71
usb 5-2: New USB device found, idVendor=19d2, idProduct=0003
usb 5-2: New USB device strings: Mfr=1, Product=2, SerialNumber=4
usb 5-2: Product: TD-SCDMA USB Modem
usb 5-2: Manufacturer: ZTE Corp
usb 5-2: SerialNumber: 000000000000
usb 5-2: configuration #1 chosen from 1 choice
scsi7 : SCSI emulation for USB Mass Storage devices
usb-storage: device found at 5
usb-storage: waiting for device to settle before scanning
usb-storage: device scan complete
scsi 7:0:0:0: CD-ROM ZTE Corp CD-ROM 0.01 PQ: 0 ANSI: 0
sr1: scsi3-mmc drive: 52x/52x cd/rw tray
sr 7:0:0:0: Attached scsi CD-ROM sr1
sr 7:0:0:0: Attached scsi generic sg6 type 5
经过google 发现需要用usb_modeswitch将模式更改为tty设备
#yum install usb_modeswitch
#vi /etc/udev/rules.d/50-zte-mu351.rules
添加如下内容:
ACTION=="add", SUBSYSTEM=="usb", DRIVERS=="usb", ATTR{idVendor}=="19d2", ATTR{idProduct}=="0003", RUN+="/usr/bin/usb_modeswitch -v %s{idVendor} -p %s{idProduct} -M 5553424312345678000000000000061b000000020000000000000000000000 -R 1"
拔掉3G上网卡后要稍微等一下再插上,此时可以识别为tty设备:
#dmesg
......
......
usb 5-2: new full speed USB device using uhci_hcd and address 8
usb 5-2: device descriptor read/64, error -71
usb 5-2: New USB device found, idVendor=19d2, idProduct=0003
usb 5-2: New USB device strings: Mfr=1, Product=2, SerialNumber=4
usb 5-2: Product: TD-SCDMA USB Modem
usb 5-2: Manufacturer: ZTE Corp
usb 5-2: SerialNumber: 000000000000
usb 5-2: configuration #1 chosen from 1 choice
scsi10 : SCSI emulation for USB Mass Storage devices
usb-storage: device found at 8
usb-storage: waiting for device to settle before scanning
usb 5-2: usbfs: USBDEVFS_CONTROL failed cmd usb_modeswitch rqt 128 rq 6 len 255 ret -71
usb 5-2: usbfs: USBDEVFS_CONTROL failed cmd usb_modeswitch rqt 128 rq 6 len 255 ret -71
usb 5-2: usbfs: USBDEVFS_CONTROL failed cmd usb_modeswitch rqt 128 rq 6 len 255 ret -71
usb 5-2: usbfs: process 4381 (usb_modeswitch) did not claim interface 0 before use
usb 5-2: USB disconnect, address 8
usb 5-2: new full speed USB device using uhci_hcd and address 9
usb 5-2: device descriptor read/64, error -71
usb 5-2: New USB device found, idVendor=19d2, idProduct=0003
usb 5-2: New USB device strings: Mfr=1, Product=2, SerialNumber=4
usb 5-2: Product: TD-SCDMA USB Modem
usb 5-2: Manufacturer: ZTE Corp
usb 5-2: SerialNumber: 000000000000
usb 5-2: configuration #1 chosen from 1 choice
option 5-2:1.0: GSM modem (1-port) converter detected
usb 5-2: GSM modem (1-port) converter now attached to ttyUSB3
option 5-2:1.1: GSM modem (1-port) converter detected
usb 5-2: GSM modem (1-port) converter now attached to ttyUSB4
option 5-2:1.2: GSM modem (1-port) converter detected
usb 5-2: GSM modem (1-port) converter now attached to ttyUSB5
option 5-2:1.3: GSM modem (1-port) converter detected
usb 5-2: GSM modem (1-port) converter now attached to ttyUSB6
scsi11 : SCSI emulation for USB Mass Storage devices
usb-storage: device found at 9
usb-storage: waiting for device to settle before scanning
usb_modeswitch[4381]: segfault at 0 ip 046cfead sp bf97d420 error 4 in libusb-0.1.so.4.4.4[46cd000+7000]
option1 ttyUSB3: GSM modem (1-port) converter now disconnected from ttyUSB3
option 5-2:1.0: device disconnected
option1 ttyUSB4: GSM modem (1-port) converter now disconnected from ttyUSB4
option 5-2:1.1: device disconnected
option1 ttyUSB5: GSM modem (1-port) converter now disconnected from ttyUSB5
option 5-2:1.2: device disconnected
option1 ttyUSB6: GSM modem (1-port) converter now disconnected from ttyUSB6
option 5-2:1.3: device disconnected
usb 5-2: reset full speed USB device using uhci_hcd and address 9
option 5-2:1.3: GSM modem (1-port) converter detected
usb 5-2: GSM modem (1-port) converter now attached to ttyUSB3
option 5-2:1.2: GSM modem (1-port) converter detected
usb 5-2: GSM modem (1-port) converter now attached to ttyUSB4
option 5-2:1.1: GSM modem (1-port) converter detected
usb 5-2: GSM modem (1-port) converter now attached to ttyUSB5
usb-storage: device scan complete
scsi 11:0:0:0: CD-ROM ZTE Corp CD-ROM 0.01 PQ: 0 ANSI: 0
scsi 11:0:0:1: Direct-Access ZTE Corp Flash Disk 0.01 PQ: 0 ANSI: 0
scsi 11:0:0:2: Direct-Access ZTE Corp TF Card Reader 0.01 PQ: 0 ANSI: 0
sr1: scsi3-mmc drive: 52x/52x cd/rw tray
sr 11:0:0:0: Attached scsi CD-ROM sr1
sr 11:0:0:0: Attached scsi generic sg6 type 5
sd 11:0:0:1: Attached scsi generic sg7 type 0
sd 11:0:0:2: Attached scsi generic sg8 type 0
sd 11:0:0:2: [sdg] Attached SCSI removable disk
sd 11:0:0:1: [sdf] 124488 512-byte hardware sectors: (63.7 MB/60.7 MiB)
sd 11:0:0:1: [sdf] Write Protect is off
sd 11:0:0:1: [sdf] Mode Sense: 03 00 00 00
sd 11:0:0:1: [sdf] Assuming drive cache: write through
sd 11:0:0:1: [sdf] Assuming drive cache: write through
sdf:
sd 11:0:0:1: [sdf] Attached SCSI removable disk
如果插入USB卡后option.ko无法驱动设备(没有创建/dev/ttyUSB*设备),需要修改drivers/usb/serial/option.c,将USB设备的vendor和product添加到option_ids[]上。例如在我的开发板上:
#define ZTE_VENDOR_ID 0x19d2
#define ZTE_PRODUCT_MU35X 0x0003
.......
{ USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E220) },
{ USB_DEVICE(ZTE_VENDOR_ID, ZTE_PRODUCT_MU35X) },
.......
1、用wvdial拨号
#yum install wvdial
#vi /etc/wvdial.conf
添加如下:
Modem = /dev/ttyUSB5 #一般3个设备中的后两个都可以,但是不能同时拨号,只能同时一个用来AT指令,一个用来拨号。
Init1 = ATZ
Init3 = ATE0V1
Init5 = ATS0=0
Init6 = AT+CGDCONT=1,"IP","cmnet"
Init7 = AT+CFUN=1
Modem Type = USB Modem
Baud = 460800
New PPPD = yes
ISDN = 0
Phone = *99***1#
Password = any
Username = any
Stupid Mode = 1
#wvdial
--> WvDial: Internet dialer version 1.60
--> Cannot get information for serial port.
--> Initializing modem.
--> Sending: ATZ
OK
--> Sending: ATE0V1
OK
--> Sending: ATS0=0
OK
--> Sending: AT+CGDCONT=1,"IP","cmnet"
OK
--> Sending: AT+CFUN=1
OK
--> Modem initialized.
--> Sending: ATDT*99***1#
--> Waiting for carrier.
CONNECT
--> Carrier detected. Starting PPP immediately.
--> Starting pppd at Tue Nov 24 14:12:41 2009
--> Pid of pppd: 4663
--> Using interface ppp0
--> pppd: [10]J=[08] |
|