This is an automated email from Gerrit.

"Tormod Volden <[email protected]>" just uploaded a new patch set to 
Gerrit, which you can find at https://review.openocd.org/c/openocd/+/9201

-- gerrit

commit 6ade47c892e94b372b66a012865a10d8e5586d94
Author: Tormod Volden <[email protected]>
Date:   Sun Nov 2 22:15:31 2025 +0100

    rtt: Add start retry timeout setting
    
    Change-Id: Ie69da3044e6bd54960cfab28ded856f442886742
    Signed-off-by: Tormod Volden <[email protected]>

diff --git a/doc/openocd.texi b/doc/openocd.texi
index 6122d6d90e..ef2724bcb9 100644
--- a/doc/openocd.texi
+++ b/doc/openocd.texi
@@ -9986,6 +9986,13 @@ The start retry interval determines (in milliseconds) 
how often the control
 block search should be retried. The default value of 0 disables retries.
 @end deffn
 
+@deffn {Command} {rtt start_retry_timeout} [duration]
+Display the start retry timeout.
+If @var{duration} is provided, set the start retry timeout.
+The start retry timeout determines (in milliseconds) how long the control
+block search should be continued retried (default: 10000).
+@end deffn
+
 @deffn {Command} {rtt channels}
 Display a list of all channels and their properties.
 @end deffn
diff --git a/src/rtt/rtt.c b/src/rtt/rtt.c
index b092b511b0..102f52f360 100644
--- a/src/rtt/rtt.c
+++ b/src/rtt/rtt.c
@@ -45,6 +45,7 @@ static struct {
 
        unsigned int polling_interval;
        unsigned int start_retry_interval;
+       unsigned int start_retry_timeout;
 } rtt;
 
 int rtt_init(void)
@@ -61,6 +62,7 @@ int rtt_init(void)
 
        rtt.polling_interval = 100;
        rtt.start_retry_interval = 0;
+       rtt.start_retry_timeout = 10000;
 
        return ERROR_OK;
 }
@@ -131,8 +133,6 @@ static int rtt_start_retry_callback(void *user_data)
        return ERROR_OK;
 }
 
-#define RTT_SEARCH_TIMEOUT_MS 10000
-
 int rtt_start(void)
 {
        int ret;
@@ -146,7 +146,7 @@ int rtt_start(void)
        if (!rtt.found_cb || rtt.changed) {
                if (!running_search) {
                        LOG_INFO("rtt: Searching for control block '%s'", 
rtt.id);
-                       search_timeout = timeval_ms() + RTT_SEARCH_TIMEOUT_MS;
+                       search_timeout = timeval_ms() + rtt.start_retry_timeout;
                }
 
                rtt.source.find_cb(rtt.target, &addr, rtt.size, rtt.id,
@@ -335,6 +335,23 @@ int rtt_set_start_retry_interval(unsigned int interval)
        return ERROR_OK;
 }
 
+int rtt_get_start_retry_timeout(unsigned int *timeout)
+{
+       if (!timeout)
+               return ERROR_FAIL;
+
+       *timeout = rtt.start_retry_timeout;
+
+       return ERROR_OK;
+}
+
+int rtt_set_start_retry_timeout(unsigned int timeout)
+{
+       rtt.start_retry_timeout = timeout;
+
+       return ERROR_OK;
+}
+
 int rtt_write_channel(unsigned int channel_index, const uint8_t *buffer,
                size_t *length)
 {
diff --git a/src/rtt/rtt.h b/src/rtt/rtt.h
index a79c48cc53..ce0b813966 100644
--- a/src/rtt/rtt.h
+++ b/src/rtt/rtt.h
@@ -204,6 +204,24 @@ int rtt_get_start_retry_interval(unsigned int *interval);
  */
 int rtt_set_start_retry_interval(unsigned int interval);
 
+/**
+ * Get the start retry timeout.
+ *
+ * @param[out] duration Start retry timeout in milliseconds.
+ *
+ * @returns ERROR_OK on success, an error code on failure.
+ */
+int rtt_get_start_retry_timeout(unsigned int *duration);
+
+/**
+ * Set the start retry timeout.
+ *
+ * @param[in] duration Start retry timeout in milliseconds.
+ *
+ * @returns ERROR_OK on success, an error code on failure.
+ */
+int rtt_set_start_retry_timeout(unsigned int duration);
+
 /**
  * Get whether RTT is configured.
  *
diff --git a/src/rtt/tcl.c b/src/rtt/tcl.c
index 691d22ea8c..9b9be43005 100644
--- a/src/rtt/tcl.c
+++ b/src/rtt/tcl.c
@@ -135,6 +135,38 @@ COMMAND_HANDLER(handle_rtt_start_retry_interval_command)
        return ERROR_OK;
 }
 
+COMMAND_HANDLER(handle_rtt_start_retry_timeout_command)
+{
+       if (CMD_ARGC == 0) {
+               int ret;
+               unsigned int timeout;
+
+               ret = rtt_get_start_retry_timeout(&timeout);
+
+               if (ret != ERROR_OK) {
+                       command_print(CMD, "Failed to get start retry timeout");
+                       return ret;
+               }
+
+               command_print(CMD, "%u ms", timeout);
+       } else if (CMD_ARGC == 1) {
+               int ret;
+               unsigned int timeout;
+
+               COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], timeout);
+               ret = rtt_set_start_retry_timeout(timeout);
+
+               if (ret != ERROR_OK) {
+                       command_print(CMD, "Failed to set start retry timeout");
+                       return ret;
+               }
+       } else {
+               return ERROR_COMMAND_SYNTAX_ERROR;
+       }
+
+       return ERROR_OK;
+}
+
 COMMAND_HANDLER(handle_rtt_channels_command)
 {
        int ret;
@@ -286,6 +318,13 @@ static const struct command_registration 
rtt_subcommand_handlers[] = {
                .help = "show or set start retry interval in ms",
                .usage = "[interval]"
        },
+       {
+               .name = "start_retry_timeout",
+               .handler = handle_rtt_start_retry_timeout_command,
+               .mode = COMMAND_EXEC,
+               .help = "show or set start retry timeout in ms",
+               .usage = "[duration]"
+       },
        {
                .name = "channels",
                .handler = handle_rtt_channels_command,

-- 

Reply via email to