aboutsummaryrefslogtreecommitdiff
path: root/src/target
diff options
context:
space:
mode:
authorTim Newsome <tim@sifive.com>2023-10-11 12:33:38 -0700
committerGitHub <noreply@github.com>2023-10-11 12:33:38 -0700
commit41d1ee3715d0b209d81b226f2e4a44e9cd9ce203 (patch)
treea77b5415bc4a7eacc28dfaf962d6e7ab3a5d2013 /src/target
parent781a626cf7220078e7133cea7595e79b8df4528b (diff)
parenta3db93b1cea56614baf04f8e88742049da9f2f1e (diff)
downloadriscv-openocd-41d1ee3715d0b209d81b226f2e4a44e9cd9ce203.zip
riscv-openocd-41d1ee3715d0b209d81b226f2e4a44e9cd9ce203.tar.gz
riscv-openocd-41d1ee3715d0b209d81b226f2e4a44e9cd9ce203.tar.bz2
Merge pull request #931 from kr-sc/kr-sc/update-examine-messages
target: Update messages connected with `examine`
Diffstat (limited to 'src/target')
-rw-r--r--src/target/target.c28
-rw-r--r--src/target/target.h6
2 files changed, 20 insertions, 14 deletions
diff --git a/src/target/target.c b/src/target/target.c
index 6481dfb..e795f78 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -744,16 +744,22 @@ static int default_check_reset(struct target *target)
* Keep in sync */
int target_examine_one(struct target *target)
{
+ if (target->examine_attempted)
+ LOG_TARGET_INFO(target, "Retry examination.");
+
+ LOG_TARGET_INFO(target, "Examination started.");
+
target_call_event_callbacks(target, TARGET_EVENT_EXAMINE_START);
int retval = target->type->examine(target);
if (retval != ERROR_OK) {
+ LOG_TARGET_ERROR(target, "Examination failed. examine() -> %d", retval);
target_reset_examined(target);
target_call_event_callbacks(target, TARGET_EVENT_EXAMINE_FAIL);
return retval;
}
- LOG_USER("[%s] Target successfully examined.", target_name(target));
+ LOG_TARGET_INFO(target, "Target successfully examined.");
target_set_examined(target);
target_call_event_callbacks(target, TARGET_EVENT_EXAMINE_END);
@@ -772,12 +778,6 @@ static int jtag_enable_callback(enum jtag_event event, void *priv)
return target_examine_one(target);
}
-/* When this is true, it's OK to call examine() again in the hopes that this time
- * it will work. Earlier than that there is probably other initialization that
- * needs to happen (like scanning the JTAG chain) before examine should be
- * called. */
-static bool examine_attempted;
-
/* Targets that correctly implement init + examine, i.e.
* no communication with target during init:
*
@@ -788,8 +788,6 @@ int target_examine(void)
int retval = ERROR_OK;
struct target *target;
- examine_attempted = true;
-
for (target = all_targets; target; target = target->next) {
/* defer examination, but don't skip it */
if (!target->tap->enabled) {
@@ -801,11 +799,11 @@ int target_examine(void)
if (target->defer_examine)
continue;
+ target->examine_attempted = true;
+
int retval2 = target_examine_one(target);
- if (retval2 != ERROR_OK) {
- LOG_WARNING("target %s examination failed", target_name(target));
+ if (retval2 != ERROR_OK)
retval = retval2;
- }
}
return retval;
}
@@ -3066,11 +3064,11 @@ static int handle_target(void *priv)
LOG_TARGET_DEBUG(target, "target_poll() -> %d, next attempt in %dms",
retval, target->backoff.interval);
- if (retval != ERROR_OK && examine_attempted) {
+ if (retval != ERROR_OK && target->examine_attempted) {
target_reset_examined(target);
retval = target_examine_one(target);
if (retval != ERROR_OK) {
- LOG_TARGET_DEBUG(target, "Examination failed. Polling again in %dms",
+ LOG_TARGET_DEBUG(target, "Polling again in %dms",
target->backoff.interval);
return retval;
}
@@ -6268,6 +6266,8 @@ static int target_create(struct jim_getopt_info *goi)
target->halt_issued = false;
+ target->examine_attempted = false;
+
/* initialize trace information */
target->trace_info = calloc(1, sizeof(struct trace));
if (!target->trace_info) {
diff --git a/src/target/target.h b/src/target/target.h
index 8589e17..b3a9b78 100644
--- a/src/target/target.h
+++ b/src/target/target.h
@@ -138,6 +138,12 @@ struct target {
*/
bool examined;
+ /* When this is true, it's OK to call examine() again in the hopes that this time
+ * it will work. Earlier than that there is probably other initialization that
+ * needs to happen (like scanning the JTAG chain) before examine should be
+ * called. */
+ bool examine_attempted;
+
/**
* true if the target is currently running a downloaded
* "algorithm" instead of arbitrary user code. OpenOCD code