Linux插入华为无线网卡无法识别问题

Janna ·
更新时间:2024-11-13
· 537 次阅读

CPU:Powerpc P1014

内核:版本较老,版本3.18.16。

插入后无法例化出网口,看dmesg打印

[ 856.603371] usb 1-1.1: new high-speed USB device number 4 using fsl-ehci [ 856.696366] usb 1-1.1: New USB device found, idVendor=12d1, idProduct=1f01 [ 856.703284] usb 1-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [ 856.710642] usb 1-1.1: Product: HUAWEI_MOBILE [ 856.715034] usb 1-1.1: Manufacturer: HUAWEI_MOBILE [ 856.719845] usb 1-1.1: SerialNumber: 0123456789ABCDEF [ 856.726372] usb-storage 1-1.1:1.0: USB Mass Storage device detected [ 856.733792] scsi host1: usb-storage 1-1.1:1.0 [ 857.741958] scsi 1:0:0:0: CD-ROM HUAWEI Mass Storage 2.31 PQ: 0 ANSI: 2 [ 857.750745] scsi 1:0:0:0: Attached scsi generic sg1 type 5

发现系统检测到了,却把网卡当做了一个闪存设备。当把网卡插入我的Ubuntu系统电脑可以识别成功。

[ 467.837302] usb 3-2.1: new high-speed USB device number 8 using xhci_hcd [ 468.050958] usb 3-2.1: New USB device found, idVendor=12d1, idProduct=1f01 [ 468.050962] usb 3-2.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [ 468.050964] usb 3-2.1: Product: HUAWEI_MOBILE [ 468.050966] usb 3-2.1: Manufacturer: HUAWEI_MOBILE [ 468.050967] usb 3-2.1: SerialNumber: 0123456789ABCDEF [ 468.199562] usb-storage 3-2.1:1.0: USB Mass Storage device detected [ 468.201522] scsi host33: usb-storage 3-2.1:1.0 [ 468.219579] usbcore: registered new interface driver usb-storage [ 468.281310] usbcore: registered new interface driver uas [ 469.219011] scsi 33:0:0:0: CD-ROM HUAWEI Mass Storage 2.31 PQ: 0 ANSI: 2 [ 469.222339] sr 33:0:0:0: Power-on or device reset occurred [ 469.229746] sr 33:0:0:0: [sr1] scsi-1 drive [ 469.230103] sr 33:0:0:0: Attached scsi CD-ROM sr1 [ 469.230365] sr 33:0:0:0: Attached scsi generic sg2 type 5 [ 469.345674] usb 3-2.1: USB disconnect, device number 8 [ 474.384538] usb 3-2.2: new high-speed USB device number 9 using xhci_hcd [ 474.595088] usb 3-2.2: New USB device found, idVendor=12d1, idProduct=14db [ 474.595090] usb 3-2.2: New USB device strings: Mfr=1, Product=2, SerialNumber=0 [ 474.595092] usb 3-2.2: Product: HUAWEI_MOBILE [ 474.595092] usb 3-2.2: Manufacturer: HUAWEI_MOBILE [ 474.643835] cdc_ether 3-2.2:1.0 eth0: register 'cdc_ether' at usb-0000:03:00.0-2.2, CDC Ethernet Device, 0c:5b:8f:27:9a:64 [ 474.644024] usbcore: registered new interface driver cdc_ether [ 474.661899] cdc_ether 3-2.2:1.0 enx0c5b8f279a64: renamed from eth0 [ 474.691638] IPv6: ADDRCONF(NETDEV_UP): enx0c5b8f279a64: link is not ready

发现电脑进行了两次识别,第一次识别厂商号和设备号为idVendor=12d1, idProduct=1f01。

第二次识别为idVendor=12d1, idProduct=14db,然后成功挂载。

而我们的linux3.18.16卡在执行完第一次识别就没下文了。

