RustSBI JH7110
rustsbi-jh7110 is an implementation of the RustSBI traits to provide the Supervisor Binary Interface (SBI) for JH7110-based platforms. The SBI is an interface between the highest privilege level (Machine mode), and the second highest privilege level (Supervisor mode) software running on the platform.
Certain access to SoC features, like Custom System Registers (CSRs), is restricted to only allow software running in Machine mode. SBI provides a common interface for less privileged software to make requests, like access to performance counters, in a uniform way across platforms. In this way, programs like bootloaders and kernels that run in Supervisor mode, can target the common interface to become platform-independent across the RISC-V ecosystem.
At the time of writing, rustsbi-jh7110 is mostly feature-complete. The majority of relevant SBI functions are implemented, and a basic "kernel" test-suite is in place to allow for integration testing on bare-metal and QEMU environments. The largest outstanding feature is the ability to load Supervisor programs from disk into memory, and hand off control to those proggrams. Almost all of the basic plumbing is in place, such as being able to parse DeviceTree (DTB) files to retrieve partition layouts. It also supplies the current HART ID and DTB address as arguments to the Supervisor program (expected by U-Boot and the Linux kernel). However, there is still work to be done reading this information from a disk like an SD card or eMMC module. Currently, it only works from inside SRAM where it is loaded by ROM firmware.
The disk reading may be able to be offloaded to bootloaders like U-Boot, which is currently able to embed the OpenSBI firmware. Ultimately, rustsbi-jh7110 should be a drop-in replacement for OpenSBI. Similarly, rustsbi-jh7110 is also usable as a library. With some work, a C interface could allow it to work with other existing bootloader projects in more robust use-cases. Obviously, it is already usable by existing Rust bootloader projects.
Flasher
The project also comes with a flashing utility to make creating and loading a binary easier.
Users can run the flash.sh helper script to create a flashable binary.
As an example, to build and flash the rustsbi-jh7110
binary to a device connected to /dev/ttyUSB0
:
git clone https://codeberg.org/weathered-steel/rustsbi-jh7110
cd rustsbi-jh7110/rustsbi-jh7110
# flash over serial
./flash.sh --flash-image --serial /dev/ttyUSB0
# only build the image, do not flash over serial
./flash.sh
Ensure the device, such as a VisionFive2 board, is connected via USB-to-Serial, and configured to boot from serial.
The resulting rustsbi-jh7110/img/sdcard.img
file can also be flashed to SD card using a program like dd
:
# dd if=rustsbi-jh7110/img/sdcard.img of=/dev/path/to/sdcard bs=4k
The tool relies on installing the following dependencies:
genimage
: https://github.com/pengutronix/genimagedtc
: https://github.com/dgibson/dtc-
rmodem
: https://codeberg.org/weathered-steel/rmodem- only needed for flashing over serial