[XPERIA X10 Android Development] DooMLoRD:
{ LONG POST WARNING }

{ NOT FULLY WORKING YET}

{ NEEDS A LOT OF FURTHER DEVELOPMENT }

Hey everyone I had thought of making this Dual Booting system work along side recovery… because initially (with FreeX10-alpha) it was not possible to have both recovery & dual boot...

Thank you zdzihu & jerpelea for your great work on FreeX10-alpha, which booted off SDCARD… I got inspiration to try and make this work for FreeX10-beta4 based on the amazing work that u guys did! Thank you jerpelea for all your feedback on my repeated messages when I was testing this a few months back (hope I didn’t bother u too much with questions :P )...

zdzihu & jerpelea u are truly LEGENDS!!!

[This is just my personal opinion] Really hoping that some devs can take interest in this to provide compatible files (ramdisks, system files) for this to work… may be as an add-on to their main roms… please don’t keep bothering devs to create ramdisks for booting off SDCARD… they are already very busy trying to make our X10 better with faster and stable ROMS/MODS/etc… this is just an additional feature…

The basic idea was to use the chargemon booting scripts provided in FreeX10-alpha and to try and make FreeX10-beta4 to boot off SDCARD…

Initially I used the img files which came with FreeX10-alpha and wiped the image to then put FreeX10-beta4 on it… while doing so I realized that all of the symbolic links were not getting copied correctly (obviously)… so I started from scratch with blank ext2fs images…

Later I thought of using clean/base nandroid/recovery backups as they are already working/preconfigured system of FreeX10-beta4…

Following is a small How-To on converting NANDROID/RECOVERY images (with yaffs fs) to ext2 fs images keeping the symlinks intact!!

I have used Ubuntu for these steps.

I have attached blank_files.7z which contains precompiled ext2fs images:

system.img [size: 256 MB]

data.img [size: 512 MB]

cache.img [size: 128 MB]

To resize or create newer ext2fs images:

[APP] Windows: Create Your Own Data.img Maker Application, +/- From Existing data.img

U can use the commands provided there even in linux to create/resize these images...

We will keep the NANDROID images at:

/home/user/nandroid_imgs/test1/

and EXT2 FS images at:

/home/user/ext2fs_imgs/test1/

while temporary mounts points will be made at:

/home/user/mntpts/

We will be using unyaffs from here:

[How-To] Extracting/Accessing Recovery/Nandroid backup (.img) files

Extracting files from the nandroid/recovery backups:

cd /home/user/nandroid_imgs/test1

mv system.img /home/user/nandroid_imgs/test1/system/
cd /home/user/nandroid_imgs/test1/system/
sudo unyaffs system.img
mv system.img ../.

mv data.img /home/user/nandroid_imgs/test1/data/.
cd /home/user/nandroid_imgs/test1/data/
sudo unyaffs data.img
mv data.img ../.

mv cache.img /home/user/nandroid_imgs/test1/cache/
cd /home/user/nandroid_imgs/test1/cache/
sudo unyaffs cache.img
mv cache.img ../.

Loop mounting ext2 fs files:

sudo mount -t ext2 -o loop,rw,noatime,nodiratime /home/user/ext2fs_imgs/test1/system.img /home/user/mntpts/system/
sudo mount -t ext2 -o loop,rw,noatime,nodiratime,nosuid,nodev /home/user/ext2fs_imgs/test1/data.img /home/user/mntpts/data/
sudo mount -t ext2 -o loop,rw,noatime,nodiratime,nosuid,nodev /home/user/ext2fs_imgs/test1/cache.img /home/user/mntpts/cache/

Recursively copy all files (preserving symlinks) from extracted yaffs images to mount points

