contributed by <huang-me
>, <OliveLake
>
Expectation
As shown in figure below
RVVM replace QEMU, and we need to prepare OS kernel
& cross compiler tools
& Distributions for it.
There are two types riscv-gnu-toolchain,
riscv32-unknown-elf-gcc
, cross compiler using newlib for 32bit
RISC-V bare-metal.riscv32-unknown-linux-gnu-gcc
, corss compiler using glibc which provides the core libraries for GNU/Linux systems.Toolchain leading with riscv-none-embed-
is toolchain for embedded system.
We're going to build risc-v linux, so we need toolchain leading with riscv64-unknown-linux-gnu-
.
fw_jump.bin
will be generated inopensbi/build/platform/generic/firmware
Image
will be generated inlinux/arch/riscv/boot
riscv-none-embed- has no byteswap.h
For ubuntu, there are some needed packages to build toolchain.
After sudo make linux
Because RISC-V Linux require A-extension
as minimal requirement, so at least we should use --wtih-arch=rv32ia
or --with-arch=rv64ia
for building linux toolchain. We sholud use
PICTURE
Usually regular bootloader (e.g. U-Boot) binary is bigger than SRAM, So we need to create some additional bootloader, referred as first-stage bootloader (in two-stage bootloader scenario). Regularly the first-stage bootloader is U-Boot SPL, and the second-stage bootloader is U-Boot.
RVVM allows boot the Linux kernel directly after SBI, without U-Boot. Therefore we need to execute fw_jump.bin
which contain OpenSBI and initial firmware.
static
jump address to the next booting stage, so previous booting stage (i.e. LOADER) has to load next booting stage (i.e. BOOTLADER) at a fixed location.
Create simple Hello world of booting Linux on RVVM
error occurs
Caused by failing to use RISC-V compiler, reset path:
fw_jump.bin
will be generated in opensbi/build/platform/generic/firmware
Build RVVM using GNU make on linux
There is an error about no such file or directory : X11/keysym.h & X11/extentions/XShm.h
Solution :
Then keep building RVVM
loop forever
After contact with RVVM team, it seems like we are running U-Boot as SBI payload, and U-Boot tries to access MMC flash - RVVM doesn't support flash (yet), so U-Boot keep resets the VM. One solution is we built U-Boot with IDE (ATA) hard-drives, and another way is we boot the Linux kernel directly after SBI, without U-Boot.
Rebuild without U-Boot
There is not that much pre-built distributions for 32-bit RISC-V, so we use Buildroot
Due to RISC-V is an open ISA, and the freedom of extending the ISA with custom instructions and extensions, the compliance tests are essential to confirm the basic operation is in accordance with the specification
TODO