Reference Notes
2026-11-04
Motivation & Architecture
Stage-by-Stage Boot Pipeline
Discussion — high-yield questions for students
At reset, a CPU has almost nothing to work with:
The “chicken-and-egg” problem:
To run a program large enough to initialize DRAM, we need memory large enough to hold that program — which does not exist yet.
The universal solution: a chain of progressively larger and more capable loaders, each one setting up enough of the platform for the next.
| Stage | Executes from | Privilege |
|---|---|---|
| Power-On Reset | — | — |
| BootROM (BL1) | on-chip mask ROM | M-mode |
| FSBL / BL2 | internal SRAM | M-mode |
| OpenSBI | DDR | M-mode (resident) |
| U-Boot | DDR | S-mode |
| Linux kernel | DDR | S-mode |
| User space | DDR | U-mode |
Each step crosses a real architectural boundary: a new execution medium, a new privilege level, or both.
| Medium | Size / Nature | Role in boot |
|---|---|---|
| On-chip Mask ROM | Tiny, immutable | BootROM (zero-stage) |
| Internal SRAM (dedicated scratchpad) | 24 + 64 + 100 KiB, volatile | FSBL / BL2 execution |
| SiP DDR3 | 512 MB, external | OpenSBI, U-Boot, kernel, user |
The progression mirrors the boot chain itself: ROM → SRAM → DRAM.
| Mode | Name | Typical occupant |
|---|---|---|
| M-mode | Machine | BootROM, FSBL, OpenSBI (resident) |
| S-mode | Supervisor | U-Boot, Linux kernel |
| U-mode | User | Applications, BusyBox, systemd |
Rules of the ladder:
mret, sret).ecall for a system call).The SG2000 is deliberately not a single-core story:
Why teach with this chip?
The zero-stage bootloader.
What it does:
fip.bin).First-Stage Bootloader — bring up main memory.
VC_SRAM @ 0x3BC0_0000, 100 KiB)What it does:
C.SCS... banner).conf_info/eFuse and runs the compiled-in PHY/controller init and training → full 512 MB available.fip.bin):
0x80000000Supervisor Binary Interface — the permanent M-mode runtime.
What it does:
mideleg / medeleg to hand timer, software, external interrupts, and page faults down to S-mode.a0 = hart ID, a1 = DTB pointer, sets mstatus.MPP = S-mode, and executes mret into U-Boot.Second-stage bootloader — flexible, device-aware loading.
What it does:
bootcmd).Image / uImage)cv181x_milkv_duos.dtb)bootargs, passes the DTB address, jumps to the kernel entry.OS kernel initialization.
What it does:
satp for Sv39/Sv48)./sbin/init or /bin/sh).U-mode — where our programs finally run.
sret to run unprivileged processes (BusyBox, systemd, …).ecall (a system call).We have now walked the full ladder: M-mode → S-mode → U-mode, across ROM → SRAM → DRAM.
BootROM is tiny and immutable.
Hence the staged chain: each loader is only as large as the environment it runs in allows.
FSBL’s job is purely initialization — bootstrap and disappear.
OpenSBI provides ongoing M-mode services that S-mode cannot perform directly due to architectural privilege restrictions:
ecallUnlike x86 (ACPI + runtime bus enumeration such as PCIe), embedded RISC-V and ARM SoCs have non-discoverable memory-mapped peripherals.
The DTB passes the physical topology — register addresses, IRQ lines — dynamically from the bootloader to the kernel.
At the silicon level, the primary core’s instruction decoder/pipeline is selected via strap pins during Stage 0 reset.
The rest of the SoC — interconnect, bus, peripherals — remains identical.
CS 4250 · Milk-V Duo S Boot Sequence — Reference