sudo cp -r -p /home/user/nandroid_imgs/test1/system/* /home/user/mntpts/system/.
sudo cp -r -p /home/user/nandroid_imgs/test1/data/* /home/user/mntpts/data/.
sudo cp -r -p /home/user/nandroid_imgs/test1/cache/* /home/user/mntpts/cache/.

Unmount the mounts:

sudo umount /home/user/mntpts/system/
sudo umount /home/user/mntpts/data/
sudo umount /home/user/mntpts/cache/

Ok now that the ext2fs iamges are populated with working files copy them onto SDCARD…

I have placed it at:

/sdcard/FreeX10

lets move on to the chargemon script...

This is, as of now, based off xRecovery chargemon (modified from FreeX10-alpha)

#!/system/bin/busybox sh

# modified chargemon for recovery + dual boot from NAND/SDCARD

/system/bin/charger

cat /dev/input/event2 > /dev/keycheck&
sleep 3
kill -9 $!

# intact recovery
if [ -s /dev/keycheck ]
then

# remount rootfs rw
mount -o remount,rw rootfs /

# Umount MTDs
umount -l /data
umount -l /cache

# Extract recovery
cd /
rm -r /sbin
rm -f etc
tar -xf /system/bin/xrecovery.tar

# Umount system
umount -l /system

chroot / /init

fi

echo "check if reboot into SDCARD OS was called"
if [ -e /data/local/tmp/rebootsdcardos ]
then

echo "Booting from SDCARD!"

# FreeX10-alpha code follows with slight modifications!!!

# remount rootfs rw
mount -o remount,rw rootfs /

busybox chmod 0777 /dev -R
busybox chown 0.2000 /dev/oncrpc -R
rm -r /sdcard

cd /
mkdir sd
chmod 777 sd
rm init*
rm logo.rle
rm default.prop
tar -xf /system/bin/sdcardos_ramdisk.tar

# Umount system,data,cache
umount -l /system
umount -l /data
umount -l /cache

# Check and mount SD Card
dosfsck -y /dev/block/mmcblk0p1
sleep 5
mount -t vfat -o rw,noatime,nodiratime /dev/block/mmcblk0p1 /sd
sleep 5

# Mount system and data ext2 images
losetup /dev/block/loop1 /sd/FreeX10/system.img
sleep 5
losetup /dev/block/loop2 /sd/FreeX10/data.img
sleep 5
losetup /dev/block/loop3 /sd/FreeX10/cache.img
sleep 5
e2fsck -y /dev/block/loop1
e2fsck -y /dev/block/loop2
e2fsck -y /dev/block/loop3
mount -t ext2 -o rw,noatime,nodiratime /dev/block/loop1 /system
sleep 5
mount -t ext2 -o rw,noatime,nodiratime,nosuid,nodev /dev/block/loop2 /data
sleep 5
mount -t ext2 -o rw,noatime,nodiratime,nosuid,nodev /dev/block/loop3 /cache
sleep 5

# zdzihu: hack-fix
if [ -e /data/data/com.android.providers.telephony/databases/telephony.db ]; then
/system/bin/chroot / /init
exit
fi

# Chroot :)
chroot / /init

# jump out of chargemon to skip NAND booting
exit
fi

echo "Booting from NAND!"

# remount rw
mount -o remount,rw rootfs /

cd /
rm -r /sdcard
rm init*
rm logo.rle
rm default.prop
tar -xf /system/bin/ramdisk.tar

# zdzihu: hack-fix
if [ -e /data/data/com.android.providers.telephony/databases/telephony.db ]; then
/system/bin/chroot / /init
exit
fi

chroot / /init

Recovery is intact so u can get into recovery the normal way… (press/tap back key after seeing SE text logo)

OS on NAND (normal system on MTD) will boot by default…

To reboot into OS on SDCARD issue the following commands in terminal emulator/adb shell:

touch /data/local/tmp/rebootsdcardos
reboot

NOW the OS should start booting off the SDCARD…

It completes commands in chargemon and then BootAnimation can be seen…

BUT HERE IS THE PROBLEM!

Check LOGCAT here: http://www.mediafire.com/?phxm3uqzp0dzzhb

here is wht J had to say:

From my limited understanding we yet have to make a proper ramdisk (sdcardos_ramdisk.tar)… I feel the init.rc file has to be changed especially the following line (based off FreeX10-beta4 ramdisk):

mount yaffs2 mtd@system /system rw remount
mount yaffs2 mtd@userdata /data nosuid nodev
mount yaffs2 mtd@cache /cache nosuid nodev

As for Multi-Booting:

We can keep adding different sections to chargmeon:

/data/local/tmp/rebootsdcardos1
/data/local/tmp/rebootsdcardos2
etc…

OR

possible solution for having both recovery and dual boot

and similarly keep adding ramdisks in NAND /system:

sdcardos1_ramdisk.tar
sdcardos2_ramdisk.tar
etc

So we can have as many OS/ROMs on SDCARD as u have free space… though we need to make specific ramdisks for each…

Hope this was slightly useful… and waiting for feedback from advance users on how we can get this working....