Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do we need a bootloader in an embedded device?

Tags:

I'm working with ELinux kernel on ARM cortex-A8.

I know how the bootloader works and what job it's doing. But i've got a question - why do we need bootloader, why was the bootloader born?

Why we can't directly load the kernel into RAM from flash memory without bootloader? If we load it what will happen? In fact, processor will not support it, but why are we following the procedure?

like image 307
chainz Avatar asked Mar 21 '13 12:03

chainz


People also ask

Why bootloader is required?

A boot loader is a critical piece of software running on any system. Whenever a computing system is initially powered on, the first piece of code to be loaded and run is the boot loader. It provides an interface for the user to load an operating system and applications.

Why bootloader is needed in microcontroller?

A Bootloader is a program that allows you to load other programs via a more convenient interface like a standard USB cable. When you power-up or reset your microcontroller board, the bootloader checks to see if there is an upload request. If there is, it will upload the new program and burn it into Flash memory.

What is booting in embedded systems?

Boot-up, the sequence of steps that a system performs between when you switch on power and load applications, is simple in theory but often complex in reality. The main job of a boot loader is to load the operating system, but software and hardware engineers view this process in different ways.

What is bootloader in embedded Linux?

In embedded systems the bootloader is a special piece of software whose main purpose is to load the kernel and hand over the control to it. To achieve this, it needs to initialize the required peripherals which helps the device to carry out its intended functionality.


2 Answers

In the context of Linux, the boot loader is responsible for some predefined tasks. As this question is arm tagged, I think that ARM booting might be a useful resource. Specifically, the boot loader was/is responsible for setting up an ATAG list that describing the amount of RAM, a kernel command line, and other parameters. One of the most important parameters is the machine type. With device trees, an entire description of the board is passed. This makes a stock ARM Linux impossible to boot with out some code to setup the parameters as described.

The parameters allows one generic Linux to support multiple devices. For instance, an ARM Debian kernel can support hundreds of different board types. Uboot or other boot loader can dynamically determine this information or it can be hard coded for the board.

You might also like to look at bootloader info page here at stack overflow.

A basic system might be able to setup ATAGS and copy NOR flash to SRAM. However, it is usually a little more complex than this. Linux needs RAM setup, so you may have to initialize an SDRAM controller. If you use NAND flash, you have to handle bad blocks and the copy may be a little more complex than memcpy().

Linux often has some latent driver bugs where a driver will assume that a clock is initialized. For instance if Uboot always initializes an Ethernet clock for a particular machine, the Linux Ethernet driver may have neglected to setup this clock. This can be especially true with clock trees.

Some systems require boot image formats that are not supported by Linux; for example a special header which can initialize hardware immediately; like configuring the devices to read initial code from. Additionally, often there is hardware that should be configured immediately; a boot loader can do this quickly whereas the normal structure of Linux may delay this significantly resulting in I/O conflicts, etc.

From a pragmatic perspective, it is simpler to use a boot loader. However, there is nothing to prevent you from altering Linux's source to boot directly from it; although it maybe like pasting the boot loader code directly to the start of Linux.

See Also: Coreboot, Uboot, and Wikipedia's comparison. Barebox is a lesser known, but well structured and modern boot loader for the ARM. RedBoot is also used in some ARM systems; RedBoot partitions are supported in the kernel tree.

like image 174
artless noise Avatar answered Nov 21 '22 06:11

artless noise


A boot loader is a computer program that loads the main operating system or runtime environment for the computer after completion of the self-tests.

^ From Wikipedia Article

So basically bootloader is doing just what you wanted - copying data from flash into operating memory. It's really that simple.

If you want to know more about boostrapping the OS, I highly recommend you read the linked article. Boot phase consists, apart from tests, also of checking peripherals and some other things. Skipping them makes sense only on very simple embedded devices, and that's why their bootloaders are even simpler:

Some embedded systems do not require a noticeable boot sequence to begin functioning and when turned on may simply run operational programs that are stored in ROM.

The same source

like image 36
Bartek Banachewicz Avatar answered Nov 21 '22 04:11

Bartek Banachewicz