I’ve spent some time today to test a Huawey E3372 dongle with Hilink mode. This dongle is enumerated as a mass storage device (for windows compatibility) and then needs to be switched to Hilink mode in order to get network access. This can be performed via usb_modeswitch or the ppp widget app (not operational on Hikey960), then I went for usb_modeswitch.
1. Build/Download usb_modeswitch for Android
There is no Android version of usb_modeswitch, so I created my own repository (https://github.com/loicpoulain/usb-modeswitch), copied the last version from official website (http://www.draisberghof.de/usb_modeswitch/) and applied minimal modification to make it buildable in Android tree. This project can be cloned in external AOSP directory and built with mm. I also uploaded the arm64 binary to https://github.com/loicpoulain/armbin/blob/master/android/aarch64/usb_modeswitch which can be directly pushable on Hikey960.
2. Plug the Huawey E3372 to Hikey960
As expected the dongle is enumerated as a mass storage:
[ 3212.692637] usb 1-1.1: New USB device found, idVendor=12d1, idProduct=1f01
[ 3212.699855] usb 1-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 3212.707882] usb 1-1.1: Product: HUAWEI_MOBILE
[ 3212.712417] usb 1-1.1: Manufacturer: HUAWEI_MOBILE
[ 3212.790387] usb-storage 1-1.1:1.0: USB Mass Storage device detected
3. Switch to HiLink mode
From root command line (serial or adb), I applied the following command:
> ./usb_modeswitch -J -v 0x12d1 -p 0x1f01
(-J is to switch to HiLink mode)
Then the usb dongle switched to cdc ethernet mode:
[ 3368.481808] usb 1-1.1: new high-speed USB device number 10 using xhci-hcd
[ 3368.593992] usb 1-1.1: New USB device found, idVendor=12d1, idProduct=14dc
[ 3368.601107] usb 1-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 3368.608904] usb 1-1.1: Product: HUAWEI_MOBILE
[ 3368.613730] usb 1-1.1: Manufacturer: HUAWEI_MOBILE
[ 3368.839554] cdc_ether 1-1.1:1.0 eth0: register ‘cdc_ether’ at usb-xhci-hcd.2.auto-1.1, CDC Ethernet Device, 0c:5b:8f:27:9a:64
[ 3368.894191] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
At this point network interface is ready and provisioned with an IP address:
eth0 Link encap:Ethernet HWaddr 0c:5b:8f:27:9a:64 Driver cdc_ether
inet addr:192.168.8.100 Bcast:192.168.8.255 Mask:255.255.255.0
inet6 addr: fe80::1c4d:503f:c9f6:69c4/64 Scope: Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:85 errors:0 dropped:0 overruns:0 frame:0
TX packets:58 errors:0 dropped:0 overruns:0 carrier:0
RX bytes:23366 TX bytes:5321
3. Configure the dongle
Android detects the dongle as a standard ethernet link (in the same way as a usb ethernet dongle). If your SIM card does not have PIN code internet is directly available, else you need to access the dongle web interface to configure it (IP is 192.168.8.1).
For sure ‘mode-switch’ can be scripted and enabled on uevent or at board init.