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
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's early stages are the TPL and the SPL (secondary program loader), and Arm's Trusted Firmware calls this one BL2. In Libre Computer's open chain the stage in SRAM is U-Boot's TPL, which brings up DRAM and loads an SPL that runs from DRAM. Both course boards ship this open chain in their SPI flash: the first-stage lines of your lab 1 log come from a published build of it, not from the one you build and start over USB in lab 3.
- The course studies 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 for both boards, with one exception: on Solitude, memory training still runs Amlogic's DDR code and the memory PHY's training firmware, which are binaries. 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:
- Annotate the first-stage lines of the Lab 1 log: where the boot ROM stops printing and the first stage starts.
- Start your board in USB boot mode and let the Libre Computer app on the bench PC send the open first stage; watch it start on the serial console.
- 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.
- Write one paragraph on what the first stage had to do before anything bigger could load.
Resources
| Resource | Use in this module |
|---|---|
| libretech-builder-simple | Builds Libre Computer's open boot chain for your board, from the first stage up |
| boot.libre.computer | The published open-chain builds the app sends to a board in USB boot mode |
| U-Boot documentation | The SPL and how U-Boot boots |
| The Libre Computer app | USB boot from the bench PC; its lc boot command sends your own build |