通过网址(http://www.linux-usb.org/usb.ids)查阅了厂商号和设备号,发现设备号0x14db是网卡,0x1f01是这个网卡的大容量存储模式。

网上查阅资料后,终于明白这个网卡内部含有windows驱动,第一次插入的时候作为一个内存设备,并提示你安装驱动。
在安装驱动之后,驱动会自动切换USB设备的模式,存储设备将会消失新的设备将会产生(如USB类型的Modem)。这种特征被无线设备的制造商称其为“免CD”的设备。

Linux切换usb模式用到一个工具叫USB_MODESWITCH,新的内核都集成了这个工具,所以能完成自动切换,旧的内核没有,所以需要移植一个usb_modeswitch。

移植usb_modeswitch

需要移植三个东西

mkdir USB-4G && cd USB-4G 创建文件夹并进入 下载libusb-1.0.21 ,并解压 tar jvxf libusb-1.0.21.tar.bz2 下载libusb-compat-0.1.5,并解压tar jvxf libusb-compat-0.1.5.tar.bz2 下载usb_modeswitch-2.5.1, 并解压tar jvxf usb-modeswitch-2.5.1.tar.bz2

平台:powerpc

1.移植libusb-1.0.21

cd libusb-1.0.21

./configure --host=ppc-linux CC=ppc_85xxDP-gcc --prefix=/home/truman/work/examples/usb-4g/install  --enable-static  --disable-udev --disable-shared

make

make install

2.移植libusb-compat-0.1.5 cd ../libusb-compat-0.1.5/ ./configure --host=ppc-linux CC=ppc_85xxDP-gcc --prefix=/home/truman/work/examples/usb-4g/install  --disable-shared --enable-static  PKG_CONFIG_PATH=/home/lingyun/fulinux/usbmode/install/lib/pkgconfig make make install 3.移植usb-modeswitch CC = ppc_85xxDP-gcc CFLAGS += -Wall -I /home/truman/work/examples/usb-4g/install/include/libusb-1.0 -static LIBS = -L /home/truman/work/examples/usb-4g/install/lib -l usb -l usb-1.0 -l pthread -lrt

不加lrt会报一个错误:

ppc_85xxDP-gcc -o usb_modeswitch usb_modeswitch.c -Wall -I /home/truman/work/examples/usb-4g/install/include/libusb-1.0 -static -L /home/truman/work/examples/usb-4g/install/lib -l usb -l usb-1.0 -l pthread /home/truman/work/examples/usb-4g/install/lib/libusb-1.0.a(libusb_1_0_la-linux_usbfs.o): In function `op_clock_gettime': /home/truman/work/examples/usb-4g/libusb-1.0.21/libusb/os/linux_usbfs.c:2670: undefined reference to `clock_gettime' /home/truman/work/examples/usb-4g/libusb-1.0.21/libusb/os/linux_usbfs.c:2672: undefined reference to `clock_gettime' /home/truman/work/examples/usb-4g/install/lib/libusb-1.0.a(libusb_1_0_la-linux_usbfs.o): In function `find_monotonic_clock': /home/truman/work/examples/usb-4g/libusb-1.0.21/libusb/os/linux_usbfs.c:336: undefined reference to `clock_gettime' collect2: ld returned 1 exit status make: *** [usb_modeswitch] Error 1

编译成功后,将usb_modeswitch放到板卡上就可以运行了,该应用有很多用法,可以-h查看,这里用的是./usb_modeswitch -c usb_modeswitch.conf 。

usb_modeswitch.conf 是一个配置文件,里面的内容是

DefaultVendor= 0x12d1 DefaultProduct= 0x1f01 TargetVendor= 0x12d1 TargetProductList="14db,14dc" HuaweiNewMode=1

 DefaultVendor和DefaultProduct是需要切换的厂商号和设备号,TargetVendor和TargetProductList是要切换到的目的厂商号和设备号。

执行结果如下,成功切换并识别网卡。

-sh-3.2# ./usb_modeswitch -c usb_modeswitch.conf Look for target devices ... No devices in target mode or class found Look for default devices ... Found devices in default mode (1) Access device 003 on bus 001 Get the current device configuration ... Current configuration number is 1 Use interface number 0 with class 8 Use endpoints 0x01 (out) and 0x81 (in) Using standard Huawei switching message Looking for active drivers ... OK, driver detached Set up interface 0 Use endpoint 0x01 for message sending ... Trying to send message 1 to endpoint 0x01 ... OK, message successfully sent Read the response to message 1 (CSW) ... Response successfully read (13 bytes), status 0 Reset response endpoint 0x81 Reset message endpoint 0x01 Could not reset endpoint (probably harmless): -99 -> Run lsusb to note any changes. Bye! -sh-3.2# [ 75.379658] usb 1-1.1: USB disconnect, device number 3 [ 76.313396] usb 1-1.1: new high-speed USB device number 5 using fsl-ehci [ 76.406889] usb 1-1.1: New USB device found, idVendor=12d1, idProduct=14db [ 76.413806] usb 1-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=0 [ 76.421162] usb 1-1.1: Product: HUAWEI_MOBILE [ 76.425541] usb 1-1.1: Manufacturer: HUAWEI_MOBILE [ 76.435701] cdc_ether 1-1.1:1.0 eth2: register 'cdc_ether' at usb-fsl-ehci.0-1.1, CDC Ethernet Device, 0c:5b:8f:27:9a:64

现在出现两个问题:

1.每次插上网卡都需要手动敲一下切换命令,网卡才可以成功加载。 2.网卡会给我的板卡dhcp自动分配一个IP,才可以上网,但我的Linux系统裁剪过,没有dhcp功能,需要把这个功能加上才可以上网。

接下来解决这两个问题。


作者:Truman楚门



Linux 华为 无线 无线网卡

需要 登录 后方可回复, 如果你还没有账号请 注册新账号