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

Semihosting with VS Code on RP2040

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.

Raspberry Pi Pico-W (RP2040) board
Continue reading

Using Semihosting the direct Way

Most embedded developers have probably used ‘semihosting’. And yes, it is generally seen as a bad thing. Maybe you have used it, without realizing what it really is and what it does. It is simple to add a printf() to the code (again: you should not use printf), and with the right standard library, it magically it shows up in a console view:

printf a hello world

That looks great, but what is behind this, to make it happen? Actually, it is really amazing technology. And it can be used for better things than just printing text.

Continue reading

Silicon Shortage and Semihosting with NXP MCUXpresso SDK on FRDM-KE02Z

The silicon shortage is still going on. While the NXP Kinetis KE devices might not be my first choice, they still seem to be available, in at least in lower quantities. This has been recognized by others, as I’m getting more and more questions and requests for the KE and KV family. This is why I un-dusted my old FRDM-KE02Z to be used with the latest MCUXpresso SDK and IDE.

FRDM-KE02Z Board

And in case you want to use that board or device with semihosting, I have you covered.

Continue reading

Semihosting with Eclipse and the NXP Kinetis SDK V2.0

The world is changing, and the say is “change is good” :-). In the software and API world, change very often means that a change results into something broken. So I had battled with semihosting working on the NXP Kinetis parts, only to find out that it does not work any more with using the latest version 2.0. The semihosting output e.g. with P&E debug connection remains empty:

No Semihosting output

No Semihosting output

So how to fix this?

Continue reading