-
Notifications
You must be signed in to change notification settings - Fork 245
SEGGER RTT support
Now that OpenOCD also supports SEGGER RTT (Real-Time Trace), Cortex-Debug has also added support for RTT. This is Cortex-Debug's own implementation of SEGGER RTT on the host side. You will find information about RTT
- https://www.segger.com/products/debug-probes/j-link/technology/about-real-time-transfer/
- https://wiki.segger.com/RTT
We highly recommend using RTT as it is very performative and less intrusive. This is compared to other methods like SWO or using a UART. However, RTT only works with a debugger (or one of the JLink tools) attached.
Cortex-Debug automates the setup of RTT on the host side, while still allowing customization. A lot of the implementation for viewing RTT data was borrowed from our own SWO implementation. Here are the main features (and limitations) which may be different from tools from SEGGER:
- Setup of RTT is automatic by default. For this to work, your executable needs to have symbols so we can locate the address of the global variable
_SEGGER_RTT
- The start of the RTT control block contains a string that OpenOCD/JLinkGDBServer looks for. If the address is auto-detected, we clear out the string. This will help with cases where you might have stale information from a previous run.
- For OpenOCD, you can customize the
polling_interval
, and the search string. The defaultpolling_interval
is 100ms as of today. 10ms seems more acceptable as a tradeoff between creating bus traffic and not losing/blocking data. If nothing changes in the MCU, then OpenOCD does not do much even if the interval is small. - It is perfectly fine to have Cortex-Debug enable RTT but not use any display features. This way you can use external tools (like JLink tools or custom ones)
- You can plot RTT data just like you could with SWO. The setup in launch.json is identical. See this comment.
- Channel sharing: You can use the same RTT channels in multiple ways. Corte-Debug reads the channel data from OpenOCD/JLink once and distributes to all subscribers (terminals & graphs & logfiles). For instance, you can plot a channel and also look at its binary data in a terminal. Just use two decoders with the same channel (actually called port) number.
- Note: JLink GDB Server has a limitation that it only exposes one channel (channel 0). There is another artifact with RTT channels where you may see output from a previous run at the very beginning.
- Note: This implementation does not support Virtual Terminals that you see in the JLink RTTViewer. All output goes to the same terminal.
In the classical VSCode way of doing things, you control everything via the launch.json
file.
There is only one proper needed to get going. enabled
.
Property | Type | Default | Description |
---|---|---|---|
enabled | boolean | "true" | Global enable/disable for RTT functionality |
address | string | "auto" | Start address to search for RTT control block (CB). Use a hex (0x prefix) or decimal number |
searchSize | number | 16 | OpenOCD only. Number of bytes to search for the beginning of RTT CB |
searchId | string | "SEGGER RTT" | OpenOCD only. the string to search for at the beginning of the RTT CB |
polling_interval | number | 0 | 0 means use gdb-server default. Or use a number in milliseconds |
decoders | array | N/A | N/A |
This is almost identical to our SWO implementation but added