FORUMS
Remove All Ads from XDA
Honor View 10

[Tool] [DEV STOPPED] Xperia S Boot Manager v0.8, a real dual boot system

1,690 posts
Thanks Meter: 2,342
 
By letama, Senior Member on 10th September 2012, 09:40 PM
Post Reply Email Thread
Hi All,

Here is a new version of my boot manager.

If you didn't see first release, its purpose is to allow dual boot a firmware with two different kernels with a third one that manages boot selection:



Here is a demo of the previous version, it behaves almost the same:



Since first release, I added cwmod and twrp support for both build:



First build is run from native partition, and second build is installled on internal storage via loopbacks. Since first release, I added automatic loobpack creation:



CWM will take care of formatting them.

FIRST A BIG WARNING: all you'll see here is highly experimental, I'm not responsible for any damage or problem it could cause.
I don't have any idea if running a build on loops is wearing off flash memory, it could damage your device.
I don't think it dramatically change anything compared to standard wear on native partitions, but who knows... And something else could go wrong.
The Following 98 Users Say Thank You to letama For This Useful Post: [ View ] Gift letama Ad-Free
 
 
10th September 2012, 09:41 PM |#2  
OP Senior Member
Thanks Meter: 2,342
 
Donate to Me
More
Pre-requisite

Currently, if you don't want to loose your current data, you have to be on a rom that has already be repackaged. By default, bootmanager installs Sony 6.1.A.2.55 kernel, so if you're using this firmware, no need to reflash it. For all the other roms, you will have to reflash the repackaged zip in the list below after installation. Don't wipe data/factory reset and you should be good to go. In both case, backup your stuff with Titanium Backup or something else!

Note: you won't be able to restore your previous cwm backups!



Installation:

Minimal setup:
  1. Download bootmanager_0.8.zip (mirrors) (previous version bootmanager_0.6.zip).
  2. Download one of the modified custom firmware in the list below
  3. Install bootmanager zip from your current recovery or extract dual.elf and flash it from fastboot.
  4. Reboot
  5. If your previous rom was not 6.1.A.2.55 based (like cm10 or aokp for instance), reflash your firmware from TWRP for native with one of the native firmware listed below.
  6. Reboot

Now, if you want to use dual boot functionnality:
  1. Select TWRP for loopback
  2. The first time, as you don't have loopbacks files on your internal storage, it will ask for system and data partition sizes. Be patient, it could take time to create them.
  3. When finally recovery is displayed, select erase data/factory reset
  4. then do erase system in partitions/format system
  5. loopbacks are now ready, you can flash one of the available build repackaged for loop.
  6. optionally flash regular google apps from here.

Upgrade from 0.6 or higher:

Upgrade should keep your existing firmwares,
  1. optional, but highly recommended, backup your stuff with cwm and/or Titanium backup.
  2. start stock or custom recovery
  3. flash bootmanager_0.8_upgrade.zip (mirrors)
  4. reboot
  5. re-enable dual boot in settings

Recoveries:

Starting with 0.8, offline charging has been added to twrp. As it's not possible to add to cwm, it is highly recommended to stay on twrp and avoid cwm as it's much safer for your phone.

Starting with 0.5, you can choose between cwm and twrp and switch as you wish. Just flash with your current recovery the recovery you want:

- TWRP 0.8.0 (mirrors) (previous TWRP 0.6.1)
- CWM 0.8.0 (mirrors) (previous CWM 0.6.0)
- EXPERIMENTAL, please read this before installing, TWRP 0.8.2 TWRP 2.6.0 and new 3.4 bootmanager kernel.


Firmwares

Stock / native partitions (flash them from stock recovery)

Sony 6.1.A.2.45 (don't pay attention to filename, this is 2.45, not 2.56, it's a silly typo). Note: you don't have to flash it if you have stock already, it will become useful only later on.
Sony 6.1.A.2.45 addon unsecure kernel, Sony stock kernel only, with ro.secure=0
Sony 6.1.A.2.45 addon kernel modules, Flash this is you have wifi problem, (mostly useful if your firmware was using a custom kernel).
Sony 6.1.A.2.50 stock firmware with unsecure kernel.
Sony 6.1.A.2.50 addon Standalone unsecure kernel.
Sony 6.2.B.0.211 stock firmware, rooted, with busybox.

