一、 开发环境
板子:海思3716C
dongle:华为EC122
虚拟机:ubuntu10.10
在这里参照了一篇博文,由于所移植的上网卡是一个型号,省去了找资料的很多麻烦,苍天啊,大地啊,感动。呵呵
http://blog.csdn.net/liuming_3385/archive/2011/02/24/6206306.aspx
二、以前也移植过一个dongle,那次是稀里糊涂的搞了半个月,最后虽然能够拨号上网了,但是不稳定,在移植中对一些知识的了解也是一知半解。通过这次的移植,了解了3G上网卡的工作流程。需要的工具:ppp-2.3.5.tar.gz udev-100.tar.bz2
1、libusb-0.1.12.tar.gz 下载地址:
libusb 是一个用C语言开发的跨平台的USB设备访问接口库。libusb 设计了一系列的外部API 为应用程序所调用,通过这些API应用程序可以操作硬件,从libusb的源代码可以看出,这些API 调用了内核的底层接口,和kernel driver中所用到的函数所实现的功能差不多,只是libusb更加接近USB 规范。使得libusb的使用也比开发内核驱动相对容易的。需要注意的是libusb有两个版本,0.1 和 1.0版本,usb-modeswitch依赖libusb,但是1.0版本的编译不过。源码里有标准的automake 工具生成的configure文件,直接交叉编译。
2、usb-modeswitch-1.1.7.tar.bz2 下载地址:
主页说明:
USB_ModeSwitch is (surprise!) a mode switching tool for controlling "flip flop" (multiple device) USB gear.
Several new USB devices (especially high-speed WAN stuff, based on cell phone chipsets containing that feature) have their MS Windows drivers onboard; when plugged in for the first time they act like a flash storage and start installing the driver from there. After installation (and on every consecutive plugging) the driver switches the mode internally, the storage device vanishes (in most cases), and a new device (like an USB modem) shows up. Modem maker "Option" calls that feature "ZeroCD (TM)" since it eliminates the need for shipping a separate driver carrier.
In the beginning, nothing of this was documented in any form and there was hardly any Linux support available.
On the good side, most of the known devices do work in both modes with the available Linux drivers like "usb-storage" or "option" (an optimized serial driver for high-speed modems).That leaves only the problem of the mode switching from storage to modem or whatever the thing is supposed to do.
Fortunately there are things like human reason, USB sniffing programs and "libusb". It is possible to eavesdrop the communication of the MS Windows driver, to isolate the command or action that does the switching and to reproduce the same thing under the rule of Linux or the BSD variants.
USB_ModeSwitch makes this process easy to handle by taking the important parameters from a configuration file and doing all the initialization and communication stuff, with heavy help from "libusb".
It is mainly used automatically - via udev events and rules - to do the switch without any user interaction. But it can also be run as a command line tool, usually when trying to make unknown devices work with it.
USB_ModeSwitch 是控制"flip flop"(多重设备)USB装置的模式转换工具, 现在一些新的USB 设备(特别是一些高速 WAN 设备,如3G数据卡)都有MS Windows的驱动程序,当第一次插入机子的时候,它们处于闪存模式,并从中提取和安装驱动。在驱动安装完毕之后,驱动马上转换模式,储存设备消失(基本上都是这样的),然后一个新的设备(比如一个USB modem)出现。有些人把这个特性叫做"ZeroCD"。
1. Usb 闪存模式:提取和安装驱动
2. 转换模式:储存设备模式转换为所需(如3G)设备模式
3. 所需设备模式:使用设备新的功能
编译修改Makefile ,指定交叉编译工具链和libusb的头文件和库的位置:
root@wang:/work/dongle/usb-modeswitch-1.1.7# cat Makefile -n
1 DESTDIR = /work/dongle/rootfs
2 PROG = usb_modeswitch
3 VERS = 1.1.7
4 CC = mipsel-linux-gcc
5 STRIP = mipsel-linux-strip
6 CFLAGS += -Wall
7 LIBS = -l usb
8 RM = /bin/rm -f
9 OBJS = usb_modeswitch.c
10 PREFIX = $(DESTDIR)/usr
11 ETCDIR = $(DESTDIR)/etc
12 UDEVDIR = $(DESTDIR)/lib/udev
13 SBINDIR = $(PREFIX)/sbin
14 MANDIR = $(PREFIX)/share/man/man1
15 CFLAGS += -I /work/dongle/rootfs/include
16 CFLAGS += -L /work/dongle/rootfs/lib
修改 usb_modeswitch.conf 文件,加入设备的信息:这一步很关键,资料不好找啊,除非生产厂提供支持。在usb-modeswitch-1.1.7目录下有device_reference.txt文件,在这里可以查到一些设备的信息,但不完整。关于设备的Vendor Product可以通过另外一种方法,在后边会看到。
root@wang:/work/dongle/usb-modeswitch-1.1.7# cat usb_modeswitch.conf
# Configuration for the usb_modeswitch package, a mode switching tool for
# USB devices providing multiple states or modes
#
# This file is evaluated by the wrapper script "usb_modeswitch_dispatcher"
# in /usr/sbin
# To enable an option, set it to "1", "yes" or "true" (case doesn't matter)
# Everything else counts as "disable"
# Disable automatic mode switching globally (e.g. to access the original
# install storage)
DisableSwitching=0
# Enable logging (results in a extensive report file in /var/log, named
# "usb_modeswitch_" (and probably others)
EnableLogging=0
# Huawei EC122
#
# #
#
# # Contributor: Anders Blomdell, Ahmed Soliman
#
DefaultVendor= 0x12d1
DefaultProduct= 0x1446
TargetVendor= 0x12d1
TargetProduct= 0x140c
MessageContent="55534243123456780000000000000011060000000000000000000000000000"
3、udev-100.tar.bz2 下载地址:
使用更高版本的udev没编译过。
udev是一个工作在用户空间的设备管理工具。在USB_ModeSwitch 的介绍中我们已经知道,USB_ModeSwitch 依赖于udev实现热插热拔。
修改Makefile:
93 prefix ?=$(PWD)/rootfs
94 etcdir = ${prefix}/etc
95 sbindir = ${prefix}/sbin
96 usrbindir = ${prefix}/usr/bin
97 usrsbindir = ${prefix}/usr/sbin
98 libudevdir = ${prefix}/lib/udev
99 mandir = ${prefix}/usr/share/man
100 configdir = ${etcdir}/udev
101 udevdir = /dev
102 DESTDIR =
103
104 INSTALL = /usr/bin/install -c
105 INSTALL_PROGRAM = ${INSTALL}
106 INSTALL_DATA = ${INSTALL} -m 644
107 INSTALL_SCRIPT = ${INSTALL_PROGRAM}
108 PWD = $(shell pwd)
109
110 CROSS_COMPILE ?=mipsel-linux-
111 CC = $(CROSS_COMPILE)gcc
112 LD = $(CROSS_COMPILE)gcc
113 AR = $(CROSS_COMPILE)ar
4、完事具备,还欠东风。设备节点准备完以后,还需要拨号工具上网。这就需要PPPD工具上场了。
修改configure文件:
root@wang:/work/dongle/ppp-2.4.5# cat configure -n
1 #!/bin/sh
2 # $Id: configure,v 1.38 2008/06/15 07:08:49 paulus Exp $
3
4 # Where to install stuff by default
5 export CC=mipsel-linux-gcc
6 DESTDIR=$PWD/rootfs/usr/local
7 SYSCONF=$PWD/rootfs/etc
运行 ./configure 生成Makefile。
修改Makefile 将install 命令中的 -s 选项去掉。
生成的工具和库中我们需要的是pppd chat rp-pppoe.so
5、将生成的可执行文件和库复制到根文件系统。将各种配置文件复制到根文件系统。usb_modeswitch.conf 将安装udev时生成的/etc/udev目录复制到根文件系统的/etc 下;将、ppp-2.4.5/etc.ppp 目录下的内容复制到/etc/ppp目录下。根据上边介绍的攻略生成PPPD 的配置文件并放到根文件系统的相应目录。
6、挂载根文件系统
#
# mount -t usbfs none /proc/bus/usb
# mount -t nfs 172.16.7.153:/nfs/7550B/rootfs/dev/ /dev/
# mount -t nfs 172.16.7.153:/nfs/7550B/rootfs/usr/ /usr/
# mount -t nfs 172.16.7.153:/nfs/7550B/rootfs/etc/ /etc/
#
#
#
#
#
# cat /proc/bus/usb/devices
T: Bus=04 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#= 1 Spd=12 MxCh= 2
B: Alloc= 0/900 us ( 0%), #Int= 0, #Iso= 0
D: Ver= 1.10 Cls=09(hub ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1
P: Vendor=0000 ProdID=0000 Rev= 2.06
S: Manufacturer=Linux 2.6.18-7.5 ohci_hcd
S: Product=BRCM OHCI
S: SerialNumber=ohci-brcm
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr= 0mA
I: If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub
E: Ad=81(I) Atr=03(Int.) MxPS= 2 Ivl=255ms
T: Bus=03 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#= 1 Spd=12 MxCh= 2
B: Alloc= 0/900 us ( 0%), #Int= 0, #Iso= 0
D: Ver= 1.10 Cls=09(hub ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1
P: Vendor=0000 ProdID=0000 Rev= 2.06
S: Manufacturer=Linux 2.6.18-7.5 ohci_hcd
S: Product=BRCM OHCI
S: SerialNumber=ohci-brcm
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr= 0mA
I: If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub
E: Ad=81(I) Atr=03(Int.) MxPS= 2 Ivl=255ms
T: Bus=02 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#= 1 Spd=480 MxCh= 2
B: Alloc= 0/800 us ( 0%), #Int= 0, #Iso= 0
D: Ver= 2.00 Cls=09(hub ) Sub=00 Prot=01 MxPS=64 #Cfgs= 1
P: Vendor=0000 ProdID=0000 Rev= 2.06
S: Manufacturer=Linux 2.6.18-7.5 ehci_hcd
S: Product=BRCM EHCI
S: SerialNumber=ehci-brcm
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr= 0mA
I: If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub
E: Ad=81(I) Atr=03(Int.) MxPS= 2 Ivl=256ms
T: Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#= 1 Spd=480 MxCh= 2
B: Alloc= 0/800 us ( 0%), #Int= 0, #Iso= 0
D: Ver= 2.00 Cls=09(hub ) Sub=00 Prot=01 MxPS=64 #Cfgs= 1
P: Vendor=0000 ProdID=0000 Rev= 2.06
S: Manufacturer=Linux 2.6.18-7.5 ehci_hcd
S: Product=BRCM EHCI
S: SerialNumber=ehci-brcm
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr= 0mA
I: If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub
E: Ad=81(I) Atr=03(Int.) MxPS= 2 Ivl=256ms
7、安装设备驱动。
# lsmod
swsysdrv 2416 0 - Live 0xc0060000
bcmdriver 15904 0 - Live 0xc0064000
yaffs 125840 2 - Live 0xc00bf000
brcmnand 94000 4 - Live 0xc0079000
# cd /usr/local/bin/
# ls
chat pppoe-discovery udevtest
comgt swapp udevtrigger
fat32format swppp-off unzip
fdisk udevcontrol usb_modeswitch
libusb-config udevd usb_modeswitch.conf
mke2fs udevinfo zip
option.ko udevmonitor
pppd udevsettle
# insmod option.ko
drivers/usb/serial/usb-serial.c: USB Serial support registered for GSM modem (1-port)
usbcore: registered new driver option
drivers/usb/serial/option.c: USB Driver for GSM modems: v0.7.1
# lsmod
option 7360 0 - Live 0xc005d000
swsysdrv 2416 0 - Live 0xc0060000
bcmdriver 15904 0 - Live 0xc0064000
yaffs 125840 2 - Live 0xc00bf000
brcmnand 94000 4 - Live 0xc0079000
#
#
8、运行udevd 工具,以守护进程运行。
# udevd -h
Usage: udevd [--help] [--daemon] [--debug-trace] [--verbose] [--version]
# udevd --daemon
# ps
PID USER VSZ STAT COMMAND
1 root 1200 S init
2 root 0 SW [migration/0]
3 root 0 SWN [ksoftirqd/0]
4 root 0 SW [migration/1]
5 root 0 SWN [ksoftirqd/1]
6 root 0 SW< [events/0]
7 root 0 SW< [events/1]
8 root 0 SW< [khelper]
9 root 0 SW< [kthread]
10 root 0 SW< [kblockd/0]
11 root 0 SW< [kblockd/1]
12 root 0 SW< [khubd]
13 root 0 SW< [kseriod]
14 root 0 SW [pdflush]
15 root 0 SW [pdflush]
16 root 0 SW< [kswapd0]
17 root 0 SW< [aio/0]
18 root 0 SW< [aio/1]
19 root 0 SW< [ata/0]
20 root 0 SW< [ata/1]
21 root 0 SW< [ata_aux]
22 root 0 SW< [scsi_eh_0]
23 root 0 SW< [scsi_eh_1]
24 root 0 SW [mtdblockd]
25 root 0 SW [romblockd]
26 root 0 SW< [pegasus]
27 root 0 SW< [kpsmoused]
47 bin 824 S portmap
48 root 1188 S telnetd
67 root 956 S /usr/bin/swsyscmd
97 root 0 SW< [kjournald]
105 root 1236 S -/bin/ash
108 root 0 SW< [rpciod/0]
109 root 0 SW< [rpciod/1]
110 root 0 SW [lockd]
122 root 900 S < udevd --daemon
123 root 1192 R ps
#
#
9、在U口插上dongle。
# usb 3-2: new full speed USB device using brcm-ohci-0 and address 2
usb 3-2: configuration #1 chosen from 1 choice
scsi2 : SCSI emulation for USB Mass Storage devices
isa bounce pool size: 16 pages
Vendor: HUAWEI Model: Mass Storage Rev: 2.31
Type: CD-ROM ANSI SCSI revision: 00
scsi 2:0:0:0: Attached scsi generic sg1 type 5
# cd /usr/local/bin/
# ls
chat pppoe-discovery udevtest
comgt swapp udevtrigger
fat32format swppp-off unzip
fdisk udevcontrol usb_modeswitch
libusb-config udevd usb_modeswitch.conf
mke2fs udevinfo zip
option.ko udevmonitor
pppd udevsettle
10、转化ROM设备为usb设备。
# usb_modeswitch -c usb_modeswitch.conf
Looking for target devices ...
No devices in target mode or class found
Looking for default devices ...
Found devices in default mode, class or configuration (1)
Accessing device 002 on bus 003 ...
Getting the current device configuration ...
OK, got current device configuration (1)
Using endpusb 3-2: usbfs: process 138 (usb_modeswitch) did not claim interface 0 before use
oints 0x08 (out) and 0x87 (in)
Using endpoints 0x08 (out) and 0x87 (in)
Inquiring device details; driver will be detached ...
Looking for active driver ...
OK, driver found ("usb-storage")
OK, driver "usb-storage" detached
SCSI inquiry data (for identification)
-------------------------
Vendor String: HUAWEI
Model String: Mass Storage
Revision String: 2.31
-------------------------
USB description data (for identification)
-------------------------
Manufacturer: HUAECHNOLOGIES
Product: HUAWEI Mobile
Serial No.: ----------------------
Setting up communication with interface 0 ...
Using endpoint 0x08 for message sending ...
Trying to send message 1 to endpoint 0x08 ...
OK, message successfully sent
Resetting response endpoint 0x87
Error resetting endpoint: -145
Resetting message endpoint 0x08
Error resetting endpoint: -145
usb 3-2: USB disconnect, address 2
Device is gone, skipping any further commands
-> Run lsusb to note any changes. Bye.
# usb 3-2: new full speed USB device using brcm-ohci-0 and address 3
usb 3-2: configuration #1 chosen from 1 choice
option 3-2:1.0: GSM modem (1-port) converter detected
usb 3-2: GSM modem (1-port) converter now attached to ttyUSB0
option 3-2:1.1: GSM modem (1-port) converter detected
usb 3-2: GSM modem (1-port) converter now attached to ttyUSB1
option 3-2:1.2: GSM modem (1-port) converter detected
usb 3-2: GSM modem (1-port) converter now attached to ttyUSB2
option 3-2:1.3: GSM modem (1-port) converter detected
usb 3-2: GSM modem (1-port) converter now attached to ttyUSB3
scsi3 : SCSI emulation for USB Mass Storage devices
# Vendor: HUAWEI Model: Mass Storage Rev: 2.31
Type: CD-ROM ANSI SCSI revision: 00
scsi 3:0:0:0: Attached scsi generic sg1 type 5
ls /dev/
bcmdebug hdc6 mtdr2 strm9
bcmdma input mtdr3 sysdev
bcmgraphics_0 intdev mtdr4 tty
bcmgraphics_1 kf2x00 mtdr5 tty0
bcmindex_0 kf2x01 mtdr6 tty1
bcmindex_1 kfir0 mtdr7 tty2
bcmindex_2 kmem mtdr8 tty3
bcmindex_3 loop0 mtdr9 tty4
bcmio loop1 null tty5
bcmkeypad loop10 pod ttyS0
bcmleds loop11 ppp ttyS1
bcmmessage loop12 ptmx ttyS2
bcmoutput_0 loop13 pts ttyS64
bcmoutput_1 loop14 ram0 ttyUSB0
bcmpaxel loop15 ram1 ttyUSB1
bcmpcm_0 loop2 random ttyUSB2
bcmpcm_1 loop3 scarda ttyUSB3
bcmpcmcapture_0 loop4 scardb urandom
bcmpcmcapture_1 loop5 scd0 usbdev3.2
bcmplay_0 loop6 scd1 usbdev3.2_ep00
bcmplay_1 loop7 sda usbdev3.2_ep08
bcmplayes_0 loop8 sda1 usbdev3.2_ep87
bcmplayes_1 loop9 sda2 usbdev3.3
bcmplayes_2 Makefile sda3 usbdev3.3_ep00
bcmplayes_3 mem sda4 usbdev3.3_ep02
bcmqamoob mtd0 sda5 usbdev3.3_ep03
bcmrecord_0 mtd1 sda6 usbdev3.3_ep04
bcmrecord_1 mtd10 sdb usbdev3.3_ep06
bcmrecord_2 mtd11 sdb1 usbdev3.3_ep08
bcmrecord_3 mtd12 sdb2 usbdev3.3_ep81
bcmremote_a mtd2 sdb3 usbdev3.3_ep82
bcmremote_b mtd3 sdb4 usbdev3.3_ep83
bcmsejinkbd mtd4 sdb5 usbdev3.3_ep84
bcmsejinrem mtd5 sdb6 usbdev3.3_ep85
bcmsettopapi mtd6 sdc usbdev3.3_ep86
bcmtransport mtd7 sdc1 usbdev3.3_ep87
bcmtuner mtd8 sdc2 usbdev3.5
bcmupggpio mtd9 sdc3 usbdev3.5_ep00
bcmupgi2c mtdblock0 sdc4 usbdev3.5_ep08
bcmvbi mtdblock1 sdc5 usbdev3.5_ep87
brcm0 mtdblock10 sdc6 usbdev3.6
console mtdblock11 sg1 usbdev3.6_ep00
docsisio mtdblock12 sr0 usbdev3.6_ep02
hda mtdblock2 sr1 usbdev3.6_ep03
hda1 mtdblock3 strm0 usbdev3.6_ep04
hda2 mtdblock4 strm1 usbdev3.6_ep06
hda3 mtdblock5 strm10 usbdev3.6_ep08
hda4 mtdblock6 strm11 usbdev3.6_ep81
hda5 mtdblock7 strm12 usbdev3.6_ep82
hda6 mtdblock8 strm2 usbdev3.6_ep83
hdc mtdblock9 strm3 usbdev3.6_ep84
hdc1 mtdr0 strm4 usbdev3.6_ep85
hdc2 mtdr1 strm5 usbdev3.6_ep86
hdc3 mtdr10 strm6 usbdev3.6_ep87
hdc4 mtdr11 strm7 zero
hdc5 mtdr12 strm8
#
到此为止生成了设别节点,下面我们拨号:
11、pppd拨号:
# pppd call cdma2000&
# No Rx Descriptor, disabling rx DMA
No Rx Descriptor, disabling rx DMA
Can't create lock file /var/lock/LCK..ttyUSB0: No such file or directory
在/var 目录下生成lock目录。
# pppd call cdma2000&
# Warning: couldn't open ppp database /var/run/pppd2.tdb
Can't create lock file /var/lock/LCK..ttyUSB0: No such file or directory
# mkdir /var/lock/
# pppd call cdma2000&
# Warning: couldn't open ppp database /var/run/pppd2.tdb
Fatal signal 11
Script /usr/local/bin/chat -s -v -f /etc/ppp/cdma2000-connect-chat finished (pid 202), status = 0x7f
Connect script failed
[1] + Done(8) pppd call cdma2000
# mkdir /var/run
# pppd call cdma2000&
# lockd: cannot monitor 172.16.7.153
lockd: failed to monitor 172.16.7.153
Warning: couldn't open ppp database /var/run/pppd2.tdb
Fatal signal 11
Script /usr/local/bin/chat -s -v -f /etc/ppp/cdma2000-connect-chat finished (pid 205), status = 0x7f
Connect script failed
# touch /var/run/pppd2.tdb
[1] + Done(8) pppd call cdma2000
# pppd call cdma2000&
# timeout set to 5 seconds
abort on (NO CARRIER)
abort on (ERROR)
abort on (NO DIALTONE)
abort on (BUSY)
abort on (NO ANSWER)
send (^MATZ^M)
expect (OK)
ATZ^M^M
OK
-- got it
send (ATD#777^M)
expect (CONNECT)
^M
ATD#777^M^M
CONNECT
-- got it
send (\d)
Script /usr/local/bin/chat -s -v -f /etc/ppp/cdma2000-connect-chat finished (pid 218), status = 0x0
Serial connection established.
using channel 1
Using interface ppp0
Connect: ppp0 <--> /dev/ttyUSB0
sent [LCP ConfReq id=0x1 ]
rcvd [LCP ConfAck id=0x1 ]
rcvd [LCP ConfReq id=0x2 ]
sent [LCP ConfAck id=0x2 ]
rcvd [CHAP Challenge id=0x3 <22527ee4763d952b0c8c1faf57230286>, name = "utstar.com"]
sent [CHAP Response id=0x3 <832bf64c4a5451605c7cb078c90a9480>, name = "CARD"]
rcvd [CHAP Success id=0x3 "\000"]
CHAP authentication succeeded:
CHAP authentication succeeded
sent [IPCP ConfReq id=0x1 ]
rcvd [IPCP ConfReq id=0x4 ]
sent [IPCP ConfRej id=0x4 ]
rcvd [IPCP ConfReq id=0x6 ]
sent [IPCP ConfAck id=0x6 ]
rcvd [IPCP ConfNak id=0x1 ]
sent [IPCP ConfReq id=0x2 ]
rcvd [IPCP ConfAck id=0x2 ]
local IP address 115.171.106.187
remote IP address 115.168.64.83
primary DNS address 219.141.140.10
secondary DNS address 219.141.136.10
# ps
PID USER VSZ STAT COMMAND
1 root 1200 S init
2 root 0 SW [migration/0]
3 root 0 SWN [ksoftirqd/0]
4 root 0 SW [migration/1]
5 root 0 SWN [ksoftirqd/1]
6 root 0 SW< [events/0]
7 root 0 SW< [events/1]
8 root 0 SW< [khelper]
9 root 0 SW< [kthread]
10 root 0 SW< [kblockd/0]
11 root 0 SW< [kblockd/1]
12 root 0 SW< [khubd]
13 root 0 SW< [kseriod]
14 root 0 SW [pdflush]
15 root 0 SW [pdflush]
16 root 0 SW< [kswapd0]
17 root 0 SW< [aio/0]
18 root 0 SW< [aio/1]
19 root 0 SW< [ata/0]
20 root 0 SW< [ata/1]
21 root 0 SW< [ata_aux]
22 root 0 SW< [scsi_eh_0]
23 root 0 SW< [scsi_eh_1]
24 root 0 SW [mtdblockd]
25 root 0 SW [romblockd]
26 root 0 SW< [pegasus]
27 root 0 SW< [kpsmoused]
47 bin 824 S portmap
48 root 1188 S telnetd
67 root 956 S /usr/bin/swsyscmd
97 root 0 SW< [kjournald]
105 root 1236 S -/bin/ash
108 root 0 SW< [rpciod/0]
109 root 0 SW< [rpciod/1]
110 root 0 SW [lockd]
122 root 900 S < udevd --daemon
157 root 0 SW< [scsi_eh_3]
158 root 0 SW< [usb-storage]
217 root 1480 S pppd call cdma2000
221 root 1192 R ps
# ifconfig
eth0 Link encap:Ethernet HWaddr 00:07:63:00:00:0B
inet addr:172.16.7.155 Bcast:172.16.7.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:7281 errors:2 dropped:2 overruns:0 frame:2
TX packets:2630 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1850283 (1.7 MiB) TX bytes:437288 (427.0 KiB)
Interrupt:16
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:16 errors:0 dropped:0 overruns:0 frame:0
TX packets:16 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1344 (1.3 KiB) TX bytes:1344 (1.3 KiB)
ppp0 Link encap:Point-to-Point Protocol
inet addr:115.171.106.187 P-t-P:115.168.64.83 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1448 Metric:1
RX packets:4 errors:0 dropped:0 overruns:0 frame:0
TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:70 (70.0 B) TX bytes:64 (64.0 B)
12、拔掉网线测试,主意这里的网线是交换机的广域网口,如果是lan口的话,NFS服务不可用。
#
# ps
PID USER VSZ STAT COMMAND
1 root 1200 S init
2 root 0 SW [migration/0]
3 root 0 SWN [ksoftirqd/0]
4 root 0 SW [migration/1]
5 root 0 SWN [ksoftirqd/1]
6 root 0 SW< [events/0]
7 root 0 SW< [events/1]
8 root 0 SW< [khelper]
9 root 0 SW< [kthread]
10 root 0 SW< [kblockd/0]
11 root 0 SW< [kblockd/1]
12 root 0 SW< [khubd]
13 root 0 SW< [kseriod]
14 root 0 SW [pdflush]
15 root 0 SW [pdflush]
16 root 0 SW< [kswapd0]
17 root 0 SW< [aio/0]
18 root 0 SW< [aio/1]
19 root 0 SW< [ata/0]
20 root 0 SW< [ata/1]
21 root 0 SW< [ata_aux]
22 root 0 SW< [scsi_eh_0]
23 root 0 SW< [scsi_eh_1]
24 root 0 SW [mtdblockd]
25 root 0 SW [romblockd]
26 root 0 SW< [pegasus]
27 root 0 SW< [kpsmoused]
47 bin 824 S portmap
48 root 1188 S telnetd
67 root 956 S /usr/bin/swsyscmd
97 root 0 SW< [kjournald]
105 root 1236 S -/bin/ash
108 root 0 SW< [rpciod/0]
109 root 0 SW< [rpciod/1]
110 root 0 SW [lockd]
122 root 900 S < udevd --daemon
157 root 0 SW< [scsi_eh_3]
158 root 0 SW< [usb-storage]
217 root 1480 S pppd call cdma2000
228 root 1192 R ps
# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
115.168.64.83 0.0.0.0 255.255.255.255 UH 0 0 0 ppp0
172.16.7.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
0.0.0.0 0.0.0.0 0.0.0.0 U 0 0 0 ppp0
# ping
PING (61.135.169.105): 56 data bytes
64 bytes from 61.135.169.105: seq=0 ttl=54 time=174.563 ms
64 bytes from 61.135.169.105: seq=1 ttl=54 time=176.748 ms
64 bytes from 61.135.169.105: seq=2 ttl=54 time=176.766 ms
64 bytes from 61.135.169.105: seq=3 ttl=54 time=188.764 ms
64 bytes from 61.135.169.105: seq=4 ttl=54 time=174.761 ms
64 bytes from 61.135.169.105: seq=5 ttl=54 time=177.752 ms
64 bytes from 61.135.169.105: seq=6 ttl=54 time=188.751 ms
64 bytes from 61.135.169.105: seq=7 ttl=54 time=193.745 ms
--- ping statistics ---
8 packets transmitted, 8 packets received, 0% packet loss
round-trip min/avg/max = 174.563/181.481/193.745 ms
总结一下,其实借助udev设备,可以实现dongle的热插热拔,这需要编写udev脚本。以后在学习了。