From 525b90d4e5d07f431a1d0f4e5d2abf9e6c691e10 Mon Sep 17 00:00:00 2001 From: Uwe Bonnes Date: Mon, 10 Sep 2018 21:40:37 +0200 Subject: [PATCH] cortexm: Only force halt before probe() if probe was forced. --- src/target/adiv5.c | 4 ++-- src/target/cortexm.c | 8 +++++--- src/target/cortexm.h | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/target/adiv5.c b/src/target/adiv5.c index 6831bc0..2439b09 100644 --- a/src/target/adiv5.c +++ b/src/target/adiv5.c @@ -337,7 +337,7 @@ static bool adiv5_component_probe(ADIv5_AP_t *ap, uint32_t addr) switch (pidr_pn_bits[i].arch) { case aa_cortexm: DEBUG("-> cortexm_probe\n"); - cortexm_probe(ap); + cortexm_probe(ap, false); break; case aa_cortexa: DEBUG("-> cortexa_probe\n"); @@ -473,7 +473,7 @@ void adiv5_dp_init(ADIv5_DP_t *dp) probed |= adiv5_component_probe(ap, ap->base); if (!probed && (dp->idcode & 0xfff) == 0x477) { DEBUG("-> cortexm_probe forced\n"); - cortexm_probe(ap); + cortexm_probe(ap, true); probed = true; } } diff --git a/src/target/cortexm.c b/src/target/cortexm.c index 8de881c..891b2bd 100644 --- a/src/target/cortexm.c +++ b/src/target/cortexm.c @@ -264,7 +264,7 @@ static bool cortexm_forced_halt(target *t) return true; } -bool cortexm_probe(ADIv5_AP_t *ap) +bool cortexm_probe(ADIv5_AP_t *ap, bool forced) { target *t; @@ -323,8 +323,10 @@ bool cortexm_probe(ADIv5_AP_t *ap) target_check_error(t); } - if (!cortexm_forced_halt(t)) - return false; + if (forced) + if (!cortexm_forced_halt(t)) + return false; + #define PROBE(x) \ do { if ((x)(t)) {target_halt_resume(t, 0); return true;} else target_check_error(t); } while (0) diff --git a/src/target/cortexm.h b/src/target/cortexm.h index e6362f4..9c763b7 100644 --- a/src/target/cortexm.h +++ b/src/target/cortexm.h @@ -168,7 +168,7 @@ extern long cortexm_wait_timeout; #define CORTEXM_TOPT_INHIBIT_SRST (1 << 2) -bool cortexm_probe(ADIv5_AP_t *ap); +bool cortexm_probe(ADIv5_AP_t *ap, bool forced); ADIv5_AP_t *cortexm_ap(target *t); bool cortexm_attach(target *t);