The open-source GNU tools provide a rich set of tools to help developing software. Some are clearly more for the high-end application development. But many of the tools are applicable for the more restricted embedded software development process as well. One is gcov, or the GNU Coverage Tool. Coverage is essential for the testing phase, as it tells you what part of code have been used and ‘covered’. This article describes how GNU coverage can be added the NXP S32 Design Studio IDE.
I wrote about using gcov in earlier articles, for example “Adding GNU Coverage Tools to Eclipse“. For a complete list of related articles see the ‘Links’ section at the end of this post. Because installation and usage depends a bit on the IDE used, this article shows how gcov can be added and used with the NXP S32 Design Studio IDE which is Eclipse based. I’m using the S32DS (Design Studio) v2.2 for ARM:
For a detailed explanation about how gcov works, please see the links at the end of the article.
Unlike the NXP MCUXpresso IDE, this IDE does not come with the necessary GNU plugins installed. So I have to install the needed plugins first.
The S32DS v2.2 IDE is based on the older Eclipse Neon release. The corresponding update site
can be turned on in the workspace preferences:
Use that update site using the menu Help > Install new software and search for the gcov plugin:
Install the plugin and restart the IDE at the end of the installation.
The plugin is required to work with the coverage .gcno and .gcda files:
To generate coverage information at runtine, the code needs to be instrumented by the compiler. For this the options
have to be added to the the source file compiler options. Do not instrument all the sources: just the source files for which coverage information shall be collected. The options can be added to the properties/settings of files or directories:
Additionally, the Linker needs the following option added:
To initialize the coverage collection and to export the data, add the necessary helper (gcov_support.c and gcoc_support.h). You can find the code in the GitHubProject:
To collect coverage information in the application: initialize the library with
At the end, write the data to the host using semihosting with:
Writing of the data to the host is done by default using semhosting, e..g with a J-Link debug probe connection which is full capable to do semihosting. The library includes a function
which can be used to verify semihosting. Of course other means (RTT, UART, …) can be used to transfer the data to the host: for this, you can implement this in the stubs if you would like to use something different.
Keep in mind that instrumentation and file I/O requires stack and memory: start with a small working example, and increase stack and heap size as needed if more instrumented code is used.
Other than that: usage is the same as for example in the MCUXpresso IDE.
The NXP S32DS IDE can be used with the GNU coverage (gcov) tool too: it requires the installation of a plugins. After that, code can be instrumented and data collected from the target using semihosing. I have published an example project used in this article on GitHub.
Happy covering 🙂
- Tutorial: GNU gcov Coverage with the NXP i.MX RT1064
- Tutorial: GNU Coverage with MCUXpresso IDE
- GNU Code Coverage on Embedded Target with Eclipse Neon and ARM gcc 5
- Code Coverage with gcov, launchpad tools and Eclipse Kinetis Design Studio V3.0.0
- Example project for S32DS: https://github.com/ErichStyger/mcuoneclipse/tree/master/Examples/S32DS/S32K144_gcov