C to C++: Bridging the Gap from C Structures to Classes

Jacob Beningo May 23, 2023

In our last post, C to C++: Proven Techniques for Embedded Systems Transformation, we started to discuss the different ways that C++ can be used to write embedded software. You saw that there is no reason to be overwhelmed by trying to adopt complex topics like metaprogramming out of the gate. An important concept to understand is that you can make the transition gradually into C++ while still receiving the many benefits that C++ has to offer.

One of the first concepts that a C...

STM32 VS Code Extension Under The Hood

Peter McLaughlin April 21, 2023

VS Code is becoming the "go to" environment for many developers. Increasingly, toolchain providers are publishing VS Code extensions and ST has recently followed suit. Additionally, CMake is significantly growing in popularity, with many projects adopting it for its ease of use and flexibility. This video shows how the STM32 VS Code extension works under the hood and how to get more out of it.

Specifically, we'll review the CMake files generated by the VS Code extension and how to modify...

Getting Started With Zephyr: West Manifest Customization

Mohammed Billoo April 4, 2023

The Zephyr Project RTOS (https://zephyrproject.org/), or simply “Zephyr” as it is known colloquially, is an increasingly popular real-time operating system due to its native support for over 450 boards and countless peripherals. When starting with any embedded software project, the first task is to start from a known baseline. This can include cloning a repository from source control, which can be the case with embedded Linux, or downloading a zip file representing a...

Review: Embedded Software Design: A Practical Approach to Architecture, Processes, and Coding Techniques

Steve Branam February 28, 2023

Full disclosure: I was given a copy of this book to review.

Embedded Software Design: A Practical Approach to Architecture, Processes, and Coding Techniques, by Jacob Beningo, is an excellent introduction to strategies for embedded systems design and bringing those designs to fruition. Renowned embedded systems expert Jack Ganssle was the technical reviewer.

This is a practical how-to book on the modern professional practice of embedded systems...

C to C++: 3 Proven Techniques for Embedded Systems Transformation

Jacob Beningo February 7, 20234 comments

For 50 years, the C programming language has dominated the embedded software industry. Even today, more than 80% of embedded projects are using C; however, over the last few years, many teams have begun transitioning from C to C++. C++ offers embedded developers a robust, modern set of tools that can be used to write flexible, scalable, and reusable applications. As embedded applications become more complex and connected, teams need a more modern language to help them deal with the software...

Libgpiod - Toggling GPIOs The Right Way In Embedded Linux

Mohammed Billoo January 24, 2023

We all know that GPIO is one of the core elements of any embedded system. We use GPIOs to control LEDs and use them to monitor switches and button presses. In modern embedded systems, GPIOs can also be used as pins for other peripheral busses, such as SPI and I2C. Similar to the previous article on interacting with peripherals on an SPI bus in userspace via SPIdev (https://www.embeddedrelated.com/showarticle/1485.php), we can also control GPIOs from userspace on an embedded...

In Memoriam: Frederick P. Brooks, Jr. and The Mythical Man-Month

Jason Sachs November 20, 2022

It is with some sadness that I have read that Fred Brooks has passed away. Brooks (1931 - 2022) worked at IBM and managed a large team developing the IBM System/360 computers in the early 1960s. Brooks was thirty years old at the start of this project. He founded the Computer Science Department at UNC Chapel Hill in 1964, at the age of thirty-three, acting as its department chair for twenty years. He remained at IBM until 1965, however. During this one-year...

Analyzing the Linker Map file with a little help from the ELF and the DWARF

Govind Mukundan December 27, 201522 comments

When you're writing firmware, there always comes a time when you need to check the resources consumed by your efforts - perhaps because you're running out of RAM or Flash or you want to optimize something. The map file generated by your linker is a useful tool to aid in the resource analysis. I wanted to filter and sort the data generated in an interactive way so I wrote a C# WinForms application that reads the data from the map and presents it in a list view (using the awesome

Understanding and Preventing Overflow (I Had Too Much to Add Last Night)

Jason Sachs December 4, 2013

Happy Thanksgiving! Maybe the memory of eating too much turkey is fresh in your mind. If so, this would be a good time to talk about overflow.

In the world of floating-point arithmetic, overflow is possible but not particularly common. You can get it when numbers become too large; IEEE double-precision floating-point numbers support a range of just under 21024, and if you go beyond that you have problems:

for k in [10, 100, 1000, 1020, 1023, 1023.9, 1023.9999, 1024]: try: ...

Chebyshev Approximation and How It Can Help You Save Money, Win Friends, and Influence People

Jason Sachs September 30, 201220 comments

Well... maybe that's a stretch. I don't think I can recommend anything to help you win friends. Not my forte.

But I am going to try to convince you why you should know about Chebyshev approximation, which is a technique for figuring out how you can come as close as possible to computing the result of a mathematical function, with a minimal amount of design effort and CPU power. Let's explore two use cases:

  • Amy has a low-power 8-bit microcontroller and needs to compute \( \sqrt{x} \)...

Zebras Hate You For No Reason: Why Amdahl's Law is Misleading in a World of Cats (And Maybe in Ours Too)

Jason Sachs February 27, 20171 comment

I’ve been wasting far too much of my free time lately on this stupid addicting game called the Kittens Game. It starts so innocently. You are a kitten in a catnip forest. Gather catnip.

And you click on Gather catnip and off you go. Soon you’re hunting unicorns and building Huts and studying Mathematics and Theology and so on. AND IT’S JUST A TEXT GAME! HTML and Javascript, that’s it, no pictures. It’s an example of an

Using the Beaglebone PRU to achieve realtime at low cost

Fabien Le Mentec April 25, 20148 comments

I work as an engineer in a synchrotron facility. A few weeks ago, I helped the people in charge of the power supply developments to integrate a realtime control algorithm on a prototype platform: a BeagleBone Black (BBB) running Linux. I had already worked with this board in the past, and I found it very interesting given its excellent resources versus price ratio (around 40 euros). This time, I was impressed by its realtime capabilities. I thought it would be a good idea to...

Coroutines in one page of C

Yossi Kreinin August 20, 201316 comments

A coroutine is a function that you can jump back into after returning from it - and it remembers where it was in the code, and all the variables. This is very useful at times.

One use is generating a sequence of values. Here's how you can generate all the x,y pairs in a 2D range in Python:

def iterate(max_x, max_y): for x in range(max_x): for y in range(max_y): yield x,y for x,y in iterate(2,2): print x,y

This prints:

0 0 0 1 1 0 1 1

The yield keyword is like...

Important Programming Concepts (Even on Embedded Systems) Part I: Idempotence

Jason Sachs August 26, 20146 comments

There are literally hundreds, if not thousands, of subtle concepts that contribute to high quality software design. Many of them are well-known, and can be found in books or the Internet. I’m going to highlight a few of the ones I think are important and often overlooked.

But first let’s start with a short diversion. I’m going to make a bold statement: unless you’re a novice, there’s at least one thing in computer programming about which you’ve picked up...

10 Software Tools You Should Know

Jason Sachs May 20, 201215 comments

Unless you're designing small analog electronic circuits, it's pretty hard these days to get things done in embedded systems design without the help of computers. I thought I'd share a list of software tools that help me get my job done. Most of these are free or inexpensive. Most of them are also for working with software. If you never have to design, read, or edit any software, then you're one of a few people that won't benefit from reading this. 

Disclaimer: the "best" software...

C++ on microcontrollers 1 - introduction, and an output pin class

Wouter van Ooijen October 9, 20117 comments


This blog series is about the use of C++ for modern microcontrollers. My plan is to show the gradual development of a basic I/O library. I will introduce the object-oriented C++ features that are used step by step, to provide a gentle yet practical introduction into C++ for C programmers.  Reader input is very much appreciated, you might even steer me in the direction you find most interesting.

I am lazy. I am also a programmer. Luckily, being a lazy...