[Samsung Galaxy Nexus] dlhxr:
Step 1: How to Modify the U-boot Source

Since developer sp3dev on xda ported u-boot for galaxy nexus, we have the opportunity to exploit it and realize dual-boot on our device. Feel free to email me (dlhxr@163.com) or pm me on xda.

Modify the U-boot

Notice: This step can be skipped using my pre-built u-boot.

View attachment 1841638

* Normal Boot -> No keys are pressed, cyan LED ->Find kernel in /data/media/boot/1st.img

* Recovery Boot -> Volume Up key pressed, green LED -> Go to recovery

* Custom Boot -> Volume Down key pressed, blue LED ->Find kernel in /data/media/boot/2nd.img

!!!It will replace your kernel. Remember to copy your boot.img to /data/media/boot/1st.img first!!!

Another pre-built u-boot by me for tri-boot!!!

View attachment 1841639

* First Boot -> No keys are pressed, cyan LED ->Find kernel in /data/media/boot/1st.img

* Third Boot -> Volume Up key pressed, green LED -> Find kernel in /data/media/boot/3rd.img

* Second Boot -> Volume Down key pressed, blue LED ->Find kernel in /data/media/boot/2nd.img

!!!It will replace your kernel. Remember to copy your boot.img to /data/media/boot/1st.img first!!!

The pre-compiled version sp3dev provides can only boot one kernel when using android 4.2 system as the main system because sdcard simulation method changed in 4.2 system. The sdcard path is /data/media/0, not /data/media. Sp3dev made the volume down button function to boot from /data/media and it cannot find the kernel we put in sdcard. So I managed to correct the path, successfully boot different kernel on device.

Edit: I change the kernel path to /data/media/boot to make sure the kernel won't be wiped by cwm recovery!

With the help of sp3dev, I successfully change the location of the custom boot kernel to /data/media/boot/2nd.img and the normal boot kernel to /data/media/boot/1st.img.

Firstly, I downloaded the source file of u-boot (https://github.com/Ksys-labs/uboot-tuna) and ARM cross-compiler codesourcery 2010q1-188 version. Exact them to the folder you like.

Change some configuration in /u-boot-source/include/configs/omap4_tuna.h.

Find the following lines.

"kernel_name=/boot/vmlinux.uimg\0" \
"script_img/boot/vmlinux.scr.uimg\0" \

Change to

"kernel_name=/meida/boot/1st.img\0" \
"script_img/media/boot/1st.scr.uimg\0" \

And find

"boot_system=echo Booting SYSTEM; "\

Change one of the lines below it from

"setenv kernel_part 0xa; " \

to

"setenv kernel_part 0xc; " \

This one changes the normal boot kernel location and kernel file name to /data/media/boot/1st.img

Now we correct the location for custom boot kernel location. Find the following lines.

"boot_custom_emmc=echo Booting custom image; " \
"tuna_set_led 4; " \
"setenv loadaddr 0x81f00000; " \
"setenv script_img media/boot/vmlinux.scr.uimg; " \
"setenv kernel_name media/boot/vmlinux.uimg; " \
"setenv script_part 0xc; " \
"setenv kernel_part 0xc; " \
"setenv rootpart 0xc; " \
"setenv devnum 0; " \
"setenv devtype mmc; " \
"setenv bootargs " \
"${dev_extras} root=/dev/${devname}${rootpart} rootwait ro ;"\
"run load_boot_script; " \
"run custom_boot\0" \

Change to

"boot_custom_emmc=echo Booting custom image; " \
"tuna_set_led 4; " \
"setenv loadaddr 0x81f00000; " \
"setenv script_img /media/boot/2nd.scr.uimg; " \
"setenv kernel_name /media/boot/2nd.img; " \
"setenv script_part 0xc; " \
"setenv kernel_part 0xc; " \
"setenv rootpart 0xc; " \
"setenv devnum 0; " \
"setenv devtype mmc; " \
"setenv bootargs " ANDROID_CMDLINE " ;"\
"run load_boot_script; " \
"run custom_boot\0" \

Save the file and recompile the u-boot using the following script. (Go to source folder first.)

export PATH=/home/hoary/codesourcery/bin:$PATH
#Note: You should change the path to your codesourcery compiler location.
export ARCH=arm
export CROSS_COMPILE=arm-none-eabi-

make clean
make distclean

make omap4_tuna_config
make -j8 omap4_tuna

And you can find u-boot.bin in your source folder.

Find pre-compiled mkbootimg to make u-boot.bin a flashable img in CWM recovery.

View attachment 1841687

mkbootimg --kernel u-boot.bin --ramdisk /dev/null -o u-boot.aimg

And copy your current kernel (boot.img) to /data/media/boot/1st.img. Using CWM flashable zip or fastboot to flash u-boot to boot partition.

CWM zip updater-script
package_extract_file("u-boot.aimg", "/dev/block/platform/omap/omap_hsmmc.0/by-name/boot");
Fastboot
fastboot flash boot u-boot.aimg