Tutorial: GNU Coverage with C++ for Embedded Applications

In an earlier article I explained how to generate GNU coverage information, for an embedded application written in C.

In this article, I show the steps and configuration needed to use GNU gcov targeting an embedded application with C++.

GNU gcov Coverage with C++ Application
Continue reading

How to Use GNU Coverage (gcov) in a Freestanding Environment for Embedded Systems

The GNU Coverage (gcov) is a source code analysis tool, and is a standard utility in the GNU gcc suite. It works great in a hosted environment (e.g. Linux or Windows), where you have plenty of resources and a file system. But the gcov tools is relevant and usable for restricted embedded systems too. I have used it for years with the help of debug probes and file I/O semihosting. But semihosting does not come for free, depends on a library with support for constructors and destructors, plus relies on file I/O.

Fortunately, there is a way to use gcov without debugger, semihosting, file I/O and special system initialization: using a freestanding environment:

gcov in freestanding environment with embedded target

This article explains how to collect coverage information using a data stream for example over UART or USB-CDC. Key benefits are less code side, no need for a debugger or on-target file system, improved performance, better automation and flexible data collection.

Continue reading

Modern On-Target Embedded System Testing with CMake and CTest

One key element of a CI/CD pipeline is the automatic testing phase: whenever I check in new source code or manually trigger it, I can run a test suite to make sure that the changes do not break anything. For this, I have to run automated tests. For an an embedded target, it means that I have to run some tests on the board itself too.

CTest with VS Code
Continue reading

Building with CMake Presets

I’m getting my head more and more around CMake and its features. After having so many issues with VS Code dealing with CMake Kits, I have found feature in CMake which really is a game changer for me: CMake Presets.

Working with CMake Presets in VS Code
Continue reading

GNU Coverage (gcov) for an Embedded Target with VS Code

An important part of every CI/CD pipeline is having a testing phase. In this article I show how to use GNU gcov (coverage) with an embedded target, using Visual Studio Code as front end:

GNU gcov with VS Code

With this, I can run the code on the embedded target which stores the coverage data on the host.

Continue reading

Implementing File I/O Semihosting for the RP2040 and VS Code

I’m working recently on a new lecture module using the Raspberry Pi Pico (RP2040) board, which highlights several aspects of modern software engineering, including DevOps and CI/CD. An important part of any CI/CD pipeline is testing. For a host application, one could pass arguments to the application, e.g. ‘myapp --test=module1‘, or let it read such information from a configuration file which describes the tests. Or write GNU gcov data to a file to collect coverage information.

Unfortunately, a normal embedded application has no argv[], and many system have no file system. A solution to this problem would be using semihosting with file I/O. Unfortunately for the Raspberry Pi Pico SDK 1.5.1 for the RP2040, there is no semihosting file I/O implemented :-(.

I have now implemented and added file I/O to the SDK, making it possible for the RP2040 to access and use files on the host, among other things. This greatly extends the capabilities of the device, and is very useful for testing, including gathering test coverage information.

RP2040 writing files on the host with semihosting
Continue reading

CI/CD for Embedded with VS Code, Docker and GitHub Actions

“Our highest priority is to satisfy the customer
through early and continuous delivery
of valuable software.”

Agile Manifesto, https://agilemanifesto.org/principles.html

It is interesting to see that modern tools and agile development workflows are getting more and more into the embedded world. CI/CD is a strategy where code changes to an application get automatically integrated, tested and released automatically into a production environment.

VS Code with CI/CD
Continue reading