diff options
authorAmit Pundir <>2015-07-18 20:22:07 +0530
committerJohn Stultz <>2015-07-20 11:10:45 -0700
commite187426d10175b8407ee891018517bef09ae2d35 (patch)
parent0b77baa435de1894506513bfbdcea103fd4d0ff2 (diff)
flo: Enable mtp function over ConfigFS gadgetlollipop-mr1-release
This patch add configs to get MTP working on Android boot completion. Catch here is that I could not configure MTP at init or during boot time like adb. When I tried doing that then mtp-tools at host side can recognize FLO but the files are not browsable. I see only top level folder and that too empty. Since we need adb to be enabled from boot time, we do a soft USB UDC reset before enabling MTP function, otherwise it won't work. Also worth noting that after enabling USB gadget with mtp and adb functions over configfs, it takes exactly 60 seconds to auto-mount Android storage. This 60 second delay is triggered by a USB gadget reset, which still need to be investigated. We can mount the storage manually at any time though without any problem. This behavior is only visible when enabling both mtp and adb functions. If I enable only mtp function then the storage auto-mounts as soon as I enable the USB gadget. I also see a "Unable to mount Nexus 7" (Unable to open MTP device) diaglog box as soon as I enable USB gadget. Not sure what is the deal with that guy. May be my udev rules? Because I see that dialog box even if I have enabled only adb function. Also USB hotplug do not work. Looks more like a platform issue and not something to to with these ConfigFS gadgets. TODO: 1) Test and Enable PTP function. 2) Auto-mount MTP device without delay. 3) USB hotplug gadgets. Signed-off-by: Amit Pundir <> Signed-off-by: John Stultz <>
1 files changed, 33 insertions, 2 deletions
diff --git a/init.flo.usb.rc b/init.flo.usb.rc
index 5b041af..8b72bef 100644
--- a/init.flo.usb.rc
+++ b/init.flo.usb.rc
@@ -13,6 +13,8 @@
# limitations under the License.
on init
+ # Create ConfigFS mount point
+ # and add standard gadget entries
mount configfs none /config
mkdir /config/usb_gadget/g1
write /config/usb_gadget/g1/idVendor 0x18D1
@@ -25,12 +27,41 @@ on init
mkdir /config/usb_gadget/g1/configs/c.1/strings/0x409
write /config/usb_gadget/g1/configs/c.1/strings/0x409/configuration "Conf 1"
write /config/usb_gadget/g1/configs/c.1/MaxPower 120
+ # adb+ffs function configs
stop adbd
mkdir /config/usb_gadget/g1/functions/ffs.adb
symlink /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/c.1/ffs.adb
- mkdir /dev/usb-ffs
- mkdir /dev/usb-ffs/adb
+ mkdir /dev/usb-ffs 0770 shell shell
+ mkdir /dev/usb-ffs/adb 0770 shell shell
mount functionfs adb /dev/usb-ffs/adb uid=2000,gid=2000
+ # Do not move these properties out of init section.
+ # These need to be set before UsbDeviceManager kicks in.
+ # If not set, adb will be set as default and overwriting
+ # later won't help.
+ setprop persist.sys.usb.config mtp,adb
+ setprop sys.usb.config mtp,adb
+ setprop sys.usb.state mtp,adb
start adbd
on boot
write /config/usb_gadget/g1/UDC ci_hdrc.0
+on property:service.bootanim.exit=1
+ # bring down UDC interface and
+ # reset adb function before we enable mtp
+ write /config/usb_gadget/g1/UDC ""
+ stop adbd
+ start adbd
+on property:sys.boot_completed=1
+ # Do not move these mtp configs to init section
+ # otherwise we end up mounting an empty folder
+ # after mtp initialization (not still quiet sure why?)
+ # and we can not browse folders or media files.
+ # mtp-tools command line interface work fine though.
+ mkdir /config/usb_gadget/g1/functions/mtp.mtp
+ symlink /config/usb_gadget/g1/functions/mtp.mtp /config/usb_gadget/g1/configs/c.1/mtp.mtp
+ write /config/usb_gadget/g1/UDC ci_hdrc.0