Getting printf Output from Target to Debugger


Debug OutputErich Styger recently posted a great tutorial on how to add console functionality using Single Wire Output (SWO) on ARM Cortex-M targets.

This inspired me to write a more general post on debug output (“printf”) implementations on embedded target, including SWO and RTT.

Debug Output from a Target

There are different methods to get debug output from the target application.

Since the early days of embedded systems, there have been hardware dependent solutions like using a UART or USB CDC. But a UART may already be used by the application and CDC requires a USB stack and a USB connector on the target hardware.

The first software solution is semihosting. With semihosting, the CPU halts to print output and is restarted “behind the scenes” by the debugger. Printing one message can take anywhere from several milliseconds to more than one hundred milliseconds, as it is an expensive operation. The debugger needs to realize that the target has stopped execution, reads registers and memory, writes memory, and can then restart the CPU. This means the target CPU does not run for this period of time. Therefore semihosting can simply not be used for applications which require real time behaviour, such as communication stacks. Additionally the semihosting implementation is debugger dependent, and applications which use semihosting might not run without a debugger connected.

And then there are ARM’s SWO trace port and SEGGER’s Real Time Transfer (RTT).

Update on: Comparing Performance on Windows, Linux and OS X

If you haven’t read the original post, have a look at it: Comparing Performance on Windows, Linux and OS X I got my computer upgraded 🙂 It is very tiny, an Intel NUC Kit. But what matters is what is inside: An Intel i7 with 4 cores and hyper-threading, so like 8 processors, 16 GB […]

Why you should benchmark your embedded system

There are plenty of potential reasons why an embedded system may not deliver the full CPU performance. This is not even that easy to detect, so here is a way to check if your system gives you the performance you expect. What can go wrong? Today’s embedded systems are complex computers. Microcontrollers are usually easiest […]

Profiling software in Embedded Systems

Good engineers for embedded software strive to write software that is efficient, small, and maintainable. However, inefficiencies can appear from the most unexpected places, places that you would never think to look for a performance bottleneck or “sinkhole”. This short article describes different ways to profile an application, showing the path to identifying such a sinkhole […]

Comparing Performance on Windows, Linux and OS X

Last week, I compared the speed of the 64-bit and the 32-bit build of Embedded Studio and the GCC compiler. The 64-bit version was the clear winner, with a performance gain of about 5 – 20%. But what can we get from working with different operating systems? At SEGGER, we developers are free to select the operating system […]