This article was also posed to Medium.
The C programming language provides a thin hardware abstraction that allows us to create low-level systems programs. However, there are still many hardware features that aren’t exposed by the programming language. How do we access hardware while programming in C?
This article covers some tricks used to write low-level code in C and build a simple bare-metal run-time environment. The target hardware is a RISC-V RV32I in machine mode. The RISC-V is a simple architecture well suited to understanding low-level programming, and a small 32-bit core is ideal for applications that benefit from bare-metal programming.
What are the basics of interrupt handing in RISC-V? Can we utilize modern C++ to simplify the interrupt handling?
This is the sixth post in a
about the RISC-V machine mode timer and timing keeping using the C++
What are system registers in RISC-V? How can we access them with modern C++?
System registers require special instructions to access, so unlike memory mapped registers (MMIO) we can’t just cast a pointer to memory to get access them in C++.
In the last post, we set up the development environment. This post is about how the RISC-V core executes our program.
How do we go from reset to entering the
main() function in C++ in
RISC-V? Startup code is generally not something you need to worry about,
however, it is of interest when bringing up a device from scratch.
For this series of posts, my platform is a SiFive HiFive1 Rev B development board. It’s equipped with a 320MHz RV32IMAC (FE310 core). For software build and debug the choice is Platform IO, an IDE integrated into VS Code.
As described in Part1, a simple C++ application to blink an LED, what does this look like with no operating system?
This is a series of posts where I’d like to combine those topics for embedded systems programming. RISC-V and C++ have been evolving rapidly, and you will see modern C++ is a great way to explore RISC-V and develop embedded systems.