Click below for the YouTube video introducing this project:
mini-rv32ima is a single-file-header, mini-rv32ima.h, in the STB Style library that:
- Implements a RISC-V rv32ima/Zifencei+Zicsr (and partial su), with CLINT and MMIO.
- Is about 400 lines of actual code.
- Has no dependencies, not even libc.
- Is easily extensible. So you can easily add CSRs, instructions, MMIO, etc!
- Is pretty performant. (~450 coremark on my laptop, about 1/2 the speed of QEMU)
- Is human-readable and in basic C code.
- Is "incomplete" in that it didn't implement the tons of the spec that Linux doesn't (and you shouldn't) use.
- Is trivially embeddable in applications.
It has a demo wrapper that:
- Implements a CLI, SYSCON, UART, DTB and Kernel image loading.
- And it only around 250 lines of code, itself.
- Compiles down to a ~18kB executable and only relies on libc.
Just see the mini-rv32ima
folder.
It's "fully functional" now in that I can run Linux, apps, etc. Compile flat binaries and drop them in an image.
I'm working on a really really simple C Risc-V emultor. So simple it doesn't even have an MMU (Memory Management Unit). I have a few goals, they include:
- Furthering RV32-NOMMU work to improve Linux support for RV32-NOMMU. (Imagine if we could run Linux on the $1 ESP32-C3)
- Learning more about RV32 and writing emulators.
- Being further inspired by @pimaker's amazing work on Running Linux in a Pixel Shader and having the sneaking suspicion performance could be even better!
- Hoping to port it to some weird places.
- Understand the most simplistic system you can run Linux on and trying to push that boundary.
- Continue to include my [education of people about assembly language].(https://www.youtube.com/watch?v=Gelf0AyVGy4)
Windows instructions (Just playing with the image)
- Clone this repo.
- Install or have TinyCC. Powershell Installer or Regular Windows Installer
- Run
winrun.ps
in thewindows
folder.
Linux instructions (both):
- Clone this repo.
- Install
git build-essential
and/or whatever other requirements are in place for buildroot. make testdlimage
- It automatically downloads the image (~1MB) and runs the emulator.
- Should be up and running in about 2.5s depending on internet speed.
You can do in-depth work on Linux by:
make everything
If you want