[GUIDE] Mass Storage

40 posts
Thanks Meter: 29
 
By bazald, Member on 12th July 2012, 08:39 PM
Post Reply Email Thread
If you aren't satisfied with transferring files over MTP for whatever reason, I have done some digging and managed to get mass storage working for the external sdcard.

I developed some scripts for switching to and from mass storage, using posts for the GT-I9300 and for the Xperia S. You can unzip them (attached) to the root of your internal sdcard. You can then easily import them into GScript Lite, available for free through the Play store.

For reference, the commands are as follows:

Mass Storage:

Just plug in your phone and run:

Code:
echo 0 > /sys/devices/virtual/android_usb/android0/enable
umount /mnt/extSdCard/
echo "mass_storage,adb" > /sys/class/android_usb/android0/functions
echo "/dev/block/vold/179:97" > /sys/devices/virtual/android_usb/android0/f_mass_storage/lun_ex/file
echo 1 > /sys/devices/virtual/android_usb/android0/enable
If Windows fails to find the correct driver, go to the Device Manager and manually set it to use the driver, "USB Mass Storage Device". It seemed to try to stick with the MTP driver in my case.

MTP:

Unmount/Eject in your operating system first, to be sure. Then:

Code:
echo "" > /sys/devices/virtual/android_usb/android0/f_mass_storage/lun_ex/file
echo 0 > /sys/devices/virtual/android_usb/android0/enable
echo "mtp,acm,adb" > /sys/class/android_usb/android0/functions
echo 1 > /sys/devices/virtual/android_usb/android0/enable
vold
Notes:

/sys/devices/virtual/android_usb/android0/f_mass_storage/lun/file seems to be prepared for the internal sdcard, but I have had no success in using it in conjunction with the device, /dev/block/vold/179:96. At least the external works.
Attached Files
File Type: zip gscript_SGH-I747_mass-storage_v2.zip - [Click for QR Code] (722 Bytes, 2696 views)
The Following 21 Users Say Thank You to bazald For This Useful Post: [ View ] Gift bazald Ad-Free
12th July 2012, 08:47 PM |#2  
AtoZ0to9's Avatar
Senior Member
Flag Mississippi
Thanks Meter: 3,038
 
More
and it stays without having to continually type all that?
The Following User Says Thank You to AtoZ0to9 For This Useful Post: [ View ] Gift AtoZ0to9 Ad-Free
12th July 2012, 09:09 PM |#3  
OP Member
Thanks Meter: 29
 
More
Quote:
Originally Posted by B-Naughty

and it stays without having to continually type all that?

If you stop after the first script, unfortunately it's not going to remount the external sdcard. This does not enable a convenient UI toggle like you might have seen on other ROMs.

I recommend saving the first sequence of commands as "Mass Storage.sh" and the second sequence as "MTP.sh". You can copy them to /sdcard/gscript/ and load them into GScript Lite as new scripts. Then it's easy to activate mass storage and deactivate it at the push of a few buttons. (GScript Lite seems to crash on me after running the scripts, on exit, but to no ill effect.)
The Following 3 Users Say Thank You to bazald For This Useful Post: [ View ] Gift bazald Ad-Free
12th July 2012, 09:14 PM |#4  
Senior Member
Thanks Meter: 71
 
More
Any way to get this into an app?
13th July 2012, 01:14 AM |#5  
OP Member
Thanks Meter: 29
 
More
Quote:
Originally Posted by jiggytom

Any way to get this into an app?

Someone could develop a specialized app, but I recommend trying GScript Lite in conjunction with the attached scripts.
13th July 2012, 02:18 AM |#6  
Account currently disabled
Thanks Meter: 267
 
More
thanks for the tutorial.
13th July 2012, 08:51 PM |#7  
Member
Flag Pittsburgh PA
Thanks Meter: 21
 
More
Woohoo!! Thanks so much for figuring this out.

[I'm having to explicitly remount the external card in the MTP script:

mount -t exfat /dev/block/vold/179:97 /mnt/extSdCard

and mount doesn't seem to be happy without an explicit type - any way around that?]
14th July 2012, 04:41 AM |#8  
OP Member
Thanks Meter: 29
 
More
Quote:
Originally Posted by plaut

I'm having to explicitly remount the external card in the MTP script:

mount -t exfat /dev/block/vold/179:97 /mnt/extSdCard

and mount doesn't seem to be happy without an explicit type - any way around that?]

That's interesting. I didn't encounter that issue. The only difference I'm aware of is that I reformatted my card using mkfs.vfat, but you could try appending the following to the MTP script, and see if it works equally well:

Code:
vold
The whole script would become:

Code:
echo "" > /sys/devices/virtual/android_usb/android0/f_mass_storage/lun_ex/file
echo 0 > /sys/devices/virtual/android_usb/android0/enable
echo "mtp,acm,adb" > /sys/class/android_usb/android0/functions
echo 1 > /sys/devices/virtual/android_usb/android0/enable
vold
If that doesn't work, your solution might be the best one for now. Let me know if this works. I don't see any harm in adding the line, in any case.
The Following User Says Thank You to bazald For This Useful Post: [ View ] Gift bazald Ad-Free
14th July 2012, 11:45 AM |#9  
Member
Flag Pittsburgh PA
Thanks Meter: 21
 
More
Yes, that works - thanks again!
The Following User Says Thank You to plaut For This Useful Post: [ View ] Gift plaut Ad-Free
24th July 2012, 11:51 PM |#10  
vudugan's Avatar
Senior Member
Milwaukee, WI
Thanks Meter: 41
 
More
Thumbs up
Just.. Perfect!!
25th July 2012, 05:02 PM |#11  
vudugan's Avatar
Senior Member
Milwaukee, WI
Thanks Meter: 41
 
More
Well, works well at home on w7 but the Xp at work doesn't want to play.

VZW SGS3 Tap a Talk
Post Reply Subscribe to Thread

Tags
development

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes