Usb_modeswitch on air unit

hello gods of herelink
I’ve compiled libusb and usb_modeswicth tools for arm air unit unfortunately /system is read-only and I dont find a way to install it correctly
I try to switch a e3372 modem into eth lan interface mode
I tryied to set all in the same folder but looks not working

# ls
libusb1.0.so usb_modeswitch usb_modeswitch.conf 
# ./usb_modeswitch -v 12d1 -p 1f01 -c ./usb_modeswitch.conf                                                                                                                                               
# 

thank’s for any info
@Michael_Oborne any idea ?

we ship the air unit with SU capability’s.

so add it to the /data partition

Thank’s a lot ! I’ve seen air unit is SU capable but my main question is how to set libusb1.0.so correctly in lib folder (should be in /system/lib64/) is there any other folder where i can put shared lib ?? /data/app_lib or somewhere else ??

given when you run it above it didnt crash, are you sure you need to put in in there.

I’ tried 2 things :

  • use the libusb1.0.so and usb_modeswitch from remote unit on air unit and I have no output (even the standard one with “usage” when no param are given)
  • recompile usb_modeswitch and libusb :
# cd arm64-v8a/                                                                                         
# ls
libusb1.0.so usb_modeswitch 
# ./usb_modeswitch                                                                                      
WARNING: linker: /tmp/share/usbms/arm64-v8a/usb_modeswitch: unsupported flags DT_FLAGS_1=0x8000001
# cd ../armeabi-v7a/                                                                                       
# ./usb_modeswitch                                                                                      
WARNING: linker: /tmp/share/usbms/armeabi-v7a/usb_modeswitch: unsupported flags DT_FLAGS_1=0x8000001
# 

i think you might need to add more debug to the app, as the linker warning are just that, and not the app failing

in fact my compiled app is working ok on remote unit as soon as I push it on air unit I got this error I think it’s because It could not find libusb in the right folder

run it with strace

OK I finally get it to work by setting the libusb at right place (/system/lib64/)
(still have the linker warning but it gets a bit more verbose )

as result I can get my HUAWEI 4G modem goes to Hlink mode and I well get the eth0 interface

# usb_modeswitch -v 12d1 -p 1f01 -c ./usb_modeswitch.conf   
WARNING: linker: /system/bin/usb_modeswitch: unsupported flags DT_FLAGS_1=0x8000001
test
Look for target devices ...
 No devices in target mode or class found
Look for default devices ...
   product ID matched
 Found devices in default mode (1)
Access device 002 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)

USB description data (for identification)
-------------------------
Manufacturer: HUAWEI_MOBILE
     Product: HUAWEI_MOBILE
  Serial No.: 0123456789ABCDEF
-------------------------
Using standard Huawei switching message
Looking for active driver ...
 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 reading failed (error -1)
 Device is gone, skip any further commands
-> Run lsusb to note any changes. Bye!

# lsusb
Bus 001 Device 001: ID 1d6b:0002
Bus 001 Device 003: ID 12d1:14db
# ifconfig 
lmi40     Link encap:UNSPEC  
          inet addr:192.168.0.10  P-t-P:192.168.0.10  Mask:255.255.255.0 
          inet6 addr: fe80::44f5:e09e:6ca8:d124/64 Scope: Link
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1550  Metric:1
          RX packets:14971 errors:0 dropped:2 overruns:0 frame:0 
          TX packets:21528 errors:0 dropped:0 overruns:0 carrier:0 
          collisions:0 txqueuelen:500 
          RX bytes:834630 TX bytes:1237393 

eth0      Link encap:Ethernet  HWaddr 00:1e:10:1f:00:00
          inet6 addr: fe80::21e:10ff:fe1f:0/64 Scope: Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:12 errors:0 dropped:0 overruns:0 frame:0 
          TX packets:2 errors:0 dropped:0 overruns:0 carrier:0 
          collisions:0 txqueuelen:1000 
          RX bytes:1048 TX bytes:160 

