This is an automated email from Gerrit. "Tomas Vanek <van...@fbl.cz>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/6753
-- gerrit commit 1157795f9f6cea2b9cfad7d92a5e17114bc7a27c Author: Tomas Vanek <van...@fbl.cz> Date: Wed Nov 24 06:10:19 2021 +0100 Revert "target: reset target examined flag if target::examine() fails" This reverts commit 98d9f1168cbdc59e4c2c0b1f01b225a4df9ad98a. The target examined flag meaning evolved over the years of OpenOCD development and unfortunately different parts of code expect different working models of examined flag. See [1], [2] and [3]. Known regression: 'reset halt' does not work on not responding Cortex-M target. It is serious e.g. for a Kinetis MCU with blank flash. MCU runs in RESET/WDOG loop and cannot neither be stopped nor put under the control of OpenOCD. Based on analyse of the shift of the flag meaning we can also expect problems in old, seldom used and difficult-to-test targets. Revert the commit in favour of not breaking upcoming 0.12 release and address the problem later. Change-Id: Ife4ed61edb09bbb4462ab4c30efde981fe9f485d Link: [1] https://review.openocd.org/gitweb?p=openocd.git;a=commit;h=9ac7cdec82c19481b79f2effcefb7106dd7ade41 Link: [2] 2151: target: reexamine after polling succeeds again | https://review.openocd.org/c/openocd/+/2151 Link: [3] 3076: Add -defer-examine option to target create command | https://review.openocd.org/c/openocd/+/3076 Signed-off-by: Tomas Vanek <van...@fbl.cz> diff --git a/src/target/target.c b/src/target/target.c index ed6f655ea..6e1038f1c 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -717,15 +717,6 @@ static int no_mmu(struct target *target, int *enabled) return ERROR_OK; } -/** - * Reset the @c examined flag for the given target. - * Pure paranoia -- targets are zeroed on allocation. - */ -static inline void target_reset_examined(struct target *target) -{ - target->examined = false; -} - static int default_examine(struct target *target) { target_set_examined(target); @@ -746,12 +737,10 @@ int target_examine_one(struct target *target) int retval = target->type->examine(target); if (retval != ERROR_OK) { - target_reset_examined(target); target_call_event_callbacks(target, TARGET_EVENT_EXAMINE_FAIL); return retval; } - target_set_examined(target); target_call_event_callbacks(target, TARGET_EVENT_EXAMINE_END); return ERROR_OK; @@ -1533,6 +1522,15 @@ static int target_profiling(struct target *target, uint32_t *samples, num_samples, seconds); } +/** + * Reset the @c examined flag for the given target. + * Pure paranoia -- targets are zeroed on allocation. + */ +static void target_reset_examined(struct target *target) +{ + target->examined = false; +} + static int handle_target(void *priv); static int target_init_one(struct command_context *cmd_ctx, @@ -3057,7 +3055,7 @@ static int handle_target(void *priv) /* Target examination could have failed due to unstable connection, * but we set the examined flag anyway to repoll it later */ if (retval != ERROR_OK) { - target_set_examined(target); + target->examined = true; LOG_USER("Examination failed, GDB will be halted. Polling again in %dms", target->backoff.times * polling_interval); return retval; @@ -5310,13 +5308,8 @@ static int jim_target_examine(Jim_Interp *interp, int argc, Jim_Obj *const *argv } int e = target->type->examine(target); - if (e != ERROR_OK) { - target_reset_examined(target); + if (e != ERROR_OK) return JIM_ERR; - } - - target_set_examined(target); - return JIM_OK; } --