Enable USB mass storage in Android ICS

cancel
Showing results for 
Search instead for 
Did you mean: 

Enable USB mass storage in Android ICS

10,776 Views
PeterChan
NXP Employee
NXP Employee

From Android ICS onwards, MTP mode is the default USB connection mode. To enable the mass storage mode in R13.5,

 

1. Change the persist.sys.usb.config property from "mtp" to "mass_storage" to enable the mass storage function by default.

 

2. In storage_list.xml, turn on the "android:allowMassStorage" flag for the mounted volume so that it can be shared for ums. Please note that there are several storage_list.xml under the "device/fsl" folder for different board configurations. Be careful you are editing the appropriate one.

 

The above change for i.MX6SL is summarized in this patch.

 

Because your PC may register your board as a MTP device, you may need to update the device driver to make the mass storage device effective.

 

To turn on the USB storage after USB connection, please click the small USB icon on the status bar at the bottom of screen. A pop up menu will be shown. Then choose "Turn on USB storage".

 

For further information, please refer to External Storage Technical Information | Android Developers.

Original Attachment has been moved to: R13.5_usb_mass_storage.patch.zip

Labels (3)
Tags (2)
0 Kudos
11 Replies

583 Views
satoshishimoda
Senior Contributor I

Hi PeterChang,

Would you give me your comment to my question?

Best Regards,

Satoshi Shimoda

0 Kudos

583 Views
jamesbone
NXP TechSupport
NXP TechSupport

this is out of scope of our standard support, because Android dropped USB mass storage. We need a specific reason which needs this support

0 Kudos

583 Views
satoshishimoda
Senior Contributor I

Dear jamesbone,

Thank you for your reply.

Actually, I did not know that Android dropped USB mass storage.

Thank you for telling me usable information.

Best Regards,

Satoshi Shimoda

0 Kudos

583 Views
satoshishimoda
Senior Contributor I

Hi PeterChan,

I heard USB mass storage is not enabled with Android 5.1.1 BSP even though it is OK with Android 5.0 BSP.

It seems that following sysfs file is not created even though CONFIG_USB_F_MASS_STORAGE is enabled in USB gadget driver configuration.

/sys/class/android_usb/android0/f_mass_storage/lun/file

The procedure was changed to enable USB mass storage in Android 5.1.1 BSP?

Best Regards,

Satoshi Shimoda

0 Kudos

583 Views
himanshugusain
Contributor III

Hi PeterChan

Do we need to make similar changes for enabling USB mass storage in Android Lollipop (5.0) as well

Regards

Himanshu

0 Kudos

583 Views
yifeiwang
Contributor III

I'm using IMX6Q with JB 4.2.2, is there any way to enable USB mass storage?

0 Kudos

583 Views
PeterChan
NXP Employee
NXP Employee

For JB 4.2.2, you can use the same way suggested in this thread to enable the USB mass storage.

0 Kudos

583 Views
yifeiwang
Contributor III

I've tried as you suggested, however, my win7 always shows "USB Device Not Recognized", can you try? thanks.

pastedImage_0.png

0 Kudos

583 Views
PeterChan
NXP Employee
NXP Employee

JB 4.2.2, additional changes are required to make USB mass storage work.

First of all, the Android mass storage function is disabled in the framework. You need to modify init.usb.rc to this.

diff --git a/imx6/etc/init.usb.rc b/imx6/etc/init.usb.rc

index 0d7c29f..c6f68e3 100644

--- a/imx6/etc/init.usb.rc

+++ b/imx6/etc/init.usb.rc

@@ -42,3 +42,22 @@ on property:sys.usb.config=ptp,adb

    start adbd

    setprop sys.usb.state ${sys.usb.config}

+# USB massstorage configuration, with adb

+on property:sys.usb.config=mass_storage,adb

+    write /sys/class/android_usb/android0/enable 0

+    write /sys/class/android_usb/android0/idVendor 18d1

+    write /sys/class/android_usb/android0/idProduct d02

+    write /sys/class/android_usb/android0/functions $sys.usb.config

+    write /sys/class/android_usb/android0/enable 1

+    start adbd

+    setprop sys.usb.state $sys.usb.config

+

+# USB massstorage configuration

+on property:sys.usb.config=mass_storage

+    write /sys/class/android_usb/android0/enable 0

+    write /sys/class/android_usb/android0/idVendor 18d1

+    write /sys/class/android_usb/android0/idProduct 2d01

+    write /sys/class/android_usb/android0/functions $sys.usb.config

+    write /sys/class/android_usb/android0/enable 1

+    setprop sys.usb.state $sys.usb.config

+

From JellyBean, the file system of data partition in primary volume (/dev/block/mmcblk0p4) is no longer "vfat" but is "ext4" now. By default, Android always shares this ext4 partition as the USB mass storage device. However, the Android mass_storage function can only accept "vfat" and using other file system type will leads to the "Volume is not format" error. To avoid user data corruption, you cannot share /dev/block/mmcblk0p4. You have modify the Android framework to share either /mnt/extsd or /mnt/udisk as the USB mass storage device.

0 Kudos

583 Views
yifeiwang
Contributor III

Thanks a lot, Peter.

"You have to modify the Android framework to share either /mnt/extsd or /mnt/udisk as the USB mass storage device" do you mean to modify

this file: "overlay/frameworks/base/core/res/res/xml/storage_list.xml"? or more than that? can you elaborate?

0 Kudos

583 Views
PeterChan
NXP Employee
NXP Employee

It is much more than that. The UsbStorageActivity and MountService in the Android framework has to be modified so that the either /mnt/extsd or /mnt/udisk will be shared as USB mass storage device. By default, it always shared the data partition of the primary volume.

0 Kudos