C++ has always fascinated us – it looks like with proper usage nothing is impossible. In this series of short blog posts, we aim to highlight the advantages of using C++ on small embedded systems. We also seek to break the myth that C++ is unsuitable for resource-constrained environments, hoping to inspire greater adoption of C++ in bare-metal development.
Our approach will be minimalistic, focusing on the essentials, while minimizing reliance on unnecessary tools, SDKs, or thirdparty software. We will explore the firmware development process on Linux from scratch, raw and clean. Along the way, we will clarify some concepts in embedded software development, including the ARM toolchain, Makefiles, startup files, linker scripts, GDB, and more.
The raw sketch of the contents looks like this:
- Motivation, Prerequisites setup
- C++ GPIO, UART, PWM/Timer, Initialization, IRQs, Calculations
- Makefile (compiling & builidng), Linker script, Startup file, Debugging, Unit testing
Why C++
The main advantage is moving as much as possible stuff to compile time to produce firmware with a smaller memory footprint, something that things like constexpr can enable.
We also focus on strictly defining types to avoid issues such as implicit conversions, which can lead to unwanted and unexpected behavior - avoiding the use of #define macro.
By leveraging features like templates, we can express ideas more elegantly without paying the price - zero cost abstraction.
There are many more aspects we will explore and discuss as we go along…
