usb gadget composite:
echo 0 > /sys/class/android_usb/android0/enable
echo mass_storage > /sys/class/android_usb/android0/functions 也可以 echo "mass_storage,rndis_qc,ffs" > /sys/class/android_usb/android0/functions
echo 1 > /sys/class/android_usb/android0/enable
echo /dev/mmcblk0p2 > /sys/class/android_usb/f_mass_storage/lun/file
因为不能共享存储,所以需要动态切换
echo "/sbin/hotplug" > /proc/sys/kernel/hotplug
#!/bin/sh
if [ "${SUBSYSTEM}" = "android_usb" ]; then
if [ "${USB_STATE}" = "CONNECTED" ]; then
umount /my/mount/point/
echo /dev/mmcblk0p2 >
/sys/class/android_usb/f_mass_storage/lun/file
fi
if [ "${USB_STATE}" = "DISCONNECTED" ]; then
mount /my/mount/point/
fi
fi
exit 1
原文地址:https://www.cnblogs.com/stachal/p/8759162.html