|
From: openocd-gerrit <ope...@us...> - 2026-05-17 20:53:37
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Main OpenOCD repository".
The branch, master has been updated
via 0e901c561f238fff70ab1423600af6d706fd603c (commit)
via af6c19d59db1dc123e7628165166f15772b80714 (commit)
from 822ac747877426b192fd45b62537d6436d30c0c9 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 0e901c561f238fff70ab1423600af6d706fd603c
Author: Tomas Vanek <va...@fb...>
Date: Tue Apr 28 17:14:46 2026 +0200
target: rename srst_asserted and power_dropout variables
Add sensed_ prefix to make sure the variables are not
mismatched mainly with the active srst control ones.
While on it update sense_handler() comment
No functional change.
int type variables misused as a bool left as is.
Change-Id: I208196b59588acab2da38602449d5666f5e0395f
Signed-off-by: Tomas Vanek <va...@fb...>
Reviewed-on: https://review.openocd.org/c/openocd/+/9604
Tested-by: jenkins
Reviewed-by: Antonio Borneo <bor...@gm...>
diff --git a/src/target/target.c b/src/target/target.c
index f862fae7c..f8cb7e483 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -2807,10 +2807,10 @@ COMMAND_HANDLER(handle_targets_command)
return retval;
}
-/* every 300ms we check for reset & powerdropout and issue a "reset halt" if so. */
+/* every polling_interval we check for reset & powerdropout */
-static int power_dropout;
-static int srst_asserted;
+static int sensed_power_dropout;
+static int sensed_srst_asserted;
static int run_power_restore;
static int run_power_dropout;
@@ -2822,29 +2822,29 @@ static int sense_handler(void)
static int prev_srst_asserted;
static int prev_power_dropout;
- int retval = jtag_power_dropout(&power_dropout);
+ int retval = jtag_power_dropout(&sensed_power_dropout);
if (retval != ERROR_OK)
return retval;
int power_restored;
- power_restored = prev_power_dropout && !power_dropout;
+ power_restored = prev_power_dropout && !sensed_power_dropout;
if (power_restored)
run_power_restore = 1;
int64_t current = timeval_ms();
static int64_t last_power;
bool wait_more = last_power + 2000 > current;
- if (power_dropout && !wait_more) {
+ if (sensed_power_dropout && !wait_more) {
run_power_dropout = 1;
last_power = current;
}
- retval = jtag_srst_asserted(&srst_asserted);
+ retval = jtag_srst_asserted(&sensed_srst_asserted);
if (retval != ERROR_OK)
return retval;
int srst_deasserted;
- srst_deasserted = prev_srst_asserted && !srst_asserted;
+ srst_deasserted = prev_srst_asserted && !sensed_srst_asserted;
static int64_t last_srst;
wait_more = last_srst + 2000 > current;
@@ -2853,11 +2853,11 @@ static int sense_handler(void)
last_srst = current;
}
- if (!prev_srst_asserted && srst_asserted)
+ if (!prev_srst_asserted && sensed_srst_asserted)
run_srst_asserted = 1;
- prev_srst_asserted = srst_asserted;
- prev_power_dropout = power_dropout;
+ prev_srst_asserted = sensed_srst_asserted;
+ prev_power_dropout = sensed_power_dropout;
if (srst_deasserted || power_restored) {
/* Other than logging the event we can't do anything here.
@@ -2937,7 +2937,7 @@ static int handle_target(void *priv)
recursive = 0;
}
- if (power_dropout || srst_asserted)
+ if (sensed_power_dropout || sensed_srst_asserted)
return ERROR_OK;
int retval = ERROR_OK;
commit af6c19d59db1dc123e7628165166f15772b80714
Author: Tim Newsome <ti...@si...>
Date: Thu Oct 21 17:08:49 2021 -0700
target: base poll frequency on wall time
Replaces code that would count number of invocations.
This is based on [1].
The behavior is changed, namely:
* `TARGET_EVENT_GDB_HALT` is not called -- the user can hit Ctrl-C if he
needs to halt the target, this use of the callback seems
counterintuitive. See [2].
* There is no early-exit when re-examining the target fails -- there are
still other targets that need to be processed.
1: https://github.com/riscv/riscv-openocd/pull/727
2: https://github.com/riscv-collab/riscv-openocd/commit/21433e83eeda7
Change-Id: Id865f191f0fbb48abece8b8558cc9fa2041a26df
Signed-off-by: Tim Newsome <ti...@si...>
Reviewed-on: https://review.openocd.org/c/openocd/+/6964
Reviewed-by: Tomas Vanek <va...@fb...>
Tested-by: jenkins
Reviewed-by: Antonio Borneo <bor...@gm...>
diff --git a/src/target/target.c b/src/target/target.c
index 6a21280fc..f862fae7c 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -118,7 +118,7 @@ static struct target_timer_callback *target_timer_callbacks;
static int64_t target_timer_next_event_value;
static OOCD_LIST_HEAD(target_reset_callback_list);
static OOCD_LIST_HEAD(target_trace_callback_list);
-static const int polling_interval = TARGET_DEFAULT_POLLING_INTERVAL;
+static const unsigned int polling_interval = TARGET_DEFAULT_POLLING_INTERVAL;
static OOCD_LIST_HEAD(empty_smp_targets);
enum nvp_assert {
@@ -2869,11 +2869,24 @@ static int sense_handler(void)
return ERROR_OK;
}
+static int handle_one_target(struct target *target)
+{
+ if (!target_active_polled(target) || !target->tap->enabled)
+ return ERROR_OK;
+
+ int res = target_poll(target);
+ if (res == ERROR_OK)
+ return res;
+
+ LOG_TARGET_ERROR(target, "Polling failed, trying to reexamine");
+ target_reset_examined(target);
+ return target_examine_one(target);
+}
+
/* process target state changes */
static int handle_target(void *priv)
{
Jim_Interp *interp = (Jim_Interp *)priv;
- int retval = ERROR_OK;
if (!is_jtag_poll_safe()) {
/* polling is disabled currently */
@@ -2924,56 +2937,34 @@ static int handle_target(void *priv)
recursive = 0;
}
+ if (power_dropout || srst_asserted)
+ return ERROR_OK;
+
+ int retval = ERROR_OK;
/* Poll targets for state changes unless that's globally disabled.
* Skip targets that are currently disabled.
*/
for (struct target *target = all_targets;
is_jtag_poll_safe() && target;
target = target->next) {
-
- if (!target_active_polled(target))
- continue;
-
- if (!target->tap->enabled)
- continue;
-
- if (target->backoff.times > target->backoff.count) {
- /* do not poll this time as we failed previously */
- target->backoff.count++;
+ /* This function only gets called every polling_interval, so
+ * allow some slack in the time comparison. Otherwise, if we
+ * schedule for now+polling_interval, the next poll won't
+ * actually happen until a polling_interval later. */
+ if (timeval_ms() + polling_interval / 2 < target->backoff.next_attempt)
continue;
- }
- target->backoff.count = 0;
- /* only poll target if we've got power and srst isn't asserted */
- if (!power_dropout && !srst_asserted) {
- /* polling may fail silently until the target has been examined */
- retval = target_poll(target);
- if (retval != ERROR_OK) {
- /* 100ms polling interval. Increase interval between polling up to 5000ms */
- if (target->backoff.times * polling_interval < 5000) {
- target->backoff.times *= 2;
- target->backoff.times++;
- }
-
- /* Tell GDB to halt the debugger. This allows the user to
- * run monitor commands to handle the situation.
- */
- target_call_event_callbacks(target, TARGET_EVENT_GDB_HALT);
- }
- if (target->backoff.times > 0) {
- LOG_TARGET_ERROR(target, "Polling failed, trying to reexamine");
- target_reset_examined(target);
- retval = target_examine_one(target);
- if (retval != ERROR_OK) {
- LOG_TARGET_ERROR(target, "Examination failed, GDB will be halted. Polling again in %dms",
- target->backoff.times * polling_interval);
- return retval;
- }
- }
-
- /* Since we succeeded, we reset backoff count */
- target->backoff.times = 0;
+ int tgt_res = handle_one_target(target);
+ if (tgt_res != ERROR_OK) {
+ retval = tgt_res;
+ target->backoff.interval = MAX(polling_interval,
+ MIN(target->backoff.interval * 2u + 1u, TARGET_MAX_POLLING_INTERVAL_MS));
+ } else {
+ target->backoff.interval = polling_interval;
}
+ target->backoff.next_attempt = timeval_ms() + target->backoff.interval;
+ LOG_TARGET_DEBUG_IO(target, "target_poll() -> %d, next attempt in %ums",
+ tgt_res, target->backoff.interval);
}
return retval;
diff --git a/src/target/target.h b/src/target/target.h
index eb4d27a33..ce1fc728b 100644
--- a/src/target/target.h
+++ b/src/target/target.h
@@ -105,8 +105,8 @@ struct gdb_service {
/* target back off timer */
struct backoff_timer {
- int times;
- int count;
+ int64_t next_attempt;
+ unsigned int interval;
};
/* split target registers into multiple class */
@@ -193,6 +193,9 @@ struct target {
struct rtos *rtos; /* Instance of Real Time Operating System support */
bool rtos_auto_detect; /* A flag that indicates that the RTOS has been specified as "auto"
* and must be detected when symbols are offered */
+ /* Track when next to poll(). If polling is failing, we don't want to
+ * poll too quickly because we'll just overwhelm the user with error
+ * messages. */
struct backoff_timer backoff;
unsigned int smp; /* Unique non-zero number for each SMP group */
struct list_head *smp_targets; /* list all targets in this smp group/cluster
@@ -826,7 +829,8 @@ int target_profiling_default(struct target *target, uint32_t *samples, uint32_t
extern bool get_target_reset_nag(void);
-#define TARGET_DEFAULT_POLLING_INTERVAL 100
+#define TARGET_DEFAULT_POLLING_INTERVAL 100u
+#define TARGET_MAX_POLLING_INTERVAL_MS 5000u
const char *target_debug_reason_str(enum target_debug_reason reason);
-----------------------------------------------------------------------
Summary of changes:
src/target/target.c | 99 ++++++++++++++++++++++++-----------------------------
src/target/target.h | 10 ++++--
2 files changed, 52 insertions(+), 57 deletions(-)
hooks/post-receive
--
Main OpenOCD repository
|