This repository contains the code for the RISC-V from scratch blog post series, which can be found here: https://github.com/twilco/twilco.github.io
RISC-V from scratch details my personal exploration of various low-level concepts including compilation and linking, primitive runtimes, assembly, and more, typically through the lens of RISC-V and its ecosystem. If this sounds interesting, here is a summary of each post released so far:
- RISC-V from scratch 1: Introduction, toolchain setup, and hello world!
Branch: No code prerequisites
An introduction to RISC-V, RISC-V GNU toolchain setup, and the running of a simple program on an emulated RISC-V processor. - RISC-V from scratch 2: Hardware layouts, linker scripts, and C runtimes
Branch: master
A review of the devicetree layout of thevirt
QEMU virtual machine, linker scripts, basic RISC-V assembly, a minimal C runtime, and more, all in an effort to understand how we get to themain
function. - RISC-V from scratch 3: Writing a UART driver in assembly (1 / 3)
Branch: pre-uart-driver-skeleton
Begins implementation of a driver for thevirt
onboard UART, discussing the basics of UART functionality and doing additional linker script and devicetree layout exploration along the way. - RISC-V from scratch 4: Creating a function prologue for our UART driver (2 / 3)
Branch: pre-function-prologue-impl (post in progress)
Continues implementation of a driver for thevirt
onboard UART, diagramming instruction-by-instruction the what, why, and how of function prologues. Also discusses other topics such as ABIs, more RISC-V assembly instructions, and function epilogues.
The code necessary to begin each post is stored in a named branch. As an example, the code required to begin RISC-V from scratch 3: Writing a UART driver in assembly (1 / 3) is located in the branch named pre-uart-driver-skeleton. Each post contains a "Setup" section that will inform you, if necessary, which branch you'll need to check out and what things need to be installed, so feel free to jump right into any post that sounds interesting.
There are two directories present in this project: src
and work
. In each branch, src
will contain the code needed to begin following along with the specific post. work
can be used as your personal working directory as you progress through the series, allowing you to move from branch to branch and pull from or compare with src
as you please.
If you have any questions, comments, or corrections, feel free to open an issue or leave a comment on the posts themselves.