Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RTT support #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions doc/openocd.texi
Original file line number Diff line number Diff line change
Expand Up @@ -8129,6 +8129,94 @@ the watchpoint should trigger. The value may be first be masked
using @var{mask} to mark ``don't care'' fields.
@end deffn


@section Real Time Transfer (RTT)

Real Time Transfer (RTT) is an interface specified by SEGGER based on basic
memory reads and writes to transfer data bidirectionally between target and host.
The specification is independent of the target architecture.
Every target that supports so called "background memory access", which means
that the target memory can be accessed by the debugger while the target is
running, can be used.
This interface is especially of interest for targets without
Serial Wire Output (SWO), such as ARM Cortex-M0, or where semihosting is not
applicable because of real-time constraints.

@quotation Note
The current implementation supports only single target devices.
@end quotation

The data transfer between host and target device is organized through
unidirectional up/down-channels for target-to-host and host-to-target
communication, respectively.

@quotation Note
The current implementation does not respect channel buffer flags.
They are used to determine what happens when writing to a full buffer, for
example.
@end quotation

Channels are exposed via raw TCP/IP connections. One or more RTT servers can be
assigned to each channel to make them accessible to an unlimited number
of TCP/IP connections.

@deffn Command {rtt setup} address size ID
Configure RTT for the currently selected target.
Once RTT is started, OpenOCD searches for a control block with the
identifier @var{ID} starting at the memory address @var{address} within the next
@var{size} bytes.
@end deffn

@deffn Command {rtt start}
Start RTT.
If the control block location is not known, OpenOCD starts searching for it.
@end deffn

@deffn Command {rtt stop}
Stop RTT.
@end deffn

@deffn Command {rtt polling_interval [interval]}
Display the polling interval.
If @var{interval} is provided, set the polling interval.
The polling interval determines (in milliseconds) how often the up-channels are
checked for new data.
@end deffn

@deffn Command {rtt channels}
Display a list of all channels and their properties.
@end deffn

@deffn Command {rtt channellist}
Return a list of all channels and their properties as Tcl list.
The list can be manipulated easily from within scripts.
@end deffn

@deffn Command {rtt server start} port channel
Start a TCP server on @var{port} for the channel @var{channel}.
@end deffn

@deffn Command {rtt server stop} port
Stop the TCP sever with port @var{port}.
@end deffn

The following example shows how to setup RTT using the SEGGER RTT implementation
on the target device.

@example
resume

rtt setup 0x20000000 2048 "SEGGER RTT"
rtt start

rtt server start 9090 0
@end example

In this example, OpenOCD searches the control block with the ID "SEGGER RTT"
starting at 0x20000000 for 2048 bytes. The RTT channel 0 is exposed through the
TCP/IP port 9090.


@section Misc Commands

@cindex profiling
Expand Down
4 changes: 3 additions & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ endif
%D%/target/libtarget.la \
%D%/server/libserver.la \
%D%/rtos/librtos.la \
%D%/helper/libhelper.la
%D%/helper/libhelper.la \
%D%/rtt/librtt.la

BIN2C = $(srcdir)/%D%/helper/bin2char.sh

Expand Down Expand Up @@ -83,3 +84,4 @@ include %D%/rtos/Makefile.am
include %D%/server/Makefile.am
include %D%/flash/Makefile.am
include %D%/pld/Makefile.am
include %D%/rtt/Makefile.am
7 changes: 7 additions & 0 deletions src/openocd.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@
#include <pld/pld.h>
#include <target/arm_cti.h>
#include <target/arm_adi_v5.h>
#include <rtt/rtt.h>

#include <server/server.h>
#include <server/gdb_server.h>
#include <server/rtt_server.h>

#ifdef HAVE_STRINGS_H
#include <strings.h>
Expand Down Expand Up @@ -247,6 +249,7 @@ struct command_context *setup_command_handler(Jim_Interp *interp)
&server_register_commands,
&gdb_register_commands,
&log_register_commands,
&rtt_server_register_commands,
&transport_register_commands,
&interface_register_commands,
&target_register_commands,
Expand Down Expand Up @@ -338,6 +341,9 @@ int openocd_main(int argc, char *argv[])
if (ioutil_init(cmd_ctx) != ERROR_OK)
return EXIT_FAILURE;

if (rtt_init() != ERROR_OK)
return EXIT_FAILURE;

LOG_OUTPUT("For bug reports, read\n\t"
"http://openocd.org/doc/doxygen/bugs.html"
"\n");
Expand All @@ -363,6 +369,7 @@ int openocd_main(int argc, char *argv[])
/* Shutdown commandline interface */
command_exit(cmd_ctx);

rtt_exit();
free_config();

if (ERROR_FAIL == ret)
Expand Down
2 changes: 2 additions & 0 deletions src/rtt/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
noinst_LTLIBRARIES += %D%/librtt.la
%C%_librtt_la_SOURCES = %D%/rtt.c %D%/rtt.h %D%/tcl.c
Loading