USB_ModeSwitch官网: USB_ModeSwitch - Handling Mode-Switching USB Devices on Linux
USB_ModeSwitch for Android 7下载: https://download.csdn.net/download/sunrain_hjb/10573201
测试环境:APQ8096、Android 7(userdebug)、HUAWEI E8372
测试步骤:
1.插入HUAWEI E8372模块并稍等片刻,运行lsusb命令检测模块状态,12d1:1f01即为HUAWEI E8372,此时为Stroage模式。
msm8996:/sys/bus/usb/devices # lsusb
Bus 001 Device 004: ID 12d1:1f01
Bus Device : ID 1d6b:
Bus Device : ID 1d6b:
2.运行命令 adb shell usbmodeswitch -W -v 12d1 -p 1f01 -M '55534243123456780000000000000011062000000101000100000000000000" 切换模式
adb shell usbmodeswitch -W -v 12d1 -p 1f01 -M ''
Take all parameters from the command line * usb_modeswitch: handle USB devices with multiple modes
* Version 2.5. (C) Josua Dietze
* Based on libusb1/libusbx ! PLEASE REPORT NEW CONFIGURATIONS ! DefaultVendor= 0x12d1
DefaultProduct= 0x1f01
MessageContent="" Look for default devices ...
found USB ID 12d1:1f01
vendor ID matched
product ID matched
found USB ID 1d6b:
found USB ID 1d6b:
Found devices in default mode ()
Access device on bus
Get the current device configuration ...
Current configuration number is
Use interface number
with class
Use endpoints 0x01 (out) and 0x81 (in) USB description data (for identification)
-------------------------
Manufacturer: HUAWEI_MOBILE
Product: HUAWEI_MOBILE
Serial No.: 0123456789ABCDEF
-------------------------
Looking for active drivers ...
OK, driver detached
Set up interface
Use endpoint 0x01 for message sending ...
Trying to send message to endpoint 0x01 ...
3.再次运行命令lsusb,检测切换后的状态,12d1:14db即切换为Modem模式后的HUAWEI E8372
msm8996:/sys/bus/usb/devices # lsusb
Bus 001 Device 005: ID 12d1:14db
Bus Device : ID 1d6b:
Bus Device : ID 1d6b:
对应的dmesg信息如下:
[ 105.249217] msm-dwc3 .hsusb: DWC3 exited from low power mode
[ 105.249255] dwc3_ext_event_notify():cancel HRTIMER
[ 105.490266] usb -: new high-speed USB device number using xhci-hcd
[ 105.631944] usb 1-1: New USB device found, idVendor=12d1, idProduct=1f01
[ 105.631965] usb -: New USB device strings: Mfr=, Product=, SerialNumber=
[ 105.631976] usb -: Product: HUAWEI_MOBILE
[ 105.631988] usb -: Manufacturer: HUAWEI_MOBILE
[ 105.631999] usb -: SerialNumber: 0123456789ABCDEF
[ 105.642186] usb-storage -:1.0: USB Mass Storage device detected
[ 105.643755] transfer actual length=, result=
[ 105.643966] scsi host1: usb-storage -:1.0
[ 105.644740] usb -: USB disconnect, device number
[ 106.220296] usb -: new high-speed USB device number using xhci-hcd
[ 106.361999] usb 1-1: New USB device found, idVendor=12d1, idProduct=14db
[ 106.362039] usb -: New USB device strings: Mfr=, Product=, SerialNumber=
[ 106.362066] usb -: Product: HUAWEI_MOBILE
[ 106.362091] usb -: Manufacturer: HUAWEI_MOBILE
[ 106.376414] cdc_ether 1-1:1.0 eth0: register 'cdc_ether' at usb-xhci-hcd.0.auto-1, CDC Ethernet Device, 0c:5b:8f:27:9a:64
[ 106.382937] cdc_ether -:1.0 eth0: kevent may have been dropped
[ 106.394406] cdc_ether -:1.0 eth0: kevent may have been dropped
[ 106.397866] cdc_ether -:1.0 eth0: kevent may have been dropped
[ 106.397879] cdc_ether -:1.0 eth0: kevent may have been dropped
[ 106.403253] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
[ 106.744979] SELinux: initialized (dev fuse, type fuse), uses mountpoint labeling
[ 114.922234] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
4.运行ifconfig命令,查看eth0的状态,并对比连接PC端时的状态
5.运行route和ping等命令,检查网络连接
msm8996:/ # route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.8.0 0.0.0.0 255.255.255.0 U eth0
6.在Chrome浏览器中测试网络连接,具体如下图所示。