[Gen9 Android Development] trevd:
Me Again!

Just a cheeky little update, I been trying the figure out the best approach to handle switching between android and recovery mode. In effect I kind of wanted to create a Stage 4 bootloader! because you can never have too many bootloaders LOL :D I certainly wanted to do a "proper" job on it and try to avoid changes to the android platform code.

While to doing research into this I found this patch to the linux kernel which the android team submitted for review, Reading the mailing list thread I don't think it's been accepted yet! It's true what they say about the Kernel Mailing List, You need to bring your A game and be sure of what your doing.. :)

Anyways the patch add a boot-control-block driver to kernel which check for a boot flag, which is exactly what I need to make booting into alternative configuration nice and simple. I suppose it wouldn't be too difficult to chuck in support for the fastboot protocol on one of those configurations. So a CWM Shouldn't be too far off now!!!

As a little treat I've attached a recovery based ram disk if anyone what's to play, just flash it with you favourite kernel on to your sde partition. Then You can boot into recovery and set your self up a pseudo partition image layout through adb. You won't be able to be into android, obviously until you put your old initramfs back.......

I'm just chucking up for those who want to get a feel for to do so. If your uncomfortable playing around in this area then stand well back, It's not prime time yet!!!!

However Feel free to ask questions of a technical bent but If you can't get it to boot then tough luck I'm afraid for now! :laugh:

You shouldn't be able to do any damage with this be I wouldn't go selecting wipe/format etc until you've got some partition images sorted.

I've add abcbox to sbin and symlink reboot_into. It does not seem to fully reboot but It will set the boot flag which you then follow with a call to reboot, That will reboot back into CWM (sde).

Onward

EDIT: Here's the Init.rc and etc/recovery.fstab that It attempts to use.

on early-init
start ueventd

on init
export PATH /sbin
export ANDROID_ROOT /system
export ANDROID_DATA /data
export EXTERNAL_STORAGE /sdcard

symlink /system/etc /etc

mkdir /boot
mkdir /sdcard
mkdir /system
mkdir /data
mkdir /cache
mkdir /mnt
mkdir /mnt/rawfs
mount /tmp /tmp tmpfs
mkdir /partitions 0771 system system
mount ext4 /dev/block/mmcblk0p4 /partitions
mount rawfs /dev/block/mmcblk0p1 /mnt/rawfs

# Mount /system rw first to give the filesystem a chance to save a checkpoint
mount ext4 loop@/partitions/CAC /cache nosuid nodev
mount ext4 loop@/partitions/DATA /data nosuid nodev
mount ext4 loop@/partitions/SYS /system
mount ext4 loop@/partitions/SDCARD /sdcard nosuid nodev
mount ext4 loop@/partitions/BOOT /boot

on boot

ifup lo
hostname localhost
domainname localdomain

class_start default

service ueventd /sbin/ueventd
critical

service recovery /sbin/recovery

service adbd /sbin/adbd recovery
disabled

# Always start adbd on userdebug and eng builds
# In recovery, always run adbd as root.
on property:ro.debuggable=1
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/idVendor 18D1
write /sys/class/android_usb/android0/idProduct D001
write /sys/class/android_usb/android0/functions adb
#write /sys/class/android_usb/android0/enable 1
write /sys/class/android_usb/android0/iManufacturer $ro.product.manufacturer
write /sys/class/android_usb/android0/iProduct $ro.product.model
write /sys/class/android_usb/android0/iSerial A101S_REC
write /sys/class/leds/lcd-backlight/brightness 75
#start adbd
setprop service.adb.root 1

# Restart adbd so it can run as root
on property:service.adb.root=1
write /sys/class/android_usb/android0/enable 0
restart adbd
write /sys/class/android_usb/android0/enable 1

Recovery.fstab

# mount point fstype device

/cache ext4 /dev/block/loop0
/data ext4 /dev/block/loop1
/system ext4 /dev/block/loop2
/sdcard ext4 /dev/block/loop3