Maybe you are using a multi-core device in your projects, but have not tapped into multi-core usage yet? FreeRTOS V11.0 is out, and the big news is that it has finally Symmetric Multi-Processing (SMP) integrated into the mainline. This greatly simplifies FreeRTOS usage, as I finally can use the same RTOS for my SMP targets and boards, and I can easily switch between single-core and multi-core applications.
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.
The MCU-Link is a small and inexpensive $10 CMSIS-DAP debug probe from NXP. It can work with OpenOCD, but has better target support using the NXP LinkServer which implements a gdb server. This makes it an ideal combination for scripting or automated testing.
What makes Microsoft Visual Studio Code really useful is the concept of Extensions: Probably for every problem or use case you might find an extension. There are more than 40K extensions available for VS Code. And VS Code asks to install extensions:
VS Code asking to install an extension
The issue with this is: more and more extensions get added, making VS Code slower and slower, caused by that ‘extension creep’. Even worse: extensions can cause conflicts, and clutter the development flow. Luckily, there is a cure for this in VS Code: Profiles.
One important thing in using VS Code and CMake projects is that one needs to have a CMake kit assigned to the project. But after a restart of VS Code or if I re-load a project, VS Code has lost the previously assigned CMake kit:
VS Code has forgotten about the previously assigned CMake Kit?
This is very annoying, but luckily I have found a fix for this.
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.
With semihosting I can use standard I/O function like printf() and I can read and write data on the host through the debug connection. If used with care, this is a great feature especially for unit testing.
In the OOP world, global objects get initialized with a constructor and destroyed at the end with a destructor. Interestingly, the GNU gcc has attributes to mark functions as constructor and destructors, which can greatly simply system startup and shutdown, even if not using C++.
C Function marked as Constructor and called before main()
With the GNU gcc compiler, I can mark functions with an attribute, so they get called before entering main() or after exit of main(). The attribute works both in C and C++, but it especially useful in C to initialize modules in an automated way.
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.