FORUMS
Remove All Ads from XDA

uboot bootloader - for the true multiboot

554 posts
Thanks Meter: 680
 
By sp3dev, Senior Member on 30th May 2012, 01:21 AM
Post Reply Email Thread
Hi! I have ported the u-boot bootloader to Samsung Galaxy S2.

What's this for
This is for allowing true multi-boot on our device. Since Samsung combined boot and recovery partitions into a single one, it is impossible to use different kernels for boot and recovery, thus it is impossible to, say, dual-boot android and ubuntu with different kernels without reflashing.

Is it safe?
Should be not more dangerous than flashing a new kernel. We're not overwriting the original Secondary Bootloader (SBL), we're chainloading from it.

Mind that currently only european galaxy s2 (with max8997 pmic and wvga screen) is supported.

How to install and test
Download the precompiled u-boot.bin http://www.mediafire.com/?ovd6asa90de4ifn
Download the uImage (3.0.30 cm9 image) http://www.mediafire.com/?y3g1e463rzas9vm

flash the uboot with heimdall
Code:
heimdall flash --kernel u-boot.bin
we abuse the unused-by-default recovery partition for keeping the linux kernel
Code:
heimdall flash --recovery uImage
You may put a custom uImage and u-boot boot script to the emmc ums partition (the 12G one). Put them to
Code:
boot/vmlinux.uimg
boot/boot.scr.uimg
accordingly. vmlinux.uimg is just a renamed uImage. Take care - for this 'custom' kernel the cmdline is different from android one, it tells the kernel to boot off microsd partition 2. If you want to use custom kernels, please hardcode the command line in kernel config when compiling. To boot the 'custom' kernel you need to hold the home key while turning on the device.

A practical example - booting Siyah kernel from emmc
Get boot.scr.uimg http://www.mediafire.com/?k4s2ldudk8g9u4e
Get siyah uImage http://www.mediafire.com/?w57aqn7jig4ij5k
copy them to the device
Code:
adb shell mkdir /sdcard/boot
adb push boot.scr.uimg /sdcard/boot
mv uImage android.uimg
adb push android.uimg /sdcard/boot
For devs - How to compile
Grab u-boot source @ my gitorious, branch is i9100_tracking
https://gitorious.org/i9100-proper-linux/i9100-uboot

for compiling uboot:
export PATH, CROSS_COMPILE and ARCH variables and do sth like this
Code:
make galaxys2_config
make -j6 galaxys2
for compiling uImage either add uboot/tools to PATH and use "make uImage" target in kernel. Or, wrap the existing zImage into uImage
Code:
u-boot/tools/mkimage -A arm -O linux -T kernel -C none -a 0x40008000 -e 0x40008000 -n Linux-android-sucks -d cm9_kernel/arch/arm/boot/zImage uImage
for compiling boot script, use the following command. Please remember that you need to use a different loadaddr not to overwrite the boto script
Code:
mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n "android" -d boot.cmd boot.scr.uimg
Here is an example boot script
Code:
setenv android_cmd loglevel=4 console=ram sec_debug.enable=0 sec_debug.enable_user=0 sec_log=0x100000@0x4d900000 s3cfb.bootloaderfb=0x5ec00000 ld9040.get_lcdtype=0x2 consoleblank=0 lpj=3981312 vmalloc=144m;

if test $sgs2_bootmode_val -eq 1; then
	setenv android_cmd ${android_cmd} bootmode=2;
fi
setenv bootargs ${android_cmd}

setenv devtype mmc
setenv devnum 0
setenv kernel_part 0xb
setenv kernel_name /boot/android.uimg
setenv loadaddr 0x4EF08000

echo Load Address:${loadaddr};
echo Cmdline:${bootargs};

if fatload ${devtype} ${devnum}:${kernel_part} ${loadaddr} ${kernel_name}; then
	bootm ${loadaddr};
	exit 0;
