Module 6 · Lab 4
Software in DRAM
With DRAM working, the first stage loads the software that stays behind after Linux starts, and the bootloader that finds and starts Linux. You stop the boot at the bootloader's prompt and do its job by hand.
Where this stage sits
Key ideas
- 64-bit Arm CPUs run at four exception levels: EL0 for applications, EL1 for the OS kernel, EL2 for a hypervisor and EL3, the most privileged, for the secure monitor.
- The secure monitor (Trusted Firmware-A's BL31) stays in memory for the life of the system. Linux calls it to turn CPUs on and off, suspend and reboot. A trusted OS can also run beside Linux in the secure world.
- U-Boot is the bootloader proper: it has drivers for storage, network, USB and display, an environment of variables, scripting, and commands to load files into memory and start them.
- Linux needs three things in memory: the kernel, a device tree that describes the board, and often an initial RAM filesystem. A FIT image can bundle them with checksums.
- The kernel also takes a command line: where its root filesystem is, where the console is, and other options (read back in
/proc/cmdline). In a hand boot it comes from U-Boot'sbootargsvariable, which you set withsetenv bootargs …; without it the kernel cannot find its root filesystem. - The memory map says where the boot ROM, SRAM, DRAM and every peripheral's registers sit in the CPU's address space.
The memory map
On the bench
In short, what you do in lab 4, where the steps are given in full:
- Interrupt the boot at the U-Boot prompt; explore with
bdinfo,printenvandmd. - Find the kernel and device tree on the boot media, load each into memory at an address you choose, set
bootargswithsetenvfrom the running system's/proc/cmdline, and start the kernel withbooti. - Draw the memory map: where each image went, and where the stages before it ran.
- Annotate the secure monitor's and U-Boot's lines in the Lab 1 log.
Resources
| Resource | Use in this module |
|---|---|
| Upstream U-Boot for Libre Computer boards | U-Boot on the kit boards |
| libretech-builder-simple | Build U-Boot and its firmware for your board from source |
| U-Boot documentation | Commands, the environment and FIT images |
| Trusted Firmware-A documentation | Exception levels, BL31 and the boot stages |