I am currently trying to get my Android-Phone connected to my Windows machine acting as HID, RNDIS and MASS_STORAGE device simultaneously. Each of those Modes as single mode is working fine but I cant get them combined properly, for example, i can use HID, MASS_STORAGE but norfilter filter HID, RNDIS. Best working practice at the moment is Setting the USB Mode via shell e.g.
setprop sys.usb.config mass_storage,adb
I also worked on using:
echo 0 > /sys/class/android_usb/android0/enable
echo ecm,adb > /sys/class/android_usb/android0/functions
echo 1 > /sys/class/android_usb/android0/enable
That way I also could get the network interface ecm0 going.
From all read on the web, i could use sysfs or configfs to setup my own gadget with different functions. Therefore I would have to mount /config as configs on my Phone but no matter what I try the /config directory stays empty and read-only.
Does anyone know a proper way to setup USB-Gadget in an Android Shell?
thanks for your answer I worked on it again and found a way to figure this out.
First you need to disable the USB-Port
One very important thing is the right "functions"-String
In my case the hid functions are appended automatically by the Kernel otherwise one would have to add that.
The other VERY important thing is to set the Vendor and Product id's via:
If you use the Vendor and Product id's of an existing device Windows10 will load the driver for that device automatically.
A list of Vendor/Product id's for USB devices can be found here:
http://www.linux-usb.org/usb.ids
Finally you need to reenable the USB port
If you want to use tethering you would of course need to configure that as well. In my case i managed to use my Android device as Hid,Storage and Rndis device in Windows10 successfully.
Hope this helps someone ;)
as far as i know it is not possible to use the USB device classes like i.e. mass storage, PTP , MTP, RNDIS ( tethering ),... simultaneously because in a composite device like a smartphone the device classes are defined on interface level and in USB protocol only one interface can be claimed at an instant
you can check this using
lsusb -v
for my smartphone the output is ( in tethering mode )you can write code to switch the interfaces programmatically ( and ensure that the appropriate drivers / kernel modules for each interface are loaded ) you can not use them simultaneously ...