Boot Loader Tutorial
The Boot Loader is a computer program that loads the main operating system or the main application program into the flash memory of the processor after the validation or the self-test of the software. The boot loader is the first program to run after power-up or reset. Its primary goal is to ready the system for control by the operating system. This requires hardware initialization and choosing the correct image to load from flash.
In a PC a boot loader, also called a boot manager, is a small program that places the operating system (OS) of a computer into memory. When a computer is powered-up or restarted, the basic input/output system (BIOS) performs some initial tests and then transfers control to the master boot record (MBR) where the boot loader resides. Most new computers are shipped with boot loaders for some version of Microsoft Windows or the Mac OS. If a computer is to be used with Linux, a special boot loader must be installed.
How Boot Loader Works in Linux OS
In the case of the Linux Operating System, the two most common boot loaders are known as LILO (Linux Loader) and LOADLIN (LOAD Linux). An alternative boot loader, called GRUB (GRand Unified Boot loader), is used with Red Hat Linux. LILO is the most popular boot loader among computer users that employ Linux as the main, or only, operating system.
The primary advantage of LILO is the fact that it allows for fast boot-up. LOADLIN is preferred by some users whose computers have multiple operating systems, and who spend relatively little time in Linux. LOADLIN is sometimes used as a backup boot loader for Linux in case LILO fails. GRUB is preferred by many users of Red Hat Linux because it is the default boot loader for that distribution.
I think let’s go discuss this for your doubt clear. Actually what it is and what is the function of this program and. Whenever a baby is getting birth and after coming into this world he/she don’t know this world. Baby doesn’t know why he/she is here and only crying. The baby doesn’t know how to eat, what to eat when to eat etc. So gradually the parents are trying to teach him all these think like as this is your head, this is your hand, this is your ear, etc. So after some months he/she started telling those things as parents teach. whenever he/she getting to know all the things then they will teach the functionality means what can do with the hand like he/she can eat, and using leg he/she can walk, etc.
Among the multiple conceptions that exist regarding the definition of a boot loader, one common approach is that it is considered to be a fixed piece of software or firmware residing at least partially in the non-volatile memory area of a microprocessor, such as ROM or Flash. The “firm” condition of the boot loader is based on the idea that once designed and developed it’s not supposed to be an object of any changes or maintenance during the processor lifetime as an application program would eventually undergo.
If you have a computer and your Operating System is getting crashed or it is not opening due to some problem. Then what you can do if you don’t have any boot loader software in your system. It might reset continuously, or stay in this application mode for which you will not be able to flash new software onto the flash memory due to this. So if you have a program available always for this means if any malfunction will occur in the application it will jump to the boot mode and there you can flash a new application software.
The different views that exist towards the features and operation that a boot loader should perform are often motivated, for instance, by the following factors:
- The resources eventually needed by a running application (time, memory, interrupts).
- The resources supported by each specific MCU (types of memories, access to special function registers, interrupt stack).
- The amount of memory available for storing initialization code.
Despite these variations, it’s a common practice to implement the boot loader in such a fashion that it starts running right after power-up, whether coming from a system software reset, external induced reset (incoming signal or command via communication interface or event-sensed configured), manual reset or by just applying power supply to the processor to turn it on.
Usually, embedded processors fetch and execute code from the reset vector at a defined address in ROM or Flash, to further jump to another section of memory where the initialization code resides. This is done to keep the reset vector small. Whether it is due the requirements imposed by an application or the capabilities of a specific processor, at its core some of the most basic and generally agreed functionalities of a boot loader are:
- Minimal hardware initialization. Especially since it’s the first code the CPU executes upon power-up. It might include:
- Enabling access to / initializing internal RAM.
- Default initialization of MCU system clock for provision of time base and pre-scalers.
- Setting up Phase Lock Loops (PLL’s).
- Initialization of base addresses for Interrupt and Exception Trap Vector.
- Initialization of user stack pointer.
- Initialization of cache and/or external memory if such memory types are supported by the MCU.
2. Identification of type of reset events (software, manual, hardware, power-up, via the communication interface, etc.).
3. Copy image from Flash or ROM to RAM for faster execution.
4. Jump to the application (alternatively to OS) and pass program control to it.
In the book Real-Time Concepts for Embedded Systems [1] for example, a typical flow is shown for a bootloader that is very similar to the one previously described. Such a flow can be appreciated in the below figure:

Because of its key role, the bootloader usually occupies special boot blocks in the flash ROM, which have hardware protection against accidental erasure and corruption. When it comes to the features considered as convenient to have in a bootloader, the following are amongst the most important:
- Checksum verification of application code.
- Remote boot capability.
- Reception of new application code (via a communication interface).
- Executing flash reprogramming routines from RAM.
- Reception of a new flash image.
Actually now I want to clear your all doubts about this. Nowadays there is an electronic device you are using it is an Embedded Device nothing but the combination of both hardware and software. If you want to design any system then you need one processor and for this processor, you need to write the program as per your requirement. But you think to suppose you have written the program then how you are going to flash this program onto the Microcontroller flash memory. So to help in application software loading onto your hardware you need some boot loader. This is again divided into two types as explained below.
Types of Bootloader
Primary Boot Loader (PBL):
This boot-loader is inside the non-volatile memory(ROM) and its main purpose is to initialize the architecture and the microprocessor/microcontroller peripherals. Also in the case of a secure boot-loader, it verifies the authenticity of the chip using an encryption algorithm like RSA or Key ladder.
Secondary Boot Loader (SBL / FBL):
The secondary boot loader resides in flash and it is the job of primary boot loader to load the secondary boot loader in RAM. The main job of the secondary boot loader is to set up the C stack and initialize everything needed to boot the Operating system, load the Operating system, and give the control to the Operating system.
Boot Loader Sequence flow for any Embedded System Device:
- Connect the device with the power supply.
- Turn on the power button.
- All the CPU pins are get reset and the registers are set into a specific hardware manufacturer defined default value.
- The CPU stack pointer jumps to the address of BIOS (0xF0000), nothing but the reset vector.
- After reset it will jump to primary boot-loader.
- The primary boot-loader will give access to jump to Secondary Boot-loader.
- The secondary boot-loader will copy the Application software onto RAM memory and it will start running.
Advantages of Bootloader
Bootloaders play a crucial role in the boot process of computers, smartphones, and embedded systems. Here are some advantages of bootloaders:
- Consistent boot process: Bootloaders provide a consistent and standardized method to start the operating system, ensuring that the boot process is reliable and predictable across various devices and platforms.
- Hardware initialization: Bootloaders perform essential hardware initialization tasks, such as setting up the memory, configuring the processor, and initializing peripherals, preparing the device for the operating system to run smoothly.
- OS selection and loading: In systems with multiple operating systems, the bootloader can present a menu to choose the desired OS or load a default one. This feature allows users to have more than one OS on their device or test different OS configurations without affecting their primary setup.
- Firmware updates and recovery: Bootloaders can facilitate firmware updates and provide recovery options in case the primary operating system becomes corrupted or fails to load. This feature is particularly useful in embedded systems, where the bootloader can initiate a firmware update or restore the system to a functional state.
- Security: Some bootloaders implement secure boot mechanisms, which verify the integrity and authenticity of the operating system before loading it. This process helps prevent unauthorized modifications to the system or loading of malicious software, enhancing overall system security.
- Customization and development: Bootloaders enable developers to modify and test new operating systems or firmware versions on devices without permanently altering the device’s primary software. This feature is particularly useful for developers working on custom ROMs for smartphones or other specialized applications.
- Resource efficiency: Bootloaders are typically designed to be small and efficient, using minimal resources during the boot process. This efficiency helps ensure that the boot process is fast and that the bootloader does not consume unnecessary memory or processing power.
- Platform independence: Bootloaders can be designed to work with various processor architectures and operating systems, allowing for platform independence and compatibility with a wide range of devices.