Jump to content











Photo
- - - - -

Drive Droid: Boot from Android


  • Please log in to reply
67 replies to this topic

#26 saddlejib

saddlejib

    Frequent Member

  • Advanced user
  • 270 posts
  •  
    United Kingdom

Posted 28 July 2013 - 10:53 AM

This may help Wonko.

This is DriveDroid's image creation page.

 

http://img23.imagesh...3/9195/tw8v.png



#27 saddlejib

saddlejib

    Frequent Member

  • Advanced user
  • 270 posts
  •  
    United Kingdom

Posted 28 July 2013 - 09:08 PM

@ rog

most smart phone devices are ARM CPU inside so XP won't work 

 Do you mind explaining or pointing to links for me !



#28 florin91

florin91

    Frequent Member

  • Team Reboot
  • 197 posts
  •  
    European Union

Posted 31 July 2013 - 03:12 PM

I should emphase that it requires root. I used it succesfully to boot Slitaz and other iso.

 

However, I couldn't make a blank writable usb image to work, simply it wouldn't appear in my computer. And the other iso appear as cd's or dvd's, not usb.



#29 FrozenCow

FrozenCow

    Newbie

  • Members
  • 16 posts
  •  
    Netherlands

Posted 31 July 2013 - 07:15 PM

I should emphase that it requires root. I used it succesfully to boot Slitaz and other iso.

 

However, I couldn't make a blank writable usb image to work, simply it wouldn't appear in my computer. And the other iso appear as cd's or dvd's, not usb.

Hm, yes. This is a known incompatibility. Only a small number of phones that I know of are using mass storage as a CD/DVD drive. Apparently you have a rather new kernel, since booting from that CD/DVD drive is only recently been fixed in Linux. What's frustrating is that I cannot detect whether the phone is an USB drive or a CD/DVD drive and (most of those) manufacturers have not implemented a way to switch from CD to USB. The upside is that you should be able to use any ISO file to boot, like Windows, without fiddling with USB burning tools or anything. That's pretty rare on stock (factory shipped) roms.

