J-Link / J-Trace (UM08001) © 2004-2017 SEGGER Microcontroller GmbH & Co. KG
357
13.2 How RTT works
13.2.1 Target implementation
Real Time Terminal uses a SEGGER RTT Control Block structure in the target's mem-
ory to manage data reads and writes.
The control block contains an ID to make it findable in memory by a connected J-Link
and a ring buffer structure for each available channel, describing the channel buffer
and its state.
The maximum number of available channels can be configured at compile time and
each buffer can be configured and added by the application at run time. Up and down
buffers can be handled separately.
Each channel can be configured to be blocking or non-blocking. In blocking mode the
application will wait when the buffer is full, until all memory could be written, result-
ing in a blocked application state but preventing data from getting lost. In non-block-
ing mode only data which fits into the buffer, or none at all, will be written and the
rest will be discarded. This allows running in real-time, even when no debugger is
connected. The developer does not have to create a special debug version and the
code can stay in place in a release application.
13.2.2 Locating the Control Block
When RTT is active on the host computer, either by using RTT directly via an applica-
tion like RTT Viewer or by connecting via Telnet to an application which is using J-
Link, like a debugger, J-Link automatically searches for the SEGGER RTT Control
Block in the target's known RAM regions. The RAM regions or the specific address of
the Control Block can also be set via the host applications to speed up detection or if
the block cannot be found automatically.
13.2.2.1 Manual specification of the Control Block location
While auto-detection of the RTT control block location works fine for most targets, it
is always possible to manually specify either the exact location of the control block or
to specify a certain address range J-Link shall search for a control block for in. This is
done via the following command strings:
•
SetRTTAddr on page 238
•
SetRTTSearchRanges on page 238
For more information about how to use J-Link command strings in various environ-
ments, please refer to
Using command strings on page 241
13.2.3 Internal structures
There may be any number of "Up Buffer Descriptors" (Target -> Host), as well as any
number of "Down Buffer Descriptors" (Host -> Target). Each buffer size can be con-
figured individually.
The gray areas in the buffers are the areas that contain valid data.
For Up buffers, the Write Pointer is written by the target, the Read Pointer is written
by the debug probe (J-Link, Host).