FXP 137 CM 9.1, original firmware thread here.
AOKP ICS m6 beta 1, thanks to Apology11 for repack! original firmware thread here.
Krabappel2548's KA19, mirrors, original firmware thread here.
Sony 6.1.A.2.55, mirrors, untested unsecure kernel only here.
FXP 147 CM 10, mirrors, original firmware thread here.
PA 2.55 17/11/2012, mirrors, original firmware thread here (kernel from FXP147)
AOKP JB Milestone 1 r1, mirrors, original firmware thread here.
FXP 148 CM 10, mirrors, original firmware thread here.
PAC 18.0.0, mirrors, original firmware thread here
FXP 150 CM 10, mirrors, original firmware thread here.
PA 2.55.1 17/11/2012, mirrors, original firmware thread here
FXP 150a CM 9.1, mirrors, original firmware thread here.
FXP 151 CM 10, mirrors, original firmware thread here.
Nova Xperia RC1, mirrors, original firmware thread here.
FXP 152 CM 10, mirrors, original firmware thread here.
PAC 18.0.2, mirrors, original firmware thread here
Nova Xperia RC2, mirrors, original firmware thread here.
Hei1125's unofficial cm10 20130109, original thread firmware here.
FXP 201 CM 10, original firmware thread here.
FXP 206a CM 10, original firmware thread here.
My JB 4.2.2 aosp build, beta 2, thread is here.
My JB 4.2.2 aosp build, beta 3, thread is here.
My JB 4.3 aosp build, alpha 0, thread is here.
My JB 4.3 aosp build, alpha 1, thread is here.

Custom / loopback partitions (flash them from custom recovery)

Sony 6.1.A.2.50 (buggy, will update soon).
Sony 6.1.A.2.50, kernel only.
Sony 6.1.A.2.55, mirrors (tested, is working properly).
Sony 6.2.B.0.211, stock firmware, rooted, with busybox.

MIUI 2.9.7, mirrors, original firmware thread here.
AOKP ICS m6 alpha 2, original firmware thread here.
Krabappel2548's KA19, mirrors, original firmware thread here.
FXP 145 CM 9.1, mirrors, original firmware thread here.
FXP 147 CM 10, mirrors, original firmware thread here.
PA 2.55 17/11/2012, mirrors, original firmware thread here (kernel from FXP147).
AOKP JB Milestone 1 r1, mirrors, original firmware thread here.
Sony stock Gingerbread 6.0.A.3.75 UK, mirrors. (enabling data makes the phone reboot for me, baseband/radio problem).
Sony 6.1.A.2.55 unsecure kernel only, mirrors
XTXperience 7, mirrors, original firmware thread here. Flash 6.1.A.2.55 kernel with it.
FXP 148 CM 10, mirrors, original firmware thread here.
PAC 18.0.0, mirrors, original firmware thread here
MIUI 2.11.5, mirrors (you have to flash one of these kernels)
FXP 150 CM 10, mirrors, original firmware thread here.
PA 2.55.1 17/11/2012, mirrors, original firmware thread here
FXP 150a CM 9.1, mirrors, original firmware thread here.
Nova Xperia RC1, mirrors, original firmware thread here.
FXP 152 CM 10, mirrors, original firmware thread here.
PAC 18.0.2, mirrors, original firmware thread here
PAC 19, original thread here.
Nova Xperia RC2, mirrors, original firmware thread here.
JellyBear 3.35, original firmware thread here.
Hei1125's unofficial cm10 20130109, original thread firmware here.
FXP 201 CM 10, original firmware thread here.
XTXperience 8.1, original firmware thread here.
FXP 206a CM 10, original firmware thread here.
Ubuntu Touch 0.0.0, thread is here. Note: BIG 540 MB download. It installs on a separate 1.2 GB loopback created by the installation zip.
DooMLoRD Sony JB 6.2.B.0.197 leak, original thread here, credits goes to DooMLoRD
My JB 4.2.2 aosp build, beta 2, thread is here.
My JB 4.2.2 aosp build, beta 3, thread is here.
My JB 4.3 aosp build, alpha 0, thread is here.
My JB 4.3 aosp build, alpha 1, thread is here.