It's an annoying problem that I'm trying to fix by submitting a patch to Linux... and hope it will be fixed on most phones in a year or two :(.

 

What phone do you have exactly?



#30 florin91

florin91

    Frequent Member

  • Team Reboot
  • 197 posts
  •  
    European Union

Posted 31 July 2013 - 09:38 PM

That's pretty rare on stock (factory shipped) roms.
It's an annoying problem that I'm trying to fix by submitting a patch to Linux... and hope it will be fixed on most phones in a year or two :(.
 
What phone do you have exactly?


Actually, it's not a phone. It's my tablet, Motorola Xoom 2 running on stock Android ICS 4.0.4, rooted, with busybox installed.

#31 FrozenCow

FrozenCow

    Newbie

  • Members
  • 16 posts
  •  
    Netherlands

Posted 03 August 2013 - 06:08 PM

Actually, it's not a phone. It's my tablet, Motorola Xoom 2 running on stock Android ICS 4.0.4, rooted, with busybox installed.

Hmm, I haven't had any reports on the Motorola Xoom 2 it seems. Could you send a support email through DriveDroids USB setup wizard or directly through the preferences. That way I have some more info about the device.



#32 saddlejib

saddlejib

    Frequent Member

  • Advanced user
  • 270 posts
  •  
    United Kingdom

Posted 03 August 2013 - 09:04 PM

@ FrozenCow

Can you give a summary of how DriveDroid works I think it would be easier for everyone to understand.

My posting of the screen did'nt help but I did use youre blank image with RmPrepusb and it worked.



#33 FrozenCow

FrozenCow

    Newbie

  • Members
  • 16 posts
  •  
    Netherlands

Posted 03 August 2013 - 09:57 PM

@ FrozenCow

Can you give a summary of how DriveDroid works I think it would be easier for everyone to understand.

My posting of the screen did'nt help but I did use youre blank image with RmPrepusb and it worked.

 

Do you mean how DriveDroid technically works, like behind the covers? Or what DriveDroid does for the user, like an overview?

I've tried to explain most things that are going on with DriveDroid briefly here already: http://reboot.pro/to...droid/?p=175074

I've tried to explain most of the technical stuff here: http://reboot.pro/to...droid/?p=175141

 

Where should I expand on?


Edited by FrozenCow, 03 August 2013 - 09:58 PM.


#34 saddlejib

saddlejib

    Frequent Member

  • Advanced user
  • 270 posts
  •  
    United Kingdom

Posted 03 August 2013 - 11:27 PM

Behind the covers.

It would also be good if it could mount sdcard partitions.



#35 FrozenCow

FrozenCow

    Newbie

  • Members
  • 16 posts
  •  
    Netherlands

Posted 04 August 2013 - 12:23 PM

Alright, here goes.

 

These are the critical steps DriveDroid must execute:

  • Change the USB mode to be Mass Storage
  • Set the file to be hosted in kernel
  • Set options for hosted file in kernel

The USB mode is basically what functions are enabled over USB. This can be any combination of Media Transfer Protocol (MTP), USB tethering (rndis), Android debugging (adb), USB Mass Storage (mass_storage) and some others (like manufacturer-specific ones). These are defined and implemented in the Linux kernel.

Functionality of mass_storage can be found in Torvalds Linux kernel here: https://github.com/t..._mass_storage.c For Android kernels the functionality is located in the same file-path.

 

To change the USB mode, DriveDroid by default uses the command:

# setprop sys.usb.config mass_storage

setprop is a command of Android that will, behind the scenes, set the right kernel parameters in /sys. Android uses this too to change Android debugging or USB tethering and stuff like that. That being said, quite a few phones haven't configured setprop properly to work with mass_storage. The functionality is available in the kernel, but it's just not in setprops configuration. To circumvent this I've implemented different USB systems that simulate the different rom-configurations.

 

So that's changing USB mode. After that we need to pass to the kernel which file we want to host on the mass_storage functionality. These devices where can be hosted on are called Logical Units (luns) in the kernel, there can be multiple of them representing multiple USB drives. On my phone I've got 2 of them, but the number of luns and the locations of the luns highly depends on the device. I have a long list of different locations where they can reside, DriveDroid detects the right ones. On my device they are located under:

/sys/devices/platform/s3c-usbgadget/gadget/lun0/
/sys/devices/platform/s3c-usbgadget/gadget/lun1/

Under those directories are the parameters for each lun. The most important parameter is "file". That is where we can write the path of the file (or device) that we want to host on the lun. DriveDroid does something like this:

# echo "/sdcard/Download/images/ubuntu.iso" > /sys/devices/platform/s3c-usbgadget/gadget/lun0/file

After that the iso is hosted as a USB device towards the PC. Depending on the device there are a number of other parameters that DriveDroid uses. One of them is "ro", which determines whether the file can be written from the PC or should be hosted as read-only. DriveDroid sets this like so:

# echo 1 > /sys/devices/platform/s3c-usbgadget/gadget/lun0/ro

Lastly, I've made a patch for a number of Android kernels that adds a new parameter to each lun. That parameter is "cdrom", which determines whether the lun will show up as a CD-drive or a USB-drive. The code of CD-emulation was already available in the Linux kernel, but with Androids system this was inaccessible from user-land (apps). This parameter is used the same way as "ro":

# echo 1 > /sys/devices/platform/s3c-usbgadget/gadget/lun0/cdrom

The CD-rom parameter can now be found in a number of CyanogenMod roms, basically all Samsung Galaxy * phones/tablets. The patch for the CD-rom parameter can be found here: https://github.com/C...efdb91cd031a993



#36 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 04 August 2013 - 12:40 PM

Under those directories are the parameters for each lun. The most important parameter is "file". That is where we can write the path of the file (or device) that we want to host on the lun. DriveDroid does something like this:

# echo "/sdcard/Download/images/ubuntu.iso" > /sys/devices/platform/s3c-usbgadget/gadget/lun0/file

So, you are now confirming that drive droid can expose EITHER:
  • a file residing on the /lun0/ device as if it was a USB device
  • the "whole" /lun0/ device as if it was a USB device
#2 would allow the booting of *any* Linux based .iso by means of just writing the "fake partition entry" related to the LBA addresses of the actual .iso file located on that device.
You could do this from Drivedroid, so that when the PC "gets to the device", it is already modiified, and you can "mantain" the RO security "flag":


 

After that the iso is hosted as a USB device towards the PC. Depending on the device there are a number of other parameters that DriveDroid uses. One of them is "ro", which determines whether the file can be written from the PC or should be hosted as read-only. DriveDroid sets this like so:

# echo 1 > /sys/devices/platform/s3c-usbgadget/gadget/lun0/ro


:cheers:
Wonko

#37 FrozenCow

FrozenCow

    Newbie

  • Members
  • 16 posts
  •  
    Netherlands

Posted 04 August 2013 - 01:06 PM

So, you are now confirming that drive droid can expose EITHER:

  • a file residing on the /lun0/ device as if it was a USB device
  • the "whole" /lun0/ device as if it was a USB device
#2 would allow the booting of *any* Linux based .iso by means of just writing the "fake partition entry" related to the LBA addresses of the actual .iso file located on that device.
You could do this from Drivedroid, so that when the PC "gets to the device", it is already modiified, and you can "mantain" the RO security "flag":


 

:cheers:
Wonko

 

Yes, I confirmed before that you can host a device. That's what oldish Android phones did when exposing their SDcard to the PC.

*However*... newer phones (last 2 years or so) do not have a external (nor internal) 'SDcard'. They have a filesystem which includes everything: firmware, rom, kernel and a 'emulated SDcard' where users can store arbitrary files.

I don't have exact details on any of this, including the 'emulated SDcard', since I do not own a modern phone (mine 3 years or so old). I can imagine it being a loopback device that resides in a file on the actual system (it would in this case still be possible to use that loopback device), but I can also imagine it being a normal directory and not a separate drive/partition at all.

The problem is that when the SDcard indeed resides on the same disk as the rest of the Android-system, the whole system-disk needs to be hosted. I don't want to change anything on the system-disk, since that can brick devices if not done properly. Since I've seen so many differences between Android devices, I can never safely make a presumption about their partitions/disks/booting mechanisms.

 

That being said, for oldish Android phones this is indeed possible, since those just have a real SDcard disk with partition table that is independent of the rest of the Android system.

That being said, the cleanest way to boot ISO files is just to emulate a CD-drive. This however requires the patch mentioned in the kernel. Most devices that run CyanogenMod already have this patch and I still need to submit the patch to other CyanogenMod devices to have CD-rom support on all devices that have CyanogenMod installed (that's pretty significant).

What I'm trying to do for long-term is apply the patch to Torvalds Linux kernel. When that happens the patch will eventually trickle down to the different (new) Android devices. I've also heard there are going to come big changes in the USB-gadget mechanism of Linux (where mass_storage resides on). With that mechanism things like dynamically changing the number of LUNs and types of LUNs by DriveDroid should be possible. So I can dynamically create a device that holds the booting mechanism and host another LUN where the ISO/IMG is hosted... that's all long-long term though.



#38 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 04 August 2013 - 01:41 PM

That being said, for oldish Android phones this is indeed possible, since those just have a real SDcard disk with partition table that is independent of the rest of the Android system.
That being said, the cleanest way to boot ISO files is just to emulate a CD-drive. This however requires the patch mentioned in the kernel.

Sure :thumbup:, the suggestion was not intended as the answer to the ultimate question about life, the universe and everything (which is 42 ;)).
It was meant as a possible workaround needing not to patch the kernel, limited to the devices actually compatible (and for a possible way when things will have settled down a bit and you will be able to emulate a LUN ).
More as a "possibility" along the lines of:
 http://tinyurl.com/4pncnjm

 stupid, stupid, stupid board software that is unable to parse a single quote in a URL  :frusty:

 

idioms.thefreedictionary.com/There's+more+than+one+way+to+skin+a+cat

(I mean, not Chinese or Japanese Unicode character, a simple, plain, single quote §@ç#ing character)

:cheers:
Wonko



#39 FrozenCow

FrozenCow

    Newbie

  • Members
  • 16 posts
  •  
    Netherlands

Posted 04 August 2013 - 02:03 PM

Sure :thumbup:, the suggestion was not intended as the answer to the ultimate question about life, the universe and everything (which is 42 ;)).
It was meant as a possible workaround needing not to patch the kernel, limited to the devices actually compatible (and for a possible way when things will have settled down a bit and you will be able to emulate a LUN ).
More as a "possibility" along the lines of:
 http://tinyurl.com/4pncnjm

 stupid, stupid, stupid board software that is unable to parse a single quote in a URL  :frusty:

 

idioms.thefreedictionary.com/There's+more+than+one+way+to+skin+a+cat

(I mean, not Chinese or Japanese Unicode character, a simple, plain, single quote §@ç#ing character)

:cheers:
Wonko

Yes, indeed. The problem is mostly device compatibility (like it always is with DriveDroid :P). If I have time I'll check whether I can create a grub4dos image that can boot an ISO by just switching to the ISO file afterwards. That seems to be the least problematic method in terms of device compatibility. I might want to combine that with the test image I use in DriveDroid: that is used to setup and test DriveDroids functionality. That way everyone will have the image when installing DriveDroid and I can integrate it in some simple tutorial.



#40 saddlejib

saddlejib

    Frequent Member

  • Advanced user
  • 270 posts
  •  
    United Kingdom

Posted 11 August 2013 - 10:17 PM

Have been trying for over a month to get my phone, Galaxy s4 to boot from Grub4Dos and boot liveXP's from its sd card using SU mass storage device app but hitting a multitude of problems, it would boot linux based no problem.

 The SD card is a 64gb sdxc card which is generally formatted with exFat explanations and incompatabillitys on Wiki.

The card can be formatted to Fat32 using guiformatter or easeus partition manager but once you mess with partitions the phone complains.

 If you dont  add partitions the phone, sdcard, is seen by my computer at least as a 'superfloppy' and things don't work,

If the phone stroke card, screwed, it could not be seen either by the phone or windows basically destroyed or at best a 32gb card, this can be resolved by using vparted, on the phone, the app's repair facility.

 So finally I gave up ''kind of' although I have had it working in 'limp mode' but then realised the card did'nt have to be exFat and returned to DriveDroid it worked flawlessly in fat32 .

 As you said the machine sees it, simply, as a usb drive,

 Although I have'nt as yet tried it I think, almost know, Steves E2B would work.



#41 FrozenCow

FrozenCow

    Newbie

  • Members
  • 16 posts
  •  
    Netherlands

Posted 12 August 2013 - 06:23 PM

I'm not sure what a superfloppy is, but I know exFat can be problematic. I'm not sure grub will support that and I'm not sure all phone roms support it.

Most stable way I think is still to have a separate image with grub4dos on it, that image is started first and will wait for a while, meanwhile you switch to an ISO and grub4dos will boot that ISO. That should work without fiddling with the SDcard and its partition table, but I haven't yet delved into this.



#42 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 12 August 2013 - 07:05 PM

I'm not sure what a superfloppy is, but I know exFat can be problematic. I'm not sure grub will support that and I'm not sure all phone roms support it.

It's a matter of definitions.

 

  1. Anything that is partitioned (i.e. which first sector is a MBR and/or contains a partition table) is "hard disk like".
  2. Anything with the EXACT size of existing floppy media (i.e. up to the 2,88 Mb floppy, i.e. 2,949,120 bytes in size) AND which first sector is a VBR (or at least contains a BPB) is "floppy like".
  3. An extension of the above is the "super-floppy like" which is anything which first sector is a VBR (or at least contains a BPB), no size limits/sets.

And, just as soon as you are familiar with the idea :), check what MakebootFAT can make (at the same time a hd-like AND a superfloppy-like :w00t:):

http://reboot.pro/to...61-makebootfat/

 

JFYI, grub4dos ( NOT "grub") supports exFAT allright, but then only the Windows 8 BOOTMGR will be able to boot from an exFAT, see:

http://reboot.pro/to...-exfat-volumes/

http://reboot.pro/to...ated-usb-drive/

 

:cheers:

Wonko



#43 saddlejib

saddlejib

    Frequent Member

  • Advanced user
  • 270 posts
  •  
    United Kingdom

Posted 12 August 2013 - 10:56 PM

 mmmm.

Deleted my post.

Pain in progress.



#44 saddlejib

saddlejib

    Frequent Member

  • Advanced user
  • 270 posts
  •  
    United Kingdom

Posted 13 August 2013 - 08:05 PM

Pain over,

DriveDriod boots both livexp and linux stuff,it is seen as a usb drive on exFat.

As Frozen Cow said.

Quick resume.

s4 galaxy 64gb sdxc card formatted by phone to exfat,

 Create blank image size to suit you, courtesy of DriveDroid, no mbr, filesystem fat, run and connect to in my case Win7

then use Rmprep on the image, max, bart, nothing else checked, prepare drive, then install g4d..

Nice



#45 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 14 August 2013 - 09:03 AM

saddlejib,

I am sure that if you could - in due time - re-describe your successful experience with more details (i.e. expand on the quick resume you made with enough details to make it reproducible) it would be helpful :).

 

:cheers:

Wonko



#46 saddlejib

saddlejib

    Frequent Member

  • Advanced user
  • 270 posts
  •  
    United Kingdom

Posted 14 August 2013 - 09:16 PM

@ Nuno

 

 

I think this site needs something like 'Shoutbox' whereas people can express themselves, ideas, angst or simple replys to things that dont need to be included in the forums. i.e being human.

 

e.g where is the best place to post this thread rather than being 'softly' berated.

 

@ Wonko

 

Thanks for that anyway Wonko. You kept your gloves on.

 

So on this note I will post an answer (description) as soon as possible,

 

Iv'e just a few ideas to try out, so I know what I'm talking about.

 

(I'm trying to go down the Zalman line ??? time at keyboard at the moment does'nt help.)

 

 Small HD only (SD Card) 64gb if it works. i.e Zalman on phone.

 

capisce. I think you do.

 

Any input appreciated.

Current tools:

Phone:

BootDroid, SG USB Mass Storage Enabler, AParted (Dead card resurrector) .

 

Computer:

 RmprepUSB and ImDisk not got that far yet though making and transporting images from computer to phone to see if they work..



#47 saddlejib

saddlejib

    Frequent Member

  • Advanced user
  • 270 posts
  •  
    United Kingdom

Posted 15 August 2013 - 03:31 PM

Had a little time to spare, so tried a 6.22 floppy.dsk borrowed of my Zalman it was accepted by BootDroid as both .dsk and .img and it booted.

 

So at that I created a 500mb ntfs removable image with ImDisk copied it to phone loaded it with BootDroid prepped it with RmPrepUsb, installed g4d and copied my LiveXP files over and it also booted.



#48 FrozenCow

FrozenCow

    Newbie

  • Members
  • 16 posts
  •  
    Netherlands

Posted 15 August 2013 - 04:24 PM

Nice work! I didn't know about RmPrepUsb, but I'll give that a try too. Good to hear g4d works with LiveXP. I'd like to try to put g4d on a separate .img and have the LiveXP image on my SDcard, so that I have grub4dos.img, livexp.iso (and maybe livewin8.iso) all side-by-side. That way I should only need one small image for g4d and can have multiple (biggish < 4GB) ISO images on the SDcard (easily removable/addable/downloadable(?) using only the phone itself).



#49 saddlejib

saddlejib

    Frequent Member

  • Advanced user
  • 270 posts
  •  
    United Kingdom

Posted 15 August 2013 - 07:47 PM

@ FrozenCow.

 

Your work is the nice work, 

 

I'm only playing with it.

 

Check out ImDisk. (superb tool, Thanks Olaf) .

 

and never forget Uwe Sieber and DriveCleanup when everything usb should work and does'nt as did in my previous posts.

 

Also related but not forgot:

  Buxters App

 

Also check out the Zalman pages on this forum..

 

It's going to be like the credits on a movie.

 

 Wonko the Insane previously Jacklaz the Sane,

and Steve 63 lots of numbers 75 resident usb guy and g4d guy.

 and all others.

Sorry if I havent mentioned you but they post a lot.

 

lol.



#50 saddlejib

saddlejib

    Frequent Member

  • Advanced user
  • 270 posts
  •  
    United Kingdom

Posted 18 August 2013 - 10:33 PM

 Help appreciated,

Why does this ...

 

title TEST.IMG
find --set-root --ignore-floppies /test.img
map  /test.img (hd0)
map --hook
chainloader (hd0)+1
rootnoverify (hd0)

 

or this

title TEST.IMG
find --set-root --ignore-floppies /test.img
map  /test.img (hd0)
map --hook
chainloader (hd0)+1

 

or this

 

title TEST.IMG
find --set-root --ignore-floppies /test.img
map  --mem /test.img (hd0)
map --hook
chainloader (hd0)+1
rootnoverify (hd0)

 

 

...loose 'focus' (diskpart reference) on the drive its loading ?

Where test.img is a g4d, active,  bootable, fat32 LiveXP image being loaded off a exFat SDCard, all three load

and all boot LiveXP and without the update kb955704 for exFat on an exFat formatted SDCard but loose the pseudo drive midway.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users