Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARM Semihosting #3516

1 task done
Crazor opened this issue May 20, 2020 · 2 comments
1 task done

ARM Semihosting #3516

Crazor opened this issue May 20, 2020 · 2 comments


Copy link

Crazor commented May 20, 2020

  • Feature Request.


Operating system: all platforms

PlatformIO Version (platformio --version): 4.3.3

Description of problem

Let's talk about semihosting support in PlatformIO! Semihosting is originally an ARM feature that allows code running on the target to issue IO requests to the host it is being debugged by. Semihosting is most widely used for sending printf's to the host's GDB console via the debug probe. Recently, non-ARM platforms started implementing semihosting as well, e.g. OpenOCD has support for semihosting on ESP32, too.

Most embedded devs are used to using a UART (or USB CDC) to print messages to a serial terminal for debugging, while features like PlatformIOs Unified Debugger make it very easy to use much more powerful debugging features on a plethora of platforms. Wouldn't it be great to get printf-style debugging without using any additional hardware ressources, as well?

With some hacks (like in platformio/platform-ststm32#272), it is possible today to display semihosting output in the IDE, however the integration could be better. Right now, it seems that the output from OpenOCD is not fed through GDB to the debug console, but discarded. Other projects (e.g. GNU MCU Eclipse) have this figured out, I can easily see printf output in the debug console there. This would be awesome for PlatformIO as well!

Another great use case IMHO would be unit testing. It is trivial to implement a custom transport that outputs unity's results via the semihosting mechanism. However, PlatformIO would have to be made aware of this transport and run GDB for testing and parse it's output (once the issue in the previous paragraph is solved). As a side effect, running tests through GDB would allow easy debugging of unit tests as well!

I've already looked through the debugging and test implementation of platformio-core, but I'm not at all familiar with the project structure and inner working. I'm willing to contribute code, but would need a little mentoring, tbh

Copy link

mohalsa commented Apr 27, 2021

I created a repository with very easy to follow instructions to allow semihosting for a STM32 Bluepill. Fully configured and painless. Please have a look!

Copy link

Guys, sorry that it took us so long. Glad to inform you that PlatformIO Core 6.0 will have native support for Semihosting.
See new docs and project example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

4 participants