PinnedA Deep Dive into Low-Level Hardware Access with C: Examples for RISC-VThe 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 captures experience with low-level programming in C gained…C22 min readC22 min read
Dec 12, 2022Nitpicking a Dumb Machine, the Imaginative Coding of ChatGPT.There’s been a buzz about ChatGPT on the tech web recently, with some Tech Bro’s even claiming to be outsourcing their coding to it. With any new tool, it’s interesting to try a corner case and a real-world problem. New technology doesn’t always work well for me, and while Jason…Rust3 min readRust3 min read
Feb 18, 2022Coding in C for MCUs: Sort Structs to Save Code SizeExploring the Impact of Hardware Architecture on Code This post explores two things. Firstly, a handy way to save code size on ARM Cortex-M-based MCUs with limited resources. Secondly, it looks at the impact of the hardware architecture on meeting software requirements. In particular, it looks at memory rows and alignment. An Easy Code Size Optimization I’d like to share a simple coding…C5 min readC5 min read
Aug 19, 2021Things to Think About When Doing Low-Level Embedded Systems Development.What are the foundations of designing and implementing low-level software that interacts with real-world systems? (By low level I mean software running on bare-metal or a small footprint RTOS, on a small processor core — Not embedded Linux on a Cortex-A class MCU) An introductory embedded systems book will often…Embedded Systems7 min readEmbedded Systems7 min read
Jun 25, 2021RISC-V: A Baremetal Introduction using C++. Conclusion.This is the last post in the series. Is it possible to write pure modern C++ bare-metal firmware from the ground up for RISC-V? The answer is a qualified yes. The toolchain using Platform IO supported modern C++ with a small configuration change. The startup code required some assembly, but…Cpp3 min readCpp3 min read
Jun 13, 2021RISC-V: A Baremetal Introduction using C++. Interrupt Handling.This is the seventh post in a series. This post is about RISC-V interrupt handling in C++. What are the basics of interrupt handing in RISC-V? Can we utilize modern C++ to simplify interrupt handling? RISC-V Machine Mode Interrupts The RISC-V ISA is not specialized for embedded applications (when compared to an ISA such…Cplusplus5 min readCplusplus5 min read
Jun 7, 2021RISC-V: A Bare-metal Introduction using C++. Machine Mode Timer.This is the sixth post in a series, about the RISC-V machine mode timer and timing keeping using the C++ std::chrono library. How does RISC-V keep time? How can we perform a periodic task with no operating system? You may take for granted that you can simply ask the operating…Risc V4 min readRisc V4 min read
Jun 7, 2021RISC-V: A Baremetal Introduction using C++. System Registers.This is the fifth post in a series. 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++. Do we…Risc V4 min readRisc V4 min read
May 29, 2021RISC-V: A Baremetal Introduction using C++. Startup.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? …Risc V4 min readRisc V4 min read
May 23, 2021RISC-V: A Baremetal Introduction using C++. Development EnvironmentFollowing on from Part 2, how do we compile this project and run it? For this series of posts, my platform is a SiFive HiFive1 Rev B development board. It’s equipped with a 320MHz RV32IMAC (FE310 core). …Risc V4 min readRisc V4 min read