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 <tim@sifive.com>
This commit is contained in:
Tim Newsome 2022-10-03 10:55:02 -07:00
parent 550a66e720
commit d4c92a5ac7
1 changed files with 8 additions and 2 deletions

View File

@ -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);