I have Galaxy S4 with custom ROM and kernel. I need to mount ISO image from sdcard to Windows/Linux PC as CD-ROM.
There's a "DriveDroid" app that works fine, but I need to do it manually (as a study). Windows 8 writes that "Device needs to be formatted".
code (bash script)
# Disable USB
echo 0 > /sys/class/android_usb/android0/enable
# Set Vendor and Product IDs
echo 0x04e8 > /sys/class/android_usb/android0/idVendor
echo 0x6860 > /sys/class/android_usb/android0/idProduct
# Set mass_storage mode
echo mass_storage > /sys/class/android_usb/android0/functions
# Enable CD-ROM and make read-only (ERROR HERE!)
echo 1 > /sys/class/android_usb/android0/f_mass_storage/lun0/cdrom
echo 1 > /sys/class/android_usb/android0/f_mass_storage/lun0/ro
# Set path to ISO
echo /mnt/shell/emulated/0/obraz.iso > /sys/class/android_usb/android0/f_mass_storage/lun0/file
# Enable USB
echo 1 > /sys/class/android_usb/android0/enable
However, both cdrom
and ro
files are still set to 0. What else should I do to make them "1" ?
# Disable USB
echo 0 | tee /sys/class/android_usb/android0/enable
# Set Vendor and Product IDs
echo 0x04e8 | tee /sys/class/android_usb/android0/idVendor
echo 0x6860 | tee /sys/class/android_usb/android0/idProduct
# Set mass_storage mode
echo mass_storage | tee /sys/class/android_usb/android0/functions
# Enable CD-ROM and make read-only
echo 1 | tee /sys/class/android_usb/android0/f_mass_storage/lun*/ro
# Set path to ISO
echo | tee /sys/class/android_usb/android0/f_mass_storage/lun*/file
echo <YOUR-IMAGE-FILE-PATH> | tee /sys/class/android_usb/android0/f_mass_storage/lun*/file
# Enable USB
echo 1 | tee /sys/class/android_usb/android0/enable
It is work on my phone. (Asus T00F - android 7.1.2)
Before writing 1 to "cdrom" and "ro" I had to empty "file" file.
Thanks @FrozenCOW (Developer of DriveDroid) for help!
# Clear path to ISO
echo "" > /sys/class/android_usb/android0/f_mass_storage/lun0/file
# Enable CD-ROM and make read-only (ERROR HERE!)
echo 1 > /sys/class/android_usb/android0/f_mass_storage/lun0/cdrom
echo 1 > /sys/class/android_usb/android0/f_mass_storage/lun0/ro
# Set path to ISO
echo /mnt/shell/emulated/0/obraz.iso > /sys/class/android_usb/android0/f_mass_storage/lun0/file