Skip to content
Libre Computer
Platform

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

The boot chain: each stage loads the nextBoot ROMfixed in the chipmodule 3First stageclocks, consolemodule 4Memory bring-uptimings, trainingmodule 5Secure monitorTF-A, stays residentmodule 6U-Bootstorage, USB, networkmodule 6UEFIstandard interfacemodule 7Linux kerneldrivers, rootmodule 8initsystemd, servicesmodule 8runs from On-chip ROMruns from On-chip SRAMruns from DRAMPower and reset come first (module 2); I/O, drivers and your project run on the finished system (modules 9 to 12).
Where this module sits in the boot chain.

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's bootargs variable, which you set with setenv 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

The memory map: one address space, many kinds of memoryRegions are drawn by kind, not to scale; module 6 has you find where each image went on your board.Peripheral registersUSB, Ethernet, UART, I2C, SPI, GPIO…Boot ROMfixed in the chipOn-chip SRAMsmall; the first stage runs hereDRAMSecure monitor (TF-A)U-BootKernel imageDevice treeInitial RAM filesystemFree memory for Linuxhigh addresses vary by chipU-Boot loads the kernel,device tree and initramfsto addresses you choose
One address space holds every kind of memory and every peripheral's registers. In this module you find where each image went on your board.

On the bench

In short, what you do in lab 4, where the steps are given in full:

  1. Interrupt the boot at the U-Boot prompt; explore with bdinfo, printenv and md.
  2. Find the kernel and device tree on the boot media, load each into memory at an address you choose, set bootargs with setenv from the running system's /proc/cmdline, and start the kernel with booti.
  3. Draw the memory map: where each image went, and where the stages before it ran.
  4. Annotate the secure monitor's and U-Boot's lines in the Lab 1 log.

Resources

ResourceUse in this module
Upstream U-Boot for Libre Computer boardsU-Boot on the kit boards
libretech-builder-simpleBuild U-Boot and its firmware for your board from source
U-Boot documentationCommands, the environment and FIT images
Trusted Firmware-A documentationException levels, BL31 and the boot stages