vxlan1    Link encap:Ethernet  HWaddr 46:18:60:e1:28:7e
          inet6 addr: fe80::4418:60ff:fee1:287e/64 Scope: Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0 
          TX packets:46 errors:0 dropped:0 overruns:0 carrier:0 
          collisions:0 txqueuelen:1000 
          RX bytes:0 TX bytes:2888 

br-vxlan  Link encap:Ethernet  HWaddr b8:8d:f1:ff:34:69
          inet addr:192.168.144.10  Bcast:192.168.144.255  Mask:255.255.255.0 
          inet6 addr: fe80::ba8d:f1ff:feff:3469/64 Scope: Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:12 errors:0 dropped:0 overruns:0 frame:0 
          TX packets:12 errors:0 dropped:0 overruns:0 carrier:0 
          collisions:0 txqueuelen:1000 
          RX bytes:1048 TX bytes:760 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0 
          inet6 addr: ::1/128 Scope: Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:116380 errors:0 dropped:0 overruns:0 frame:0 
          TX packets:116380 errors:0 dropped:0 overruns:0 carrier:0 
          collisions:0 txqueuelen:1 
          RX bytes:8196912 TX bytes:8196912 

br-vxlan:0 Link encap:Ethernet  HWaddr b8:8d:f1:ff:34:69
          inet addr:192.168.42.10  Bcast:192.168.42.255  Mask:255.255.255.0 
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

driver loading looks ok
status led on modem goes to solid on 4G network every thing looks ok

unfortunately I should get a IPv4 address from CGNAT but I dont … and ping throug eth0 is obviously not working
I think it’s due to default bridging of eth0 into br-vxlan interface config to work with usb to eth converter
is it possible to get rid of that ??

# ping 8.8.8.8
connect: Network is unreachable
# ping -I eth0  8.8.8.8                                                                                        
ping: Warning: source address might be selected on device other than eth0.
PING 8.8.8.8 (8.8.8.8) from 192.168.42.10 eth0: 56(84) bytes of data.
From 192.168.42.10: icmp_seq=1 Destination Host Unreachable
From 192.168.42.10: icmp_seq=2 Destination Host Unreachable
From 192.168.42.10: icmp_seq=3 Destination Host Unreachable
From 192.168.42.10: icmp_seq=4 Destination Host Unreachable
From 192.168.42.10: icmp_seq=5 Destination Host Unreachable
From 192.168.42.10: icmp_seq=6 Destination Host Unreachable
From 192.168.42.10: icmp_seq=7 Destination Host Unreachable
From 192.168.42.10: icmp_seq=8 Destination Host Unreachable
From 192.168.42.10: icmp_seq=9 Destination Host Unreachable
^C
--- 8.8.8.8 ping statistics ---
10 packets transmitted, 0 received, +9 errors, 100% packet loss, time 9132ms
pipe 4

try
su
start dhcpcd

not sure if this will help or not

to stop the auto bridge add

su
stop usbethx

@Olivier_Gasté can you share your compiled usb_modeswitch binaries to experiment with?

yea with pleasure
https://drive.google.com/drive/folders/1gk2h9wt5nAFBQ663cQ1A9jF5k8tTnrle?usp=sharing
you need to set .so file into /system/lib64
and you can put bin in /system/bin

I can Have a eth0 not linked to br-vxlan but it start down and even iff I’m turning it up
I get no IPV4
and obviously I have no route passing by eth0
I’m still searching
thank’s for the help

eth0      Link encap:Ethernet  HWaddr 00:1e:10:1f:00:00
          inet6 addr: fe80::21e:10ff:fe1f:0/64 Scope: Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:7 errors:0 dropped:0 overruns:0 frame:0 
          TX packets:13 errors:0 dropped:0 overruns:0 carrier:0 
          collisions:0 txqueuelen:1000 
          RX bytes:416 TX bytes:834 