Mirrors of few builds, thanks to elpelas

Repackager package for linux 64 bits, unzip and untar, run as root: ./repackage.sh source_file out_name
Attached Files
File Type: zip repackager_0.1.zip - [Click for QR Code] (670.5 KB, 689 views)
The Following 65 Users Say Thank You to letama For This Useful Post: [ View ] Gift letama Ad-Free
10th September 2012, 09:43 PM |#3  
OP Senior Member
Thanks Meter: 2,342
 
Donate to Me
More
DONATIONS

Thanks to @rolex0815 for his donation!

FAQ

- Can I flash any update zip with BootManager ?

Most of the time, no. Some may work unmodified, like google apps that mounts system without using explicit partition. But most of the zips found here mounts directly native partitions so they won't work for build installed on loops. Last, all the kernel zips have to be modified. Flashing any unrepackaged kernel zip will replace boot manager completely and will kill it.

- Can I restore my previous CWM backups after installing bootmanager ?

Yes and no. Yes if you want to go back to where you were before installing bootmanager. No if you want to keep boot manager: restoring the backup will erase it.

Known issues

- Moved apps (to storage/sdcard) will disappear when booting from one build to another. I presume it happens because both builds are sharing storage and it messes up ext2sd scheme. As a workaround, move apps back to internal. This is not a boot manager issue per se, but it's more related to the way builds are repackaged, it probably requires different location for ext2sd. I'll take a look someday.

- Recoveries backups will backup/restore all kernels at once instead of of doing each one separately.

History

2013/02/21: version 0.8

- Offline charging embedded in TWRP, bootmanager is no longer using native build to provide it.
- 1 GB system loop size added

Note: Offline charging can't be added to CWM so CWM is not recommended anymore, TWRP is safer for power management.

2013/01/28: version 0.7

- New settings menu, single boot/dual boot, boot manager protection enable/disable, alternate enable/disable
- Default is now single boot: in this mode, boot manager is only using one kernel and is only providing separate recovery for it.
- TWRP upgraded to v 2.3.3.0
- Only released with aosp build

2012/11/20: version 0.6

- Default recovery is now twrp
- Default kernel is now from 6.1.A.2.55 firmware
- TWRP updated to fix keyboard in backups
- Boot menu now remember which kernel was launched and defaults to it at next boot.
- Bootmanager protection: flashing a kernel that hasn't been repacked should fail. Temporary protection removal here if you want to get rid of bootmanager with a normal firmware.
- Native partition protection: flashing from loop recoveries should not be able to mount native partitions
- Kernel flasher bug fix: layout should now be calculated properly and big kernels shouldn't trash bootmanager anymore
- Notification led color changes depending on which recovery is launched
- ram_console is now properly handled by boot manager kernel. From now on, you should go to a recovery to get the last_kmsg for a crashing kernel.
- Boot manager can be flashed from recoveries.

2012/10/20: version 0.5

- flashable recoveries (cwm and twrp)!
- new kernel layout to give more space to loop kernel
- boot menu delay countdown fix
- offline charging forwarded to native build
- pre-installed kernel is now 6.1.A.2.50 one.
- added recoveries for alternate (re-partitioned devices only)

2012/10/06: version 0.4

- initramfs location moved to 0x41500000 for aokp and cm10 compatibility
- debug traces left in cwm removed
- new kernel extraction command (ke)

2012/10/02: version 0.3

- cwm recovery bugfix to get proper Aroma colors.
- stock / custom name changed to native / loopback in menus.
- added menu for cache loopback to adjust cache size.

2012/09/10: version 0.2

- CWMod recoveries are now working for stock (native) and custom (loopbacks).
- Loopbacks files are created if they are missing with multiple sizes.

2012/09/04: version 0.1

- Initial release, original thread here.
The Following 29 Users Say Thank You to letama For This Useful Post: [ View ] Gift letama Ad-Free
10th September 2012, 09:43 PM |#4  
OP Senior Member
Thanks Meter: 2,342
 
Donate to Me
More
For devs:

Source code:
  • Trimmed kernel uploaded to gitorious here , branch bootloader_kernel.
  • Boot menu (FBMenu, thanks to openAOS for initial release!) here.
  • Embedded kernel flasher kf : here.
  • Elf kernel splitter sksplit here. I use it mostly to extract kernel and cpio in repackaging firmware.

Background:

Here are some details on how it works:
  1. I trimmed down a stock kernel to remove some fat and add a driver to set a specific memory location.
  2. I embed a small assembly loader with this kernel and its cpio plus the other 2.
  3. The tiny kernel is loaded first, it displays the menu and eventually starts cwm. The menu will set the memory location with the kernel choice, then reboot.
  4. At next reboot, the assembly loader will detect the kernel choice and start the appropriate kernel.

So, in fact, you're booting two times, first the small loader, then the real boot.

It adds some boot time, but it's not dramatic. The advantage is that it's easy to build the loader, it's a simple init. Second advantage, the second kernel is running on a "fresh" start, no left-over in memory, no kexec patch to apply, it works with any kernel. Last, cwm can be embedded with the tiny kernel, so it's finally independent from the build kernel.
The Following 16 Users Say Thank You to letama For This Useful Post: [ View ] Gift letama Ad-Free
10th September 2012, 09:44 PM |#5  
OP Senior Member
Thanks Meter: 2,342
 
Donate to Me
More
Repack sample, FXP137 cm9.1:

unzip ../downloads/FXP137-cm-9-20120908-UNOFFICIAL-nozomi.zip
sksplit boot.img
sudo su
mkdir cpio
cd cpio
cat ../sec1-0x41300000.bin | gzip -d | cpio -i --make-directories
emacs init.semc.rc


Code:
# mount mmc partitions
    # mount /system, set up links to the modem, and remount r/o
    mount ext4 /dev/block/mmcblk0p12 /system wait rw barrier=1
    mkdir /system/etc/firmware/misc 0771 system system
    mount ext4 /dev/block/mmcblk0p12 /system wait ro barrier=1
    setprop ro.crypto.tmpfs_options size=128m,mode=0771,uid=1000,gid=1000
    mount ext4 /dev/block/mmcblk0p14 /data wait noatime nosuid nodev data=ordered noauto_da_alloc
    mount ext4 /dev/block/mmcblk0p13 /cache wait noatime nosuid nodev data=ordered noauto_da_alloc
becomes:

Code:
    # losetup on storage
    mkdir /sd
    mount vfat /dev/block/mmcblk0p15 /sd wait rw
    # ro directly as misc is created by install script
    mount ext4 loop@/sd/custom_system.ext4  /system wait ro barrier=1
    setprop ro.crypto.tmpfs_options size=128m,mode=0771,uid=1000,gid=1000
    mount ext4 loop@/sd/custom_data.ext4 /data wait noatime nosuid nodev data=ordered noauto_da_alloc
    mount ext4 loop@/sd/custom_cache.ext4 /cache wait noatime nosuid nodev data=ordered noauto_da_alloc
and:

Code:
     exec sbin/bootrec
becomes

Code:
     exec /system/bin/chargemon
and save

rm init.semc.rc~
cd sbin
rm e2fsck bootrec bootrec-device fix_permissions killrecovery.sh mke2fs nandroid-md5.sh parted postrecoveryboot.sh sdparted tune2fs
cd ..
find . | cpio -o -H newc | gzip > ../initramfs.cpio.gz
cd ..
rm -r cpio sec2-0x00020000.bin sec1-0x41300000.bin boot.img
mv sec0-0x40208000.bin zImage

emacs META-INF/com/google/android/updater-script

Code:
format("ext4", "EMMC", "/dev/block/mmcblk0p12", "0");
mount("ext4", "EMMC", "/dev/block/mmcblk0p12", "/system");
becomes

Code:
format("ext4", "EMMC", "/dev/block/loop2", "0");
mount("ext4", "EMMC", "/dev/block/loop2", "/system");
then

Code:
package_extract_file("boot.img", "/dev/block/mmcblk0p3");
becomes

