Firmware and bootloader are two important software components in many electronic devices, especially those using ARM processors. While they work together to start up and run a device, there are some key differences between firmware and bootloader.
What is Firmware?
Firmware is a type of software program that provides low-level control of a device’s hardware components. Unlike regular software that users interact with directly, firmware runs in the background and operates at a basic level to communicate between high-level software and the physical components. Firmware gives hardware the necessary instructions to function and serve its purpose.
Some key characteristics of firmware include:
- Stored in non-volatile memory like flash memory or ROM so it persists even when device is powered off
- Operates below OS level so continues working independently of high-level software
- Difficult to update, often requires physical access to device’s components
- Handles startup processes, hardware communication, and provides core device functionality
On ARM-based systems, the firmware goes through several stages at boot time to initialize hardware and prepare the system for operation. For example, on the Beaglebone Black single board computer with an ARM Sitara processor, the firmware boot sequence includes:
- BootROM code verifies and initializes RAM
- Stage 1 bootloader loaded from ROM into RAM
- Stage 1 bootloader initializes clocks and DDR RAM
- Stage 2 bootloader (U-Boot) loaded from flash storage to RAM
- U-Boot loads Linux kernel to RAM and passes control for system boot
So in summary, firmware is the base layer software in a device responsible for booting, hardware initialization, and core device functionality.
What is a Bootloader?
A bootloader is a specific type of firmware that handles the boot process and initial loading of the operating system. The main purpose of a bootloader is to load other software programs and get the system up and running.
Some key responsibilities of a bootloader include:
- Initializing system hardware like clock, memory controllers, I/O ports
- Detecting, verifying, and loading firmware or OS from boot medium
- Providing boot options like recovery or safe mode
- Supporting firmware updates
- Establishing secure boot environment
On an ARM system, the bootloader is typically the first code that executes on startup. It lives in ROM or flash chips and initializes memory, clocks, and peripherals to get the hardware ready before loading the firmware or OS. Some examples of ARM bootloaders include:
- U-Boot – Popular open source bootloader for embedded Linux devices
- Trusted Firmware-A (TF-A) – Reference bootloader from ARM for trusted boot use cases
- Das U-Boot – Bootloader from ARM optimized for Cortex-A processors
- BootROM – Bootloader code built into ARM SoC system logic
So in summary, a bootloader is the initial startup firmware that prepares the hardware and loads the main system firmware/OS.
Key Differences Between Firmware and Bootloader
While firmware and bootloader work closely together, there are some key differences:
- Purpose – The firmware provides core device functionality while the bootloader has the specific role of booting up the system.
- Execution – The bootloader runs first on startup, then initializes and loads the firmware.
- Storage – The bootloader typically lives in ROM while firmware uses flash memory.
- Update – Firmware can often be flashed remotely while bootloader usually requires physical access.
- Level – Bootloader works at a lower level than firmware and has fewer dependencies.
- Complexity – Firmware incorporates more complex logic and functionality beyond hardware init.
- Bootloader – Initializes hardware, limited functionality, loads OS/firmware
- Firmware – Broad device functionality, control over peripherals and components
The bootloader starts up first, kicking off the firmware boot sequence to get the system running. So the bootloader can be considered a subset of firmware with the specific role of booting.
Bootloader and Firmware Working Together
The bootloader and firmware work closely together to start up an ARM system:
- On power on, the bootloader code stored in ROM runs first.
- The bootloader initializes hardware like RAM, clocks, UARTs, flash memory.
- It looks for valid firmware in flash or external storage based on the boot sequence logic.
- The bootloader copies the firmware image to RAM.
- It passes control to the firmware for the rest of the boot process.
- The firmware continues initializing hardware and establishing the runtime environment.
- Finally, it completes the boot by launching the main OS or application software.
So in summary, the bootloader executes out of the box to set up hardware, find firmware, and kick off firmware initialization. The firmware then boots the main OS. This hand-off allows reusable bootloader code while custom firmware provides functionality for different devices.
Updating Firmware vs Bootloader
Given their different roles, there are implications to updating firmware vs the bootloader:
- Firmware – Can often update via USB or remote flash over-the-air. Fixes bugs, adds features, tuned for the application.
- Bootloader – Typically requires physical access to flash IC pins to update. Controls fundamental hardware operation so updates are infrequent.
If firmware becomes corrupted, the bootloader can re-flash it from a known good image. But if the bootloader is corrupted, the system may become inoperable without direct hardware access or a recovery mode.
For end-users, firmware updates are common to fix bugs or add capability. The bootloader only needs updated if it needs to work with new hardware or firmware features. Vendors take care when updating bootloaders to avoid bricking devices.
Example Boot Process on ARM Linux System
Here is an example boot process to illustrate how the bootloader and firmware interact on a typical ARM-based Linux system:
- On startup, the ARM SoC runs the built-in BootROM code
- BootROM initializes RAM and loads Stage 1 bootloader from ROM
- Stage 1 bootloader initializes system clocks, DDR memory
- It then loads U-Boot (Stage 2 bootloader) from flash to RAM
- U-Boot probes available storage, finds the Linux kernel image
- It loads the kernel and device tree to RAM and passes control
- The Linux kernel initializes hardware, starts kernel processes
- It mounts the root filesystem and launches init process
- init starts up all other userspace applications and services
- System is fully booted and operational
In this example:
- BootROM and Stage 1 bootloader are basic initialization code in ROM
- U-Boot is a more fully featured bootloader running from flash
- The Linux kernel and root filesystem make up the core firmware driving the system
The bootloaders initialize hardware, load firmware, and transfer control for startup. The firmware then boots Linux to launch all main software.
In summary, the bootloader is the first code that runs during system startup to initialize hardware and load firmware. The firmware then takes over for full system functionality and booting the OS. Both are essential ARM system software components with the bootloader focused on initialization and the firmware focused on runtime control and operation.
Key differences again are:
- Bootloader initializes and loads firmware
- Firmware controls peripherals and provides core device functions
- Bootloader is minimal, immutable code in ROM
- Firmware incorporates complex logic and stored in flash
- Bootloader starts first, then launches firmware
- Firmware boots full OS and applications
Understanding the interaction between the bootloader and firmware gives insight into the ARM Linux boot process and how to update the different system software components.