ok,thdhcpcd command i gave above if for dhcp on the bridge. you will need to start dhcp manualy to assign that interface an ip.

things I dont understand is that normaly it should get it IP from CGNAT router of LTE provider …

YES !!!

# ping -I eth0 8.8.8.8                                                                                                                                                                                            
PING 8.8.8.8 (8.8.8.8) from 192.168.8.102 eth0: 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=110 time=35.5 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=110 time=34.2 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=110 time=32.4 ms

thank’s a lot !!!
I finaly get it to work !!
so for those looking to do same

first : you need correctly libusb.so lib and usb-modswitch tool installed
you can get source and compile it from here https://github.com/joerg65/usb_modeswitch_Android
or simply get it from my previous message

  • connect your host directly to usb on air unit
  • authorize write on system partition
    adb shell "su 0 mount -o rw,remount /system"
  • autorise push on tmp folder
    adb shell "su 0 chmod +w /tmp"
  • then copy libusb.so and usb-modswitch to tmp folder
    adb push <path to your file on host>/libusb1.0.so /tmp/
    adb push <path to your file on host>/usb-modeswitch /tmp/
  • moves them to correct folder under a shell
    adb shell
$su
#mv /tmp/libusb1.0.so /system/lib64/
#mv /tmp/usbmodeswitch/system/bin/

if you are using like me a HUAWEI 3372 4G modem you will need a conf file for usb-modeswitch tool
you can directly write string code it’s up to you ( google is your friend) but I prefer readable conf file

  • just put the following into a usb-modeswitch.conf file and then push it to tmp and moves it to /etc/ folder
 TargetVendor=0x12d1
 TargetProductList="14db,14dc"
 HuaweiNewMode=1
 NoDriverLoading=1
  • unplug your adb host of air unit and get connected to remote
  • reboot the air unit
  • connect your 4G modem to air unit USB OTG port (please use an externaly powered usb cable)
  • as explained here : Herelink Ethernet - #3 by Michael_Oborne
adb shell (gets you into the gcs unit)
adb connect 192.168.0.10
adb -s 192.168.0.10:5555 shell

you will reach a shell on air unit

  • disable auto bridging of eth0 interface (thank’s a lot @Michael_Oborne I would have never find this one without you)
su
stop usbethx
  • check your modem is well registered on usb
# lsusb
Bus 001 Device 001: ID 1d6b:0002
Bus 001 Device 003: ID 12d1:1f01
  • switch the modem into hilink mode (if you are using another modem you should probably use wwan0 mode and it’s a litel bit more confuse to get qmi working)
# usb_modeswitch -v 12d1 -p 1f01 -c /etc/usb_modeswitch.conf
  • check your eth0 is registered with : ip a
  • wake up the interface : ifconfig eth0 up
  • start dhcpd on eth0 : dhcpcd-6.8.2 eth0 (it will setup route for you)
  • check your fresh IPv4
  • check you can ping outside : ping -I eth0 8.8.8.8

I still need to setup a dns correctly if someone can help it looks iptable is empty and seems android dont care about resolve.conf
thank’s for all helps

3 Likes

to set a dns:
I’ve try to add a /syste/etc/resolv.conf
with nameserver 8.8.8.8 inside (I tested 8.8.4.4 and some others found around internet)
I’m still unable to ping 8.8.8.8
but www.google.com is still unknown host

How do you command
su
It is locked for me

you have to be aware that su is lock on remote but available on air unit
here we speaking on putting 4G network capability on air unit

same result using setprop

# setprop net.dns1 8.8.8.8 
# getprop | grep dns                                                                                    
[net.change]: [net.dns1]
[net.dns1]: [8.8.8.8]
# ping google.com
ping: unknown host google.com
# ping 8.8.8.8                                                                                          
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=110 time=95.8 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=110 time=34.5 ms
^C
--- 8.8.8.8 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 34.513/65.193/95.873/30.680 ms