Compiling OpenSBI

OpenSBI stands for Open-source Supervisor Binary Interface and it is an open-source implementation of the RISC-V Supervisor Binary Interface. It is a RISC-V-specific runtime service provider and it is typically used in boot stage following ROM and LOADER. A typical boot flow is as follows:

Figure 1. Typical Boot Flow

Follow the steps below to compile OpenSBI for VisionFive 2.

  1. Locate to your desired directory to store the OpenSBI files. For example, the home directory.
    cd ~ # home directory
  2. Download the source code for OpenSBI compilation.
    git clone https://github.com/starfive-tech/opensbi.git
  3. Inside opensbi directory, type the following to compile openSBI.
    cd opensbi
    make ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- PLATFORM=generic FW_PAYLOAD_PATH={U-BOOT_PATH}/u-boot.bin FW_FDT_PATH={U-BOOT_PATH}/arch/riscv/dts/starfive_visionfive2.dtb FW_TEXT_START=0x40000000
    
    Tip:

    Modify the {U-BOOT_PATH} to the path of U-Boot from before.

    Result:

    After compilation, the file fw_payload.bin will be generated in the directory opensbi/build/platform/generic/firmware and the size is larger than 2M.

    Figure 2. Example Output