| Updated: October 28, 2024 |
The media on which the bootable OS image is stored, and how it is stored (compressed or not) determine what the IPL must do with the image.
The type of removable media used to store the IPL and the IFS affects many aspects of the IPL design. One significant factor is whether the storage media is linearly mapped (e.g., NOR FLASH) or non-linearly mapped (e.g., eMMC, SD card), because it determines if the IPL can use eXecute In Place (XIP).
Other important factors include whether the image is compressed, and the device on which it is stored (see Image storage methods).
With linearly mapped devices (e.g., ROM devices), the entire image is in directly addressable storage that maps its entire address space into the processor's address space. The processor can address any location in the OS image, so the IPL needs to copy only the startup code (not the entire image) into RAM, leaving the rest of the image on the device.
Figure 1. IPL loading of startup code from device into RAM, with rest of image left on
device.If the removable media is linearly mapped, the IPL can use XIP. In this case, the .text section of the IPL (the code) in the linker file (e.g., mx6sx-sabre-sdb.lnk or vayu-evm.lnk) must be in the linearly mapped address space.
All of the IPL assembly code can run before the image is copied into RAM.
With non-linearly mapped devices (e.g., eMMCs, SD cards, or SPI NOR devices), the image is in storage that can't be mapped directly into the processor's address space. The processor can't address the OS image, so the IPL needs to copy the entire image (including the startup code) into RAM.
Figure 2. IPL loading of entire image from device into RAM.If a bootable image is too large to store on the removable media in its original form, or if hardware limitations (e.g., slow bus) make copying and extracting the image more efficient than copying the image in its original format, the bootable image may be compressed on either a linearly mapped or a non-linearly mapped removable storage device.
When it builds the OS image, the mkifs utility checks for the compress attribute in the buildfile. If the attribute is set (e.g., [virtual = x86_64, bios +compress boot = { ), mkifs compresses the image (see the OS Image Buildfiles chapter).
If the image is compressed, it must be copied to RAM and extracted before the main() function in the IPL's second stage calls the image_scan() function. When you write an IPL or update a system that uses a compressed image, ensure that you:
For examples of how different storage options are used, see Image storage methods in this chapter.
The IPL can load the OS image from different types of devices or over a network, depending on what the board supports. The locations where OS images are often stored include:
As well as supporting a primary method for loading the OS image, the IPL code may also need to support an alternative loading method (e.g., an .altboot in the case of a disk boot on x86 boards). This secondary method may have to be an automatic fallback when the primary image is corrupt. You can use a .boot directory with a list of fallback IFSs that can be loaded from read-only media.
To validate a bootable image, use the checksum() function to perform a checksum over the entire image. A call to validate an image looks like this:
checksum (image_paddr, startup_size); checksum (image_paddr + startup_size, stored_size - startup_size);