Week 4 ยท Lecture outline
Memory bring-up and software in DRAM
Modules 5: Memory bring-up and 6: Software in DRAM. Lab: Lab 4, memory and the bootloader. Due: Lab 3. Quiz 1 is this week.
Learning goals
By the end of the week a student can:
- Explain why DRAM cannot be used at reset: refresh, timings, training and size detection.
- Name the four Arm exception levels and what runs at each.
- Say what the secure monitor and U-Boot each do, and what Linux needs in memory to start.
- Boot a kernel by hand from the U-Boot prompt, and draw the memory map.
Lecture 1, block 1: what DRAM needs
- Each bit is charge in a tiny capacitor that leaks; the controller refreshes every row many times a second.
- The controller needs the memory's timings, bus width, size and clock.
- Das Frite has one DDR4 chip on a 16-bit bus; Solitude has LPDDR4 on a 32-bit bus. Each needs its own settings and training.
Lecture 1, block 2: training and size detection
- At these speeds the data lines do not arrive in step.
- Training sweeps the delay on each lane, finds the window in which data reads correctly, and sets the delay to its centre.
- Size detection writes and reads at chosen addresses to find how much memory is really there.
Lecture 1, block 3: when it fails
- A failed bring-up usually stops the boot right there.
- A marginal one is worse: the board boots and corrupts data later.
- That is why boards are memory-tested, and why a memory test proves less than it seems.
- In the lab, students change the memory clock in the open first stage and see the effect.
Lecture 2, block 1: exception levels and the secure monitor
- EL0 for applications, EL1 for the OS kernel, EL2 for a hypervisor, EL3, the most privileged, for 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 run beside Linux in the secure world.
Lecture 2, block 2: U-Boot
- The bootloader proper: drivers for storage, network, USB and display; an environment of variables; scripting; commands to load files and start them.
- Linux needs the kernel, a device tree describing the board, and often an initial RAM filesystem.
- A FIT image can bundle them with checksums.
- The lab's commands:
bdinfo,printenv,md,load,setenv bootargs(the kernel command line, saved from/proc/cmdline) andbooti.
Lecture 2, block 3: the memory map
- One address space holds the boot ROM, SRAM, DRAM and every peripheral's registers.
- Show the course's memory map diagram.
- Students mark where each image went and where the stages before it ran.
Board demo
- Point out the memory lines in a boot log: the size and clock the first stage reports.
- Interrupt the boot at the U-Boot prompt; run
bdinfo,printenvandmdon an address in DRAM. - Load the kernel and the device tree from the boot media at addresses you choose, set
bootargsfrom the running system's/proc/cmdline, and start the kernel withbooti.
Check questions
Why is a marginal memory bring-up worse than a failed one?
A failed bring-up stops the boot at once, where it is easy to see. A marginal one lets the board boot and then corrupts data later, far from the cause.
At which exception level does the secure monitor run, and what does Linux use it for?
EL3, the most privileged. Linux calls it to turn CPUs on and off, to suspend and to reboot.