Skip to content
Libre Computer
Platform

Module 4 ยท Lab 3

Loading the bootloader into SRAM

When the boot ROM hands over, the only working memory is a small SRAM inside the system-on-chip. The first stage has to fit there, and it has one job above all: make the far larger DRAM usable.

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

  • On-chip SRAM works from power-on with no setup, but it is small: tens to hundreds of kilobytes. DRAM is thousands of times larger but does nothing until it is configured.
  • So the boot is split. A small first stage runs from SRAM, sets up clocks and the serial console, brings up DRAM (module 5) and loads the larger stages into it.
  • This course calls it the first stage, or the SRAM stage after where it runs. Projects name it differently: U-Boot calls it the SPL (secondary program loader), and Arm's Trusted Firmware calls it BL2.
  • Both course boards boot Libre Computer's open boot chain: the first stage, the memory bring-up and everything after it are open code that libretech-builder-simple builds from source. You can read the stage that runs in SRAM, change it, rebuild it and boot your own build.

On the bench

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

  1. Annotate the first-stage lines of the Lab 1 log: where the boot ROM stops printing and the first stage starts.
  2. Start your board in USB boot mode and let the app, or the Amlogic USB boot tool on the bench PC, send the open first stage; watch it start on the serial console.
  3. On the bench PC, build the first stage for your board with libretech-builder-simple, add one line to its console output, and start the board over USB with your build.
  4. Write one paragraph on what the first stage had to do before anything bigger could load.

Resources

ResourceUse in this module
libretech-builder-simpleBuilds Libre Computer's open boot chain for your board, from the first stage up
boot.libre.computerThe published open-chain builds the app sends to a board in USB boot mode
U-Boot documentationThe SPL and how U-Boot boots
eMMC flashing steps from Linux with pyamlbootUSB boot from the bench PC with the Amlogic USB boot tool