• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!

uboot bootloader - for the true multiboot

Search This thread

sp3dev

Senior Member
Jul 11, 2006
554
675
Kaluga/Moscow
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 [email protected] 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
 
Last edited:

Phistachio

Senior Member
Oct 22, 2011
1,475
1,026
25
Belgium, BE
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!
 

sp3dev

Senior Member
Jul 11, 2006
554
675
Kaluga/Moscow
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
 

sp3dev

Senior Member
Jul 11, 2006
554
675
Kaluga/Moscow
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
 
  • Like
Reactions: TriboDoP

jphilpot

Senior Member
Jul 8, 2010
68
0
hello

I know you state this will only work on the European version but just wanted to confirm this would not work on att i777. There was so many variants i was not sure.

I think i have the max8997 pmic and wvga screen but not positive
 
Last edited:

joesnose

Senior Member
Dec 5, 2009
840
154
This is geat news. Just wondering why this is not buzzing as big news. Native booting linux, who wouldn't apreciate that. Especially if the telephony part got worked out, could hardly see much point in booting to android. Good work.
 

joesnose

Senior Member
Dec 5, 2009
840
154
Could anyone write a step by step tutorial. I am a little confused as to how to and what to do. Do I loe my siyah kernel? Or does it dual boot my dual boot kernel, lol.

Sent from my GT-I9100 using Tapatalk 2
 

Top Liked Posts

  • There are no posts matching your filters.
  • 29
    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 [email protected] 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
    3
    Will make a noob friendly tutorial tomorrow

    Sent from my GT-I9100 running CM10
    1
    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
    1
    Hello I am indeed joe stranger.

    I am not that great at all this stuff myself.

    The cheese.txt file is empty and can be called whatever you like and placed where you like as long as you adapt the script I posted previously to reflect the changes. The script just looks for the file, in my case cheese.txt and if it finds it runs the commands in the script.

    As far as I can remember in ubuntu I just created a launcher on the desktop with the cp command. Something like...

    cp /storage/sdcard0/Download/cheese.txt /storage/sdcard0/

    ...so you can see I keep a file in /Download/ called cheese.txt which is copied to the root of my sdcard. If the script is running in android it deletes the cheese.txt file and runs the start.prop commands.

    I am sorry if I am a little vague I have since got a nexus 7 which can boot ubuntu natively with touchscreen, rotation and sound all working.

    Also it may be worth starting a new thread as we have hijacked this thread.

    The beauty of the uboot method, which I could never figure out, is that it allows booting ubuntu using a linux kernel. The OP seems to have touch screen working with evdev and states that sound can be enabled. That being said I am sure I read that they are trying to bring linux and android kernel together, this would surely make linux on thd framebuffer a little more stable.

    For me I often found myself using vnc to access my linux as it allowed for better touch control.

    Hope this helps. Feel free to pm me for any more tips or maybe start a new thread?



    Sent from my Nexus 7 using Tapatalk 2