Small kernel for RISC-V
WIP paging: Make a page fault
Makefile: source config.mk for workspace-specific settings
Remove unused imports


browse  log 



You can also use your local clone with git send-email.


Small monolithic kernel for RISC-V.


The following ingredients are needed at compile time:

  • Hare toolchain for the host system
  • Cross-compiler + binutils for riscv64 capable of building shared objects. I recommend using riscv64-linux-musl from musl.cc, but you can try building one from source.
  • dd, parted and mtools for building the disk image
$ export CROSS_COMPILE=riscv64-your-prefix-
$ make

#Running in QEMU with U-Boot

First, build U-Boot according to these instructions. Don't forget to set CROSS_COMPILE to the correct cross compiler prefix (riscv64-linux-musl- if 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...

#Running on real hardware

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