elif ext2load ${devtype} ${devnum}:${kernel_part} ${loadaddr} ${kernel_name}; then
	bootm ${loadaddr};
	exit 0;
else
	echo failed to boot custom image;
fi
TODO
Add lcd and board revision detection to build a proper command line

Add support for other galaxy s2 and Note revisions - depending on the user feedback and testing volunteers

Fix MTYPE (linux kernel machine type). Samsung uses the same mtype for all boards which is clearly wrong. In my linaro-based kernel I'm using a new mtype which I registered for I9100. Since CM9 kernels enable more than one board, booting will fail if mtype is wrong. So, for now, uboot is using samsung's mtype, and I want to find a way to switch it in runtime.

Add galaxys2 modem support to fsogsmd or ofono, install Mer or ubuntu and get rid of the java-ridden crapware named Android
The Following 29 Users Say Thank You to sp3dev For This Useful Post: [ View ] Gift sp3dev Ad-Free
 
 
30th May 2012, 02:08 AM |#2  
Phistachio's Avatar
Senior Member
Flag Belgium, BE
Thanks Meter: 1,030
 
More
Great job! Any chance on getting it as a .tar ODIN flashable file? I could make a guide to help newbies use the uboot bl as well when it's developed further

Using both CM9 Kernel for CM9 and Siyah for Resurrection Remix ICS is a great sight!
30th May 2012, 04:19 AM |#3  
bala_gamer's Avatar
Recognized Contributor
Flag Madurai-Chennai
Thanks Meter: 7,042
 
Donate to Me
More
looks promising. great going
30th May 2012, 05:58 AM |#4  
NOMIOMI's Avatar
Senior Member
Flag Abbottabad
Thanks Meter: 1,279
 
More
dual boot ... mean two different roms on sgs2 like siyah kernel???
30th May 2012, 06:08 AM |#5  
sahibunlimited's Avatar
Senior Member
Flag Nagpur
Thanks Meter: 2,453
 
More
Deleted
30th May 2012, 09:36 AM |#6  
OP Senior Member
Flag Kaluga/Moscow
Thanks Meter: 680
 
More
I am unsure about multiple android kernels - need to make some boot scripts to test. My initial aim was to support both android and native Ubuntu. I will tell you about dual-booting android, but I need time for testing
30th May 2012, 09:49 AM |#7  
Senior Member
Flag Thessaloniki
Thanks Meter: 221
 
More
How about using my code in board_unit()? Seems to me like the only way. I don't see how it can be done without modifying uboot.

Sent from my GT-I9100 using XDA
30th May 2012, 10:10 AM |#8  
OP Senior Member
Flag Kaluga/Moscow
Thanks Meter: 680
 
More
Quote:
Originally Posted by MemoryController

How about using my code in board_unit()? Seems to me like the only way. I don't see how it can be done without modifying uboot.

Sent from my GT-I9100 using XDA

Please take a look at my git, the boot key detection is done in a very similiar way. I would suppose that we can put any commands in the uboot script file and can boot custom android kernels with that
The Following User Says Thank You to sp3dev For This Useful Post: [ View ] Gift sp3dev Ad-Free
30th May 2012, 10:13 AM |#9  
Senior Member
Flag Thessaloniki
Thanks Meter: 221
 
More
About the mtype I mean. Doesn't it need to be set in board_init ()? I will checkout the git later.

Sent from my GT-I9100 using XDA
30th May 2012, 10:37 AM |#10  
OP Senior Member
Flag Kaluga/Moscow
Thanks Meter: 680
 
More
need to think of mtype..

anyway, updated the first post with the instructions how to boot siyah from emmc. now we can multi-boot android kernels
30th May 2012, 12:57 PM |#11  
tolis626's Avatar
Senior Member
Flag Amaliada
Thanks Meter: 617
 
More
With the SGS3 and this,I think my SGS2 will just replace my fried old PC and get hooked to my TV.Nice job man.Really nice.
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