Running U-Boot & Linux Kernel in QEMU

Donotalo
18.5K views

Open Source Your Knowledge, Become a Contributor

Technology knowledge has to be shared and made accessible for free. Join the movement.

Create Content

OpenSBI acts as a layer between the hardware and Operating System running in S-Mode for RISC-V. It helps to get access to hardware from the Operating System. This tutorial uses v1.2 of OpenSBI. Check the RISC-V SBI specs for details.

Run the following from the root working directory:

# Download the source code
git clone https://github.com/riscv-software-src/opensbi.git

cd opensbi
git checkout v1.2

# Build for generic platform with U-Boot as bootloader
make PLATFORM=generic FW_PAYLOAD_PATH=../u-boot/u-boot.bin -j$(nproc)
  • PLATFORM=generic = tells OpenSBI to build the firmware for generic platform, which isn't tied to any specific board. Rather, the hardware description comes from Flattened Device Tree (FDT) which is passed from previous boot stage. In other words, the firmware that loads OpenSBI will provide the list of devices available to the system.
  • FW_PAYLOAD_PATH = tells OpenSBI the location of the firmware to be executed next.

This tutorial will use the output file build/platform/generic/firmware/fw_payload.elf that QEMU can run. Because FW_PAYLOAD_PATH points to the u-boot, U-Boot is embedded in the output and OpenSBI will launch U-Boot automatically.

Open Source Your Knowledge: become a Contributor and help others learn. Create New Content