From d4c92a5ac7d17f6a0a178d1b4450244e1e3811a9 Mon Sep 17 00:00:00 2001 From: Tim Newsome Date: Mon, 3 Oct 2022 10:55:02 -0700 Subject: [PATCH] target: Try to examine unexamined target in halt() Some targets fail to examine during `init`, e.g. for timing reasons. The right solution is a better config script, but that ends up being complicated to figure out. This is a bit of a hack, but hopefully silently fixes the problem so users won't have to deal with it at all. Change-Id: Ib04d0680eb4136f06c383caa6775dd2581a08ce0 Signed-off-by: Tim Newsome --- src/target/target.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/target/target.c b/src/target/target.c index 927329a64..56607a114 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -589,8 +589,14 @@ int target_halt(struct target *target) int retval; /* We can't poll until after examine */ if (!target_was_examined(target)) { - LOG_ERROR("Target not examined yet"); - return ERROR_FAIL; + /* Try to examine the target right now, in case the target we're + * talking to didn't examine correctly during `init`. */ + LOG_TARGET_INFO(target, "Try to examine unexamined target in target_halt()."); + target_examine(); + if (!target_was_examined(target)) { + LOG_ERROR("Target not examined yet"); + return ERROR_FAIL; + } } retval = target->type->halt(target);