aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Newsome <tim@sifive.com>2022-10-03 10:55:02 -0700
committerTim Newsome <tim@sifive.com>2022-10-04 13:36:18 -0700
commitd4c92a5ac7d17f6a0a178d1b4450244e1e3811a9 (patch)
treefbe5a59d5d7d02a1cb0bc9c9864306209aa6aeb0
parent550a66e72094bc59b33fd2f020bf78acf731f60c (diff)
downloadriscv-openocd-d4c92a5ac7d17f6a0a178d1b4450244e1e3811a9.zip
riscv-openocd-d4c92a5ac7d17f6a0a178d1b4450244e1e3811a9.tar.gz
riscv-openocd-d4c92a5ac7d17f6a0a178d1b4450244e1e3811a9.tar.bz2
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>
-rw-r--r--src/target/target.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/target/target.c b/src/target/target.c
index 927329a..56607a1 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);