Systems & software · topic D11 · 25 hours
Boot chain & bootloader
Between power-on and your business code there lies an entire boot chain. Debugging «the board won't start», doing firmware OTA, and getting kernel parameters right all run through this chain. In embedded interviews, the bootloader is a high-frequency question.
What to learn
- Two boot chains: the MCU line (ROM → flash vector table → SystemInit → main, STM32 as the example) and the SoC line (BootROM → SPL/U-Boot → device tree → kernel → init, Jetson/Raspberry Pi as the example)
- U-Boot hands-on: environment variables, bootcmd/bootargs, loading the kernel from eMMC/SD/network (TFTP)
- Device Tree: DTS decouples hardware description from drivers, so changing a peripheral no longer means changing the kernel
- Firmware updates: dual-partition A/B, IAP/DFU, rollback on failed upgrades and power-loss protection
The lesson · plain words
From pressing the power button to your program running, a complete boot chain lies in between: ROM → SPL → U-Boot → kernel → root filesystem → application. Every link can surprise you in the field.
The value of understanding the chain: you can localize «which stage it is stuck at», you can optimize boot time, and you can explain why it occasionally fails to boot.
Six relay legs, each with its own job
ROM (burned into the chip): initializes the most basic memory and finds the SPL on the boot medium. SPL (second-level loader): initializes DRAM and loads U-Boot. U-Boot: the universal bootloader — loading the kernel, passing arguments, flashing firmware, and unbricking all depend on it.
Kernel: drivers, mounting the root filesystem, starting the first process init. Root filesystem and applications: systemd brings services up in dependency order, and finally your ROS/control program is ready. Watch the figure: the length of each segment is the bulk of boot time.
Interactive figure · drag it and see
Boot optimization: measure first, then cut
The right side of the figure shows the optimized comparison: a trimmed U-Boot (extra probing removed), a lean kernel (drivers you never use removed), services started on demand (systemd analyze finds the serial bottlenecks). Going from 4-second class to 1-second class is a routinely reachable target.
The measurement toolchain: U-Boot's built-in bootstage; kernel printk timestamps (initcall_debug); systemd analyze blame. Measure each segment separately — do not guess.
Field triage for boot failures
A symptom taxonomy: no serial output at all = the ROM/SPL stage (power supply, boot-medium dip switches, DRAM init); U-Boot prints but the kernel never starts = kernel image/device tree problem; kernel panic = driver or root filesystem; services fail to start = dependencies and configuration. One serial cable (USB-TTL) is the entire entry ticket for boot debugging.
Practical gear: keep a known-bootable backup image, and leave a fallback entry in U-Boot to boot from network/SD card. Unbricking in the field relies on preplanned measures, not improvisation.
How deep to go
Read the main U-Boot commands (tftpboot/bootm/booti), flip one peripheral's enable in the device tree, and write a systemd service unit with dependencies. These three cover 90% of BSP daily work.
Interview favorites: what a bootloader does (init + load + pass arguments), what a device tree is (a data structure describing hardware to the kernel), why boot is slow (time each stage to localize).
Three questions — do you really get it?
1. No serial output at all after power-on — what do you check first?
- AKernel panic
- BThe ROM/SPL stage: power supply, boot medium, dip switches
- Csystemd services
Show answer
B. Not even the bootloader ran, so the problem sits at the very bottom. A serial cable + multimeter is where you start.
2. What is the device tree for?
- AManaging process scheduling
- BCompressing the filesystem
- CDescribing hardware information to the kernel so one kernel fits many boards
Show answer
C. Hardware description is separated from kernel code; peripheral config changes go into the dts, not the kernel source.
3. The first step of boot optimization is?
- AMeasuring stage by stage: bootstage / printk timestamps / systemd analyze
- BTrimming the kernel right away
- CA faster SD card
Show answer
A. Measure first, cut second. Each stage's time distribution decides the main battlefield; guessing never finds it.
Keep going deeper
Links without a marker stay on this site; the rest point to the Chinese edition until its translation batch lands.
How it fails in the field
- Editing the device tree source but never recompiling and flashing the dtb, or flashing the wrong partition — then misdiagnosing it as «my code did not take effect»
- OTA on a single partition: power lost mid-upgrade bricks the whole machine, with no A/B rollback
You have learned enough when
The Chinese edition carries the full topic page for Boot chain & bootloader, including the complete outline, depth requirements per career track, and further derivations: robotguide.dev/k/D11/.