Components of Embedded Linux – Why is a bootloader needed, and what is a bootloader?

Components of Embedded Linux – Why is a bootloader needed, and what is a bootloader?

First of all, it is also software like the operating system, or the applications we are still running every day.

We already know that our application runs on the operating system, not on the bootloader.
So what the hell is a bootloader??? Is it necessary to need it???

If speaking of general operating systems, in addition to Linux, including very small operating systems, like some RTOS for example, there may not be a need for the bootloader we are talking about here.
Since the CPU is usually capable of loading a certain piece of code, if the operating system is small enough for the CPU to load it into memory, there is no need for a bootloader.

So in the end, what does the bootloader do???
The main reason is from computer fundamentals (can’t remember the name very well).
The idea is: the program must be loaded into memory before it can run.

CPUs often also have a small piece of code available to run, after being plugged in, the code is used to load a fixed segment somewhere (usually the boot sector on main storage) into memory to run.
*We should clearly distinguish between memory as RAM, while memory devices refer to HDD, SSD, USB Memory… the type that is not erased when the power is out to avoid confusion)

Because in order to run the application, the kernel must be loaded into the first memory, we assume the Linux kernel is about 9MB in size. The CPU cannot load that much, even if it is loaded, it is very inconvenient, because the CPU only works with an address, of a certain type of memory device only. When you change, your mouth is always broken.

To solve this problem, people divide from the time the power is plugged in to the time the operating system kernel is loaded into memory into several successive stages:
Kind of like this

CPU –> LD 1 –> LD 2 –> LD 3 …—> Operating system

CPU performs load LD 1, LD 1 put into memory to run, it will load LD 2, and so on, load the operating system and run the operating system.

Once we get to the operating system, we will be able to run everything.

Here we should remember to finish loading the next LD, it passes control (or jumps to the address that is loaded in memory) to run the loaded Loader. That also means, the previous LD will finish the mission, no longer needed.

The process of executing LD 1 -> LD 2….–> LD N

Collectively called the Booting process, or the whole bunch of LDn is called Bootloader.

How many loads and then replace will depend on the Platform as well as the Bootloader you use.

If LD 1 is already able to load the operating system, then LD 2 and 3 are no longer needed.

The principle seems to be the same, but usually the Bootloader gets 2, or 3 times to the operating system already.

The main tasks of the bootloader:
– Hardware initialization
– Set up RAM memory
– Processor settings
– Load the operating system by reading the memory device, from the network, from the serial…

On Embedded Linux, the commonly used bootloader is Das U-Boot, Barebox.

The most popular is Das U-Boot, which is full of powerful features.
– Can access popular file systems such as: FAT, ext2, ext3, ext4.
– Support even loading kernel over the network.
– Support the mechanism of passing parameters to the kernel by device tree when booting the kernel.

  • Share

admin

Leave a Reply

Your email address will not be published.