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:
Follow the steps below to compile OpenSBI for VisionFive.
-
Locate to your desired directory to store the OpenSBI files. For example, the home
directory.
cd ~ # home directory
-
Download the source code for OpenSBI compilation.
git clone https://github.com/riscv/opensbi.git
-
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}/u-boot.dtb
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.
-
Navigate to the directory containing fw_payload.bin.
cd opensbi/build/platform/generic/firmware
-
Copy the file
fw_payload.bin
to a different location.cp fw_payload.bin ~/Desktop/payload/
-
Navigate to the location where fw_payload.bin is copied and execute the following to
install an image conversion tool.
cd ~/Desktop/payload/ sudo apt install subversion svn export https://github.com/starfive-tech/freelight-u-sdk.git/branches/starfive/fsz.sh
Tip:Here is the source code.
-
Change the user rights of the tool.
chmod 777 fsz.sh
-
Convert the file from fw_payload.bin to
fw_payload.bin.out.
./fsz.sh fw_payload.bin fw_payload.bin.out
Figure -
Tip:You will see a new file named
fw_payload.bin.out
generated. Refer to Appendix B: Updating Firmware and u-boot section in VisionFive Single Board Computer Quick Start Guide to flash u-boot.