From 72b39088ee1772a65e74004fdc096db09edf8c0c Mon Sep 17 00:00:00 2001 From: Antonio Borneo Date: Mon, 8 Apr 2024 17:42:52 +0200 Subject: [PATCH] target: reset examine after assert_reset For some target, the API assert_reset() checks if the target has been examined, with target_was_examined(), to perform conditional operations like: - assert adapter's srst; - write some register to catch the reset vector; - invalidate the register cache. Targets created with -defer-examine gets the examine flag reset right before entering in their assert_reset(), disrupting the actions above. For targets created with -defer-examine, move the reset examine after the assert_reset(). Change-Id: If96e7876dcace8905165115292deb93a3e45cb36 Signed-off-by: Antonio Borneo Reviewed-on: https://review.openocd.org/c/openocd/+/8293 Tested-by: jenkins Reviewed-by: Tomas Vanek --- src/target/target.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/target/target.c b/src/target/target.c index efc168903..7d4947a6e 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -5365,17 +5365,19 @@ COMMAND_HANDLER(handle_target_reset) return ERROR_FAIL; } - if (target->defer_examine) - target_reset_examined(target); - /* determine if we should halt or not. */ target->reset_halt = (a != 0); /* When this happens - all workareas are invalid. */ target_free_all_working_areas_restore(target, 0); /* do the assert */ - if (n->value == NVP_ASSERT) - return target->type->assert_reset(target); + if (n->value == NVP_ASSERT) { + int retval = target->type->assert_reset(target); + if (target->defer_examine) + target_reset_examined(target); + return retval; + } + return target->type->deassert_reset(target); }