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

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

ARM Semihosting #3516

Crazor opened this issue May 20, 2020 · 2 comments

Comments

@Crazor
Copy link

Crazor commented May 20, 2020

  • Feature Request.

Configuration

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
stm32cube-hal-semihosting.zip
.

@mohalsa
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!

https://github.com/mohalsa/STM32_BluePill_Semihosting

@ivankravets
Copy link
Member

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 https://docs.platformio.org/en/latest/advanced/unit-testing/semihosting.html and project example https://github.com/platformio/platformio-examples/tree/develop/unit-testing/semihosting

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

No branches or pull requests

4 participants