Skip to content

Commit

Permalink
rtt: default the ID to "SEGGER RTT"
Browse files Browse the repository at this point in the history
Instead of making people type this in all the time, just default to
"SEGGER RTT" so more things work out of the box.

Change-Id: I147142cf0a755e635d3f66e047be2eb5049cf511
Signed-off-by: Karl Palsson <karl.palsson@marel.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8354
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
  • Loading branch information
karlp authored and borneoa committed Aug 25, 2024
1 parent 5cb184a commit e7a0600
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
5 changes: 3 additions & 2 deletions doc/openocd.texi
Original file line number Diff line number Diff line change
Expand Up @@ -9541,11 +9541,12 @@ 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
@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.
ID defaults to the string "SEGGER RTT"
@end deffn

@deffn {Command} {rtt start}
Expand Down Expand Up @@ -9588,7 +9589,7 @@ on the target device.
@example
resume

rtt setup 0x20000000 2048 "SEGGER RTT"
rtt setup 0x20000000 2048
rtt start

rtt server start 9090 0
Expand Down
12 changes: 9 additions & 3 deletions src/rtt/tcl.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@ COMMAND_HANDLER(handle_rtt_setup_command)
{
struct rtt_source source;

if (CMD_ARGC != 3)
const char *DEFAULT_ID = "SEGGER RTT";
const char *selected_id;
if (CMD_ARGC < 2 || CMD_ARGC > 3)
return ERROR_COMMAND_SYNTAX_ERROR;
if (CMD_ARGC == 2)
selected_id = DEFAULT_ID;
else
selected_id = CMD_ARGV[2];

source.find_cb = &target_rtt_find_control_block;
source.read_cb = &target_rtt_read_control_block;
Expand All @@ -38,7 +44,7 @@ COMMAND_HANDLER(handle_rtt_setup_command)

rtt_register_source(source, get_current_target(CMD_CTX));

if (rtt_setup(address, size, CMD_ARGV[2]) != ERROR_OK)
if (rtt_setup(address, size, selected_id) != ERROR_OK)
return ERROR_FAIL;

return ERROR_OK;
Expand Down Expand Up @@ -218,7 +224,7 @@ static const struct command_registration rtt_subcommand_handlers[] = {
.handler = handle_rtt_setup_command,
.mode = COMMAND_ANY,
.help = "setup RTT",
.usage = "<address> <size> <ID>"
.usage = "<address> <size> [ID]"
},
{
.name = "start",
Expand Down

0 comments on commit e7a0600

Please sign in to comment.