Sometime there is some steps need to be done before enabling gadget(i.e. ffs need to be mounted before active)
1 2 3 4
# Create mount point for ffs and start adbd mkdir -p "${mount_point}" mount -t functionfs adb "${mount_point}" -o uid=0,gid=0 adbd &
If no extra step is needed, we can directly enable gadget
Enable the gadget
1 2 3 4 5 6 7
# Find the available udc udc=$(ls -1 /sys/class/udc/) if [ -z $udc ]; then echo"No UDC driver registered" exit 1 fi echo"${udc}" > /sys/kernel/config/usb_gadget/g1/UDC
Compound USB Device
To setup a compound USB device, we just need to create several gadget functions and binding them with configuration(s) before enabling the gadget