[Galaxy Note 8.0 (Tablet) Android Development] Phil_Suz:
Hi all,

Sorry, posting here because no access yet to dev sub forum. Admin, can you move it in dev subforum ?

Long time reader of xda forum, this is my first contribution. Long Post ... read carefully before starting.

This modded TWRP recovery program open the ability to boot any roms or recovery roms from external storage or even internal storage ( but not a lot of place there...).

It can be very usefull to :

- test a new released custom ROM without erasing your current one

- use any recovery ROMS

- run multiple instance of same ROM : example CM11/Dalvik and CM11/ART runtime ( thank's to excellent porting of CM11 from sbrissen ! )

- Save your internal flash by writing only to external card.

- test kernel/initrd without flashing them

- bypass 8M limit of boot/recovery devices size
​

Limitations :

- fully supported internal roms ( located in /data/media/0/roms )

- fully support FAT32 (vfat), EXTx on external sdcard roms

- Partially supported Exfat filesystems ( >= Android 4.3, or any android 4.x with latest Civato kernel http://xdaforums.com/showthread.php?t=2287802 )

- Not supported NTFS until now ( just because I never used it... )

- Sizes of filesystem hardcoded in this version ( check /sbin/create_rom.sh if you want to change default sizes )

- multiboot only from recovery program ( I did that on purpose just because did'nt want to change boot.img )

- Not all internal block devices "protected" from OTA and/or APPS - 5 blocks are protected ( boot, efs, cache, system, data ). Maybe modem and preload will be added next time...​

Some time ago, I started to try to add multiboot fonctionnality to our Galaxy Note 8.

My starting point was to port kexec-harboot patch created by mkasic in this post http://xdaforums.com/showthread.php?t=1266827 and explained also by Tassadar in http://xdaforums.com/showthread.php?t=2104706

Unfortunaltely this method could not be fully completed, mainly because one of the very lasts operations of kexec (disabling mmu) did not work on our cpu - exynos4412.

Then I tried another method derivated from kexec-hardboot method which finally worked very well.

I will explain in another post the details of the method and kernel patch/userspace tool. I think this method is not as elegant as KE-HB method but is easier to implement and i think it can be applied easily on almost all Android devices.

At this step, I was able to boot any kernel/initrd from android. Next step was to be able to boot a full custom rom from another location than the inernal flash.

I looked at excellent multirom project sources from Tassadar wich gave me good knowledge of the method applied ( if I understood well : first stage ke-hb kernel/initrd acting as bootloader and new init injected on the fly in target inird, new init that is

able to mount/load appropriate filesystems ).

My goals was to make something easier to code and to use the features directly provided by original targeted init. I wanted also to use exactly the same recovery tools to manage an external rom or the internal rom.

The method is quite simple :

- creating img files formatted as ext4 devices ( for cache, system, data, efs, and boot)

- associating those img files to loop devices

- force linking the loop devices to the original internal blockdevices (mmcblk0pxx) in /dev filesystem

Step 3 is very important because all recovery programs and installation programs use them to mount/unmount/format/install operations.

When the 3 steps are applied, we can use all recovery programs to install a rom directly in the new locations. We apply also the same method to install any recovery images

Even if all recovery programs are able to support this method, I choose TWRP to add new management functions ( create/delete roms and recovery roms ) mostly because it was very easy to modify ui.xml to add custom pages and to add functions ( as shell scripts )

Note that the same method is also applied for booting a new rom. In this case, we use native fonctions in init.rc to mount the appropiate img files ( mount loop@path/to/img/file ... ).

You can look shell programs in /sbin and files in /injector dir to check methods.

Instructions

:

Important Note : Use this program as is, I am not responsible if something goes wrong and erase your data, so BACKUP all your data before using this program.

Also I recommand end-users to wait few time for feedbacks from developpers and powerusers before trying it.

Please read carefully all instructions.

If you install a ROM on vfat, exfat linux filesystems the ROM size will take about 7GB on your media card, so verify first remaining space before installing.

- cache : 1.5G

- system : 2.5G

- data : 3G

- boot : 8M

- efs : 20M​

If you install on EXT fs, same size will be reported but as img files are sparsed, real size used will be far less (only real size of all objects installed)

Install to internal flash ONLY if you are sure to have always 7GB free.

For your first installation, I recommand that you use an external sdcard formated in vfat. If you have an external sdcard in ext4, it will be better. For recovery ROMS, no recommandations, it will work well everywhere.

If you have ~7G available internally, go for instern install, installation will be very fast and ROM will be as fast as real rom.

Typical new rom installation : follow this steps for first time try.

Choose for example Cyanogenmod (10.2 or 11) for first try.

1 ) "ROMs Management" -> "Create New ROM" -> Press Storage, choose "external Card" ( even if it is already chosen ) -> "ROM Name" -> enter name "test" (no space in the name !) --> "Swipe to Create ROM"

-> wait ~20mn ( if external ) or ~1 mn ( if internal )

In console output, you will see :

Creating ROM...

....

ROM creation complete.​

Press "Back" to go back to main menu

At the end of this step, all empty img files are created ( will be filesystems and boot images )​

2 ) "set ROMs" -> Press Storage, choose "external Card" -> press on ROM name that you previously created --> "Swipe to Swap ROM"

-> wait ~5 seconds

In console output, you will see :

Swaping ROM...

...

Command succeded

Swap ROM complete​

Press Back => In main menu you will see in red color "CURRENT ROM : <name>

At this step you can now Install a ROM as usual​

3 ) Install ROM, GAPS, PROGRAMs as usual, this will be installed externally.

At the end of installs, DON'T REBOOT, go to main menu​

4 ) Go back to internal ROM : "Set ROM" -> "Reset to Internal" -> "Swipe to confirm switch" -> "Back"

5 ) "Multiboot" -> "Boot ROM" -> choose your newly created ROM -> "Swipe" -> "Reboot New Rom"

Use same procedure to install recovery ROMs.

Notes :

Be patient on first boot....

If first boot does not work try another time ( reboot to recovery ). If still does not work, you can let a message here.

Active "Advanced reboot" in CM Roms to be able to reboot to recovery.

I let roms and recoroms directories opened. Play with img files only if you know what you are doing.​

References / Credits :

mkasic : kexec-hardboot creator

Tassadar : multirom creator - bbootimg included in this release for boot.img extraction

sbrissen : cm port on Galaxy notes

Civato : ROMs and Kernels ( native exfat very usefull )

TWRP Team

All Roms creators : Without all of you, this project will be useless !​

Philippe,