As a beginner in RISC-V, In this repo, I am learning the bootflow of RISC-V, and want to emulate it with QEMU.
NOTE: different from Direct Boot, in which to launch a kernel on QEMU without having to make a full bootable image and just passing a parameter -kernel
to specify the kernel image. Then qemu-system-riscv64
will load it automatically. (This is helpful for kernel debugging, but hides many details of the bootflow)
As it has variant bootflows, here I just focus on two of them:
-
I boot it by using a payload firmware of OpenSBI.
./boot_payload
: BootROM -> FSBL -> FW_Payload -> UBoot -> Linux Kernel -
I change it to use a dynamic firmware of OpenSBI.
./boot_uboot-spl
: BootROM -> UBoot-SPL -> FW_Dynamic + Uboot-Proper -> Linux Kernel
PBL
: Primary Boot LoaderSPL
: Secondary Program LoaderZSBL
: Zero Stage Boot LoaderFSBL
: First Stage Boot LoaderSSBL
: Second Stage Boot Loader
BootROM (PBL)
- Processor boots from BootROM
- Copies FSBL from memory device to SRAM and start executing FSBL.
Specific FSBL / U-Boot-SPL
- Copies next stage of code into DRAM
- Further initialization
- Launches SSBL
OpenSBI + UBoot-Proper
- OpenSBI: FW_Payload / FW_Dynamic / FW_Jump
- Flexibilities in boot sources.
(a) BootROM -> Specific FSBL -> OpenSBI -> Linux
(b) BootROM -> Specific FSBL -> OpenSBI -> U-Boot-Proper -> Linux
(c) BootROM -> U-Boot-SPL -> OpenSBI -> U-Boot-Proper -> Linux
For a), usually FPGA platforms use this approach.
For b) and c), mostly real world SoC tend to use these flows. We have bootloaders which provide advance booting methods
. We can load kernel image from SD card OR Flash OR TFTP without changing firmware or bootloader.
The c) approach is most flexible because we can upgrade
any image in the boot flow without changing other images.