From e7a060090ee82bc6904338df54740c4331926ec4 Mon Sep 17 00:00:00 2001 From: Karl Palsson Date: Tue, 16 Jan 2024 13:52:56 +0000 Subject: [PATCH] rtt: default the ID to "SEGGER RTT" 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 Reviewed-on: https://review.openocd.org/c/openocd/+/8354 Tested-by: jenkins Reviewed-by: Antonio Borneo --- doc/openocd.texi | 5 +++-- src/rtt/tcl.c | 12 +++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/doc/openocd.texi b/doc/openocd.texi index db787fdb2..dee431301 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -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} @@ -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 diff --git a/src/rtt/tcl.c b/src/rtt/tcl.c index 2b8822fce..bae71b6ce 100644 --- a/src/rtt/tcl.c +++ b/src/rtt/tcl.c @@ -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; @@ -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; @@ -218,7 +224,7 @@ static const struct command_registration rtt_subcommand_handlers[] = { .handler = handle_rtt_setup_command, .mode = COMMAND_ANY, .help = "setup RTT", - .usage = "
" + .usage = "
[ID]" }, { .name = "start",