U-Boot Running inside U-Boot

What is U-Boot?

Das U-Boot or sub-texted as Universal boot loader is an open source secondary stage boot loader mostly used in embedded devices and in custom Android Devices. U-boot further has capabilities to cater the needs of a complex Operating System. boot-up such as tftp boot, emmc boot etc.

Why? I am writing about this.

Well, Recently I stumbled upon a broken target which I was working on, or more slang-ish term would be bricked target. So, this target will not boot-up because some how I crashed the U-Boot Image on that because I loaded a u-boot on top of it with some missing configurations and was failing in loading the further kernel images.

How? I brought it back to life.

I started googling the solution did not found the much of idea to get it back. So started with a hunch since U-boot initializes a significant parts in the target environment including the RAM, ALU,CLOCKS, GPIOs etc.Given this the terminal given by U-boot should be capable of executing executable as kernel image (Linux) itself is an executable which gets executed by u-boot such images are know as flat binary. To cut short the flat binary is a binary which has not structure or segments (it does not require any run time environment as of a .elf or .exe binary) and can be directly loaded to ram and executed from there.

With given little bit of hunch the next encampment was to find the flat binary executable which can be loaded by u-boot. The first thought comes to mind that u-boot itself should be a flat binary as it directly runs on a target which is bare-metal, then what is the catch? Well there is one and here it goes… most of the micro-controllers ( or System-on_Chips would be a better ) has a Primary Stage Boot Loader which adds cetrain type of header requirement to the first executable loaded on ram which is U-Boot or some type of boot-loader and most of the build system generates the specific boot-loader code packed with required header.

So? How to do it.

There are the answers are load and go that’s sort form of answer and bit of explanation is there are many many ways to load the binary to the ram from u-boot terminal the variations go from filesystem dependent loads etc. and basically we load it to a address in RAM or flash memory if you have (highlight unlikely), but what to load, in almost all the builds u-boot generates the .bin version of itself hence I rebuilt the u-boot with correct settings and loaded the binary at RAM address and executed the image with go command (Example below.)Also, follow the below link for more from u-boot. Post the questions and comments if any further explanations are required.

U-Boot> fatload usb 0:1 0x10807009 uImage.bin
U-Boot> go 0x10807009


Uboot On TI-Sitara processor

Image Credit : http://processors.wiki.ti.com/index.php/File:Sitara-linux-training-spl-start.png

Thanks for Reading.

One thought on “U-Boot Running inside U-Boot

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s