What is a bootloader? It’s a small program responsible for placing the operating system into the memory. In general-purpose computers, it is usually pre-installed for either Windows or Mac OS. However, the case is different with Linux, the OS on which many embedded systems are made – you need to install it separately. In this article, we explore the topic of bootloaders further, explaining what they are and how they work. Are you interested? Then we invite you to read on.

What Is a Bootloader?

Bootloader, also known as boot loader, bootstrap loader, or boot manager, is simply a program responsible for loading the OS data into the working memory during device start-up. It is launched by the BIOS, which first finds the bootable device – any type of hardware that contains the bootloader – and then starts this program, initiating the process of loading the OS into the RAM. The whole process is called booting.

A bootloader is usually stored in the first sector of the bootable device. This makes the process much quicker and more efficient for the BIOS as it only has to read the Master Boot Record (aka the first sector). The exceptions to this include the bootloader being stored in a particular partition of the bootable medium that the BIOS is able to find and access.

We also should mention that a device may have more than one bootloader. An example of that can be observed in systems where primary and secondary boot managers exist. In such cases, the former is usually exceptionally small and run by the BIOS while having only one task – to launch the secondary, larger, bootloader.

How Does a Bootloader Work?

Knowing what a bootloader is, we may proceed with explaining how it works. To do so, we will analyze the whole booting process from the beginning to the end.

  1. Turning the device on – The process starts when you turn on the device, which also starts up the firmware.
  2. Launching BIOS – The BIOS (and for general-purpose computers: some information about the hardware) is launched from ROM and looks for the bootable device.
  3. Finding master boot record – The BIOS looks for the master boot record to localize the bootloader.
  4. Loading the bootloader – The bootloader takes control and loads the operating system to the main memory of the system.
  5. Operating system in charge – The OS takes control of the entire system.

Bootloader in an Embedded System

Knowing what an embedded system is, you might be expecting the bootloader in it to work slightly differently from general-purpose computers. And this is largely true. It all goes down to the fact that embedded systems don’t have a BIOS that could initiate the booting process. But, the differences might also be spotted in the role that a bootloader plays in these types of devices.

So, how does a bootloader work in an embedded system? Let’s take a look at it more closely:

  1. Initialization – For starters, the bootloader in embedded systems fills the role of the BIOS, meaning that it’s the first code that is run when such a device is turned on.
  2. Loading Firmware – The bootloader loads the main application firmware into the memory. It is then written into RAM or flash memory.
  3. Giving up control – Finally, like general-purpose bootloaders, it hands the control over the system to the OS.

The three steps are merely a portion of the bootloader functions in embedded systems – the features that are visible during system launch. However, this process is much more complex due to the additional capabilities of bootloaders:

  • Communication interfaces – Between these, it was quite difficult to update the firmware in embedded systems. However, nowadays, most bootloaders include a type of communication interface, like UART, USB, Ethernet, or even Bluetooth or Wi-Fi, that enables quick and seamless software updates, hotfixes, or debugging.
  • Security – Bootloaders also incorporate security measures to prevent unauthorized firmware from being loaded onto a given device. These can range from digital signatures to complex encryptions.
  • Error handling – Boot managers usually contain an error-checking mechanism. When an error is spotted, the firmware might be rejected, or the bootloader may initiate a recovery procedure. This way, the integrity of the system is ensured.

Popular Embedded System Bootloaders

While it is possible to write your own customized bootloader, in most cases, you may use some of the already available solutions. But, with different architectures, none of these will ever fit all devices, so your choice should most likely depend on the desired functionalities and the hardware implemented in your embedded system.

  • U-Boot – Also known as the Universal Bootloader, it’s used mostly for PowerPC and ARM architectures in embedded systems.
  • Barebox – Started as U-Boot v2 (this was literally its name), this bootloader was aimed at eliminating the limitations of U-Boot. Now the community behind it and its aims have changed, and so has its name. Barebox runs on a variety of architectures, including but not limited to x86, ARM, MIPS, and RISC-V.
  • Alios – This interesting bootloader is written in assembler with the attempt to remove any need for firmware in embedded systems.
  • RedBoot – Tested in action, this bootloader is known for powering the entertainment systems in aircraft like Airbus A380s and Boeing 767. It also has pre-built support for network booting and enables booting automation, so this is quite a viable option for embedded systems.

The Takeaway

Let’s sum up what a bootloader is and how it works. This is a short code or small program used to load the OS or firmware into the memory. It can also serve additional roles such as error handling or ensuring security. In general-purpose computers, it’s operated by a BIOS; in embedded systems, the bootloader takes control when the device is turned on. Bootloaders differ based on the operating system they need to boot, as well as on the type of processor architecture.

Did you like this article? You might also read: What Is RISC and CISC Architecture & Their Differences