Small monolithic kernel for RISC-V.
The following ingredients are needed at compile time:
riscv64capable of building shared objects. I recommend using
riscv64-linux-muslfrom musl.cc, but you can try building one from source.
$ export CROSS_COMPILE=riscv64-your-prefix- $ make
First, build U-Boot according to these instructions. Don't forget to set
CROSS_COMPILE to the correct cross compiler prefix (
using the one from musl.cc).
$ qemu-system-riscv64 -machine virt -bios /path/to/u-boot/u-boot \ -drive file=build/disk_image,format=raw,if=virtio -serial stdio
Note: I/O is redirected to the terminal, but the GUI window will still appear.
This can be disabled with
-nographic, but still recommended to do because
that window will provide an easy way to kill QEMU if the kernel halts.
Press any key to stop auto-booting and drop into U-Boot shell, then the following will boot carrot:
=> virtio scan => load virtio 0:1 $kernel_addr_r /efi/boot/bootriscv64.efi => bootefi $kernel_addr_r
Optional: set sane auto-boot settings: run
make menuconfig, go into
"Boot options" -> "bootcmd value", set it to
virtio scan; load virtio 0:1 $kernel_addr_r /efi/boot/bootriscv64.efi; bootefi $kernel_addr_r, save, exit.
Then rebuild U-Boot. TODO: this shouldn't be necessary...
For the HiFive Unmatched: first, get u-Boot with UEFI support working for your system. Consult the upstream docs. Then boot your system and break the u-Boot startup via serial by pressing a key, and run this:
=> pci enum => usb start => load usb 0:1 $kernel_addr_r /EFI/boot/bootriscv64.efi => bootefi $kernel_addr_r
TODO: rewrite this (essentially zero steps) once this works with bootmgr