
The Flattened Image Tree (FIT) is at the heart of modern U-Boot booting, providing a flexible and verifiable way to package kernels, ramdisks, and devicetrees. A new series introduces a significant enhancement to how U-Boot processes FITs, enabling a powerful two-stage boot process. This allows a “load-only” FIT to configure the system (like setting up a devicetree) before a second FIT loads the operating system.
This capability unlocks more flexible and dynamic boot scenarios, especially for systems where the hardware configuration (devicetree) and the OS have different update cadences or sources.
The Concept: Load-Only and Restartable Booting
The core of this feature revolves around two new concepts:
- Load-Only Configurations: A FIT configuration can now be marked as “load-only.” When U-Boot’s
bootm
command processes such a configuration, it understands that there might not be a kernel to boot. Instead of failing, it will load any specified components—like a devicetree or other binaries—into memory and then gracefully exit with a special status code (-ENOPKG
). - Restartable
bootm
: Thebootm
command, which orchestrates the boot process, now has a newrestart
subcommand. Unlikestart
, which clears all previous state,restart
continues the boot process while preserving the components that have already been loaded.
When combined, these features allow for a sequence like this:
bootm start <fit1_addr>
: U-Boot loads a load-only FIT. It finds no OS but successfully loads a devicetree into memory.bootm restart <fit2_addr>
: U-Boot loads a second, standard FIT. It finds the OS kernel and ramdisk. Because this is arestart
, it retains the devicetree from the first step.bootm go
: The kernel is booted using the devicetree from the first FIT and the kernel/ramdisk from the second.
Key Changes in the Series
Bringing this feature to life required a fair amount of refactoring:
- Core
bootm
Logic: Thebootm
state machine was updated to recognize “load-only” configurations and to handle the newrestart
state, ensuring that previously loaded images (like the devicetree) are not discarded. - FIT Image Loading: The function
fit_image_load()
was enhanced to correctly handle the “load-only” property and return the new-ENOPKG
error code when an OS is not present in such a configuration. - Function Refactoring: Several key functions in the boot flow, like
boot_get_ramdisk()
andboot_get_fdt()
, were refactored for better clarity and more consistent error handling, making the code easier to maintain. - Comprehensive Testing: The FIT test suite in Python was significantly refactored and expanded. New tests were added to validate the “load-only” case and the two-stage boot process with a second FIT, ensuring the new functionality is robust.
- Documentation: The
bootm
command’s documentation has been fleshed out to describe the boot flow, the newrestart
subcommand, and all the other states, making this powerful command easier for developers to understand and use.
This series significantly enhances the flexibility of U-Boot’s FIT handling, paving the way for more sophisticated and modular boot architectures.