Code:
package_extract_file("zImage", "/tmp/zImage");
package_extract_file("initramfs.cpio.gz", "/tmp/initramfs.cpio.gz");
assert(run_program("/sbin/kf", "2",  "/tmp/zImage", "/tmp/initramfs.cpio.gz") == 0);
add before this :
Code:
show_progress(0.200000, 0);
show_progress(0.200000, 10);
this:
Code:
run_program("/sbin/busybox", "mkdir", "/system/etc/firmware/misc");
set_perm(1000, 1000, 0771, "/system/etc/firmware/misc");
and save, then finally:

zip -r ../cm9-loop.zip *
The Following 19 Users Say Thank You to letama For This Useful Post: [ View ] Gift letama Ad-Free
10th September 2012, 09:44 PM |#6  
OP Senior Member
Thanks Meter: 2,342
 
Donate to Me
More
Repack Sample, 6.1.A.2.45 firmware on stock/native:

mkdir stock_6.1.A.2.45_zip
cd stock_6.1.A.2.45_zip
7z x ../downloads/LT26i_6.1.A.2.45_GENERIC_NL.7z
7z x "LT26i_6.1.A.2.45_GENERIC NL.ftf"
rm "LT26i_6.1.A.2.45_GENERIC NL.ftf"
mkdir zip_out
sin2raw kernel.sin kernel.elf
sksplit kernel.elf
mv sec0-0x40208000.bin zip_out/zImage
mv sec1-0x41300000.bin zip_out/initramfs.cpio.gz
sin2raw system.sin system.ext4
sudo su
mkdir system
mount -o loop -t ext4 system.ext4 system
cd system


... optionally add root, busybox:

