Skip to content

rtfb/riscv-hobby-os

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RISC-V Hobby OS

CI

This is a small hobbyist kernel for RISC-V. It doesn't try to be compatible with anything, but happens to go along the old Unix ways. It does preemptive multitasking, implements fork+exec system calls, and a bunch of others needed for implementation of a simple shell. It also implements pipes.

It runs in qemu, as well as several physical RISC-V SBC boards:

Building And Running

On Ubuntu, make prereqs will install the prerequisite software for building.

make build-qemu-image will build a Docker image for running qemu. This simplifies running qemu on different versions of Ubuntu and on OSX.

With that done, you should be able to make all to build all targets, and then make run-virt to actually run it in qemu.

Implementation Details

The kernel and userland programs are built into a single binary. So the userland programs are actually just functions, located in a separate memory section. The section is isolated from the kernel memory, though, via RISC-V PMP mechanism.

On some targets the kernel supports virtual memory, and in such case the processes are better isolated. See docs/mmu.md for details.

Some other targets do not implement virtual memory. This is because the smallest common denominator of supported hardware is an extremely small HiFive microcontroller, with only 16kB of RAM and no MMU. This puts severe limitations. We want to maintain an ability to run in such small environments, as we intend to use this kernel on a small implementation of a RISC-V core on a modestly sized FPGA.

Debugging with gdb

Qemu

  1. Obtain gdb (docs/gdb.md).
  2. Run as usual with an extra DBG=1 argument, e.g. make run-virt DBG=1.
  3. In a separate terminal, run make gdb. Gdb will connect to the above, and you can use it as usual.

More Docs

The docs/ folder contains a few documents on specific narrow subjects, like operating a specific SBC board.

Handy RISC-V Quick References: