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 <karl.palsson@marel.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8354
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
This commit is contained in:
Karl Palsson 2024-01-16 13:52:56 +00:00 committed by Antonio Borneo
parent 5cb184a732
commit e7a060090e
2 changed files with 12 additions and 5 deletions

View File

@ -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 assigned to each channel to make them accessible to an unlimited number
of TCP/IP connections. 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. Configure RTT for the currently selected target.
Once RTT is started, OpenOCD searches for a control block with the 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 identifier @var{ID} starting at the memory address @var{address} within the next
@var{size} bytes. @var{size} bytes.
ID defaults to the string "SEGGER RTT"
@end deffn @end deffn
@deffn {Command} {rtt start} @deffn {Command} {rtt start}
@ -9588,7 +9589,7 @@ on the target device.
@example @example
resume resume
rtt setup 0x20000000 2048 "SEGGER RTT" rtt setup 0x20000000 2048
rtt start rtt start
rtt server start 9090 0 rtt server start 9090 0

View File

@ -19,8 +19,14 @@ COMMAND_HANDLER(handle_rtt_setup_command)
{ {
struct rtt_source source; 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; 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.find_cb = &target_rtt_find_control_block;
source.read_cb = &target_rtt_read_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)); 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_FAIL;
return ERROR_OK; return ERROR_OK;
@ -218,7 +224,7 @@ static const struct command_registration rtt_subcommand_handlers[] = {
.handler = handle_rtt_setup_command, .handler = handle_rtt_setup_command,
.mode = COMMAND_ANY, .mode = COMMAND_ANY,
.help = "setup RTT", .help = "setup RTT",
.usage = "<address> <size> <ID>" .usage = "<address> <size> [ID]"
}, },
{ {
.name = "start", .name = "start",