cp -r /home/tama/supersu/system/* .
cd xbin
chmod 6755 su
cp /home/tama/cm9/out/target/product/gen9/system/xbin/busybox .
cp /home/tama/relink-busybox.sh .
chmod 755 relink-busybox.sh
cd ../..
tar -cvzf zip_out/system.tgz system
... get script from cm9, ..
cd zip_out
cp -a ../../fxp137_cm9_ziploop/META-INF .
emacs META-INF/com/google/android/updater-script


Code:
assert(getprop("ro.product.device") == "LT26i" || getprop("ro.build.product") == "LT26i" ||
       getprop("ro.product.device") == "LT26a" || getprop("ro.build.product") == "LT26a" ||
       getprop("ro.product.device") == "nozomi" || getprop("ro.build.product") == "nozomi");

ui_print("LT26i 6.1.A.2.45 firmware for boot manager (stock)");
show_progress(0.100000, 5);
format("MTD", "system");
mount("MTD", "system", "/system");
show_progress(0.700000, 60);
package_extract_file("system.tgz", "/tmp/system.tgz");
assert(run_program("/sbin/tar", "-cvzf",  "/tmp/system.tgz") == 0);
show_progress(0.200000, 10);
assert(run_program("/system/xbin/busybox-relink.sh", "");
unmount("/system");
package_extract_file("zImage", "/tmp/zImage");
package_extract_file("initramfs.cpio.gz", "/tmp/initramfs.cpio.gz");
assert(run_program("/sbin/kf", "1",  "/tmp/zImage", "/tmp/initramfs.cpio.gz") == 0);
ui_print("Firmware installation complete");
The Following 13 Users Say Thank You to letama For This Useful Post: [ View ] Gift letama Ad-Free
10th September 2012, 09:45 PM |#7  
OP Senior Member
Thanks Meter: 2,342
 
Donate to Me
More
Repackage sample, KA14 with Aroma installer

Code:
sudo su
mkdir ka14
cd ka14
unzip /home/tama/sony/downloads/KA14_Xperia_SSpeed.zip
mv zImage zImage.original
sksplit zImage.original
mkdir cpio
cd cpio
cat ../sec1-0x41300000.bin | gzip -d | cpio -i --make-directories
rm *~
rm init
rm init_gb
mv init_ics init
rm recovery.*
rm -r res
rm 1
rm init.sh
cd sbin
rm tune2fs sdparted parted nandroid-md5.sh nandroid mr mke2fs killrecovery.sh fota-ua fota-mke2fs  fix_permissions e2fsck checkabortedflash autoroot.sh
ln -s /init ueventd
cd ..
find . | cpio -o -H newc | gzip > ../initramfs.cpio.gz
cd ..
mv sec0-0x40208000.bin zimage
emacs META-INF/com/google/android/updater-script
change:
Code:
          assert(package_extract_file("zImage", "/tmp/zImage"),
                        write_raw_image("/tmp/zImage", "/dev/block/mmcblk0p3"),
                        delete("/tmp/zImage"));
to:
Code:
          package_extract_file("zimage", "/tmp/zimage");
          package_extract_file("initramfs.cpio.gz", "/tmp/initramfs.cpio.gz");
          assert(run_program("/sbin/kf", "1",  "/tmp/zimage", "/tmp/initramfs.cpio.gz") == 0);
Code:
zip -r ../bm_native_ka14.zip META-INF customize system zimage initramfs.cpio.gz
The Following 13 Users Say Thank You to letama For This Useful Post: [ View ] Gift letama Ad-Free
10th September 2012, 09:45 PM |#8  
OP Senior Member
Thanks Meter: 2,342
 
Donate to Me
More
AOSP experiment
Special build, aosp 4.2.1 experiment!

This one is special and deserve specific instructions.

First, it's not functional, and will never be.

I just wanted to have a look at current status of AOSP experiment for Xperia S, it required much more fiddling than reasonable and ended into a monster.

Again, I take no responsability if you flash this. It doesn't work properly, it's not tested, it can be bad for your phone
.

Second, if you want to install this, read carefully instructions, it's not packaged like a normal loop rom.

[B]Last: special thanks to FXP team, it wouldn't have been this far with the work they did on CM10. I took few binaries from FXP release and few patches from Cyanogen repo, no way to make it run without the work they did.

Now, that the warning are there, here is the status:

What's working:
1) It boots
2) Audio
3) Phone call/sms
4) Wifi

What's not working:
1) Data
2) Storage
3) And much more

Pre-Installation:

1) You need around 2G free space on storage
2) It will replace your loop kernel but keeps the loopback files untouched
3) If you want to save your current kernel, you can do this from loopback recovery with adb:

Code:
adb shell ke 2 /tmp/zimage /tmp/initramfs
adb pull /tmp/zimage
adb pull /tmp/initramfs
Installation

From loopback recovery, install zip file.

Restore previous loopback rom

Flash build zip file without wiping data/cache

or if you saved your kernel previously:

Code:
adb push zimage /tmp
adb push initramfs /tmp
adb shell kf 2 /tmp/zimage /tmp/initramfs
adb shell sync
then boot your loopback build.

Download

Download rom here, mirrors.

FAQ

1) What is this ?

I started this to check status of Google/Sony AOSP experiment. I wanted to see how far they went and how it behaves.

2) Why not making it functional ?

As it is, it's not worth it. To have the running state I have, I had to patch google aosp source, patch kernel, fiddle with FXP binaries, etc... This build is a Frankenstein monster and it would take quite a big amount of work to end up with something that takes many things from CM and doesn't work as good as CM.

We'll see if Sony goes further in releasing proprietaries and source code, but without that, AOSP will end up in CM without CM bonus
The Following 12 Users Say Thank You to letama For This Useful Post: [ View ] Gift letama Ad-Free
10th September 2012, 09:57 PM |#9  
Vipitus's Avatar
Senior Member
Thanks Meter: 606
 
More
Wow, this is far more superior than 0.1!
So now I can install every ROM on loops?
10th September 2012, 09:59 PM |#10  
OP Senior Member
Thanks Meter: 2,342
 
Donate to Me
More
Quote:
Originally Posted by Vipitus

Wow, this is far more superior than 0.1!
So now I can install every ROM on loops?

No, that's not possible, you need adapted zip for it. Maybe in a future version, but I think it would be very difficult to patch cpio's on the fly.

I'll continue adapting few builds to give more choice though.
10th September 2012, 10:02 PM |#11  
Vipitus's Avatar
Senior Member
Thanks Meter: 606
 
More
For now only CM9, yes?

---------- Post added at 10:02 PM ---------- Previous post was at 10:00 PM ----------

Quote:
Originally Posted by letama

(...)First make sure that your stock firmware is 6.1.A.2.56

Do this firmware exists?
Do you mean 6.1.A.2.45?
Post Reply Subscribe to Thread

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

Advanced Search
Display Modes