Visual Studio Code for C/C++ with ARM Cortex-M: Part 9 – RTT

For me the Cortex-Debug Visual Studio extension by marus25 is the standard way to use VSC for embedded development. Another ‘standard’ piece I’m using in many of my projects is the SEGGER RTT.

SEGGER RTT Output with Visual Studio Code


RTT is a bidirectional-multi-channel communication protocol which is very fast and can transfer data between the host and the target. Think about a fast UART or data communication over the debug interface or cable. It requires a SEGGER J-Link connection and J-Link compatible probe connected to the target, see for more details about this technology.

RTT Library

To use RTT, you need to add the RTT stubs to your application. See the folder ‘McuLib/SEGGER_RTT’ in my project on GitHub. Make sure you initialize the library with McuRTT_Init():

Initializing RTT

Then you can print or scan data like from a ‘virtual UART’. E.g. to print data on RTT channel 0 (the default console), you can use:

McuShell_SendStr("hello world!\n", McuRTT_GetStdio()->stdOut);

With this data gets printed to the RTT console channel and you can use any other RTT (either telnet port or RTT viewer from Segger).

To use RTT within Visual Studio, you need to configure the Launch Configuration.

Launch Configuration

You need to add a “rttConfig” to your launch.json file:

RTT Config in launch.json
"rttConfig": {
                "enabled": true,
                "address": "auto",
                "decoders": [
                        "label": "",
                        "port": 0,
                        "type": "console"


Port 0 is the default console port. If you launch now the debug session, I have now RTT support within Visual Studio Code:

RTT console output in Visual Studio Code

The Visual Studio Code console supports the ANSI terminal color coding as well. Below an example with using the McuLog function:

Another usage of RTT is as shell/console interface to the application:

Shell with RTT


RTT is very useful: I have a multiple (terminal, binary data, logging) bidirectional data channels to my target(s), and all what I need is a SEGGER debug probe. While the RTT data can be produced or consumed by different clients, it is very useful to have RTT used directly from the Visual Studio Code. I hope you find that as useful as I do.

Happy RTTing 🙂


3 thoughts on “Visual Studio Code for C/C++ with ARM Cortex-M: Part 9 – RTT

    • Yes, it is such a great tool. Many developers do not realize that debugging is not only about the probe hardware but about the development tools around it. Tracealyzer is great, so is SystemViewer.


  1. Pingback: Visual Studio Code for C/C++ with ARM Cortex-M: Part 10 – Assembly Stepping | MCU on Eclipse

What do you think?

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.