modm API documentation
|
lbuild module: modm:rtt
This module implements the RTT protocol compatible with JLink and OpenOCD. RTT works by placing multiple ring-buffers in RAM which the debugger read and writes using background memory accesses via SWD. It therefore works on any Cortex-M device without extra pins except for the SWDCLK and SWDIO.
You can define the number of channels and their buffer size by setting the buffer.tx
and buffer.rx
set options. Note that you can define multiple buffer sizes indexed by channel. Here is an example of three channels:
You can set the buffer size to 0
if you don't want to use this channel direction. This won't allocate a buffer and save a little RAM.
The API reference is available here.
OpenOCD has built-in support for RTT and modm generates a config that opens each RTT channel as a TCP port starting at 9090 (ie. 9090=channel 0, 9091=channel 1, etc).
You can also call this from inside GDB via the monitor
command:
You can then use netcat to connect to one or multiple streams:
Note that this connection does not halt the target, you should therefore be able to use this at any point during program execution.
A simple RTT client is integrated into the build system generator, however, it can only connect to one stream at a time (disconnect with Ctrl+C).
If you want to use this as a proper communication channel with a custom protocol you should implement the OpenOCD config yourself (with different ports).
You can also use JLink to access the RTT data, which may be significantly faster than OpenOCD if the debug probe has hardware support for the protocol. Note the port JLink uses is 19021 (channel 0) and 19022 (channel 1), etc.
Generated with: [512] in [0 ... +Inf]
Generated with: [0] in [0 ... +Inf]