Cortexm: Remove forced_halt.
This commit is contained in:
parent
9bb2807706
commit
159196c2ad
|
@ -465,7 +465,7 @@ static bool adiv5_component_probe(ADIv5_AP_t *ap, uint32_t addr, int recursion,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Probe recursively */
|
/* Probe recursively */
|
||||||
res |= adiv5_component_probe(
|
adiv5_component_probe(
|
||||||
ap, addr + (entry & ADIV5_ROM_ROMENTRY_OFFSET),
|
ap, addr + (entry & ADIV5_ROM_ROMENTRY_OFFSET),
|
||||||
recursion + 1, i);
|
recursion + 1, i);
|
||||||
}
|
}
|
||||||
|
@ -524,7 +524,7 @@ static bool adiv5_component_probe(ADIv5_AP_t *ap, uint32_t addr, int recursion,
|
||||||
switch (pidr_pn_bits[i].arch) {
|
switch (pidr_pn_bits[i].arch) {
|
||||||
case aa_cortexm:
|
case aa_cortexm:
|
||||||
DEBUG_INFO("%s-> cortexm_probe\n", indent + 1);
|
DEBUG_INFO("%s-> cortexm_probe\n", indent + 1);
|
||||||
cortexm_probe(ap, false);
|
cortexm_probe(ap);
|
||||||
break;
|
break;
|
||||||
case aa_cortexa:
|
case aa_cortexa:
|
||||||
DEBUG_INFO("\n -> cortexa_probe\n");
|
DEBUG_INFO("\n -> cortexa_probe\n");
|
||||||
|
@ -615,7 +615,6 @@ ADIv5_AP_t *adiv5_new_ap(ADIv5_DP_t *dp, uint8_t apsel)
|
||||||
|
|
||||||
void adiv5_dp_init(ADIv5_DP_t *dp)
|
void adiv5_dp_init(ADIv5_DP_t *dp)
|
||||||
{
|
{
|
||||||
volatile bool probed = false;
|
|
||||||
volatile uint32_t ctrlstat = 0;
|
volatile uint32_t ctrlstat = 0;
|
||||||
adiv5_dp_ref(dp);
|
adiv5_dp_ref(dp);
|
||||||
#if PC_HOSTED == 1
|
#if PC_HOSTED == 1
|
||||||
|
@ -745,12 +744,7 @@ void adiv5_dp_init(ADIv5_DP_t *dp)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* The rest should only be added after checking ROM table */
|
/* The rest should only be added after checking ROM table */
|
||||||
probed |= adiv5_component_probe(ap, ap->base, 0, 0);
|
adiv5_component_probe(ap, ap->base, 0, 0);
|
||||||
if (!probed && (dp->idcode & 0xfff) == 0x477) {
|
|
||||||
DEBUG_INFO("-> cortexm_probe forced\n");
|
|
||||||
cortexm_probe(ap, true);
|
|
||||||
probed = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
adiv5_dp_unref(dp);
|
adiv5_dp_unref(dp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -263,29 +263,7 @@ static void cortexm_priv_free(void *priv)
|
||||||
free(priv);
|
free(priv);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool cortexm_forced_halt(target *t)
|
bool cortexm_probe(ADIv5_AP_t *ap)
|
||||||
{
|
|
||||||
DEBUG_WARN("cortexm_forced_halt\n");
|
|
||||||
target_halt_request(t);
|
|
||||||
platform_srst_set_val(false);
|
|
||||||
uint32_t dhcsr = 0;
|
|
||||||
uint32_t start_time = platform_time_ms();
|
|
||||||
const uint32_t dhcsr_halted_bits = CORTEXM_DHCSR_S_HALT | CORTEXM_DHCSR_S_REGRDY |
|
|
||||||
CORTEXM_DHCSR_C_HALT | CORTEXM_DHCSR_C_DEBUGEN;
|
|
||||||
/* Try hard to halt the target. STM32F7 in WFI
|
|
||||||
needs multiple writes!*/
|
|
||||||
while (platform_time_ms() < start_time + cortexm_wait_timeout) {
|
|
||||||
dhcsr = target_mem_read32(t, CORTEXM_DHCSR);
|
|
||||||
if ((dhcsr & dhcsr_halted_bits) == dhcsr_halted_bits)
|
|
||||||
break;
|
|
||||||
target_halt_request(t);
|
|
||||||
}
|
|
||||||
if ((dhcsr & dhcsr_halted_bits) != dhcsr_halted_bits)
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool cortexm_probe(ADIv5_AP_t *ap, bool forced)
|
|
||||||
{
|
{
|
||||||
target *t;
|
target *t;
|
||||||
|
|
||||||
|
@ -393,14 +371,6 @@ bool cortexm_probe(ADIv5_AP_t *ap, bool forced)
|
||||||
target_check_error(t);
|
target_check_error(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Only force halt if read ROM Table failed and there is no DPv2
|
|
||||||
* targetid!
|
|
||||||
* So long, only STM32L0 is expected to enter this cause.
|
|
||||||
*/
|
|
||||||
if (forced && !ap->dp->targetid)
|
|
||||||
if (!cortexm_forced_halt(t))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
#define PROBE(x) \
|
#define PROBE(x) \
|
||||||
do { if ((x)(t)) {target_halt_resume(t, 0); return true;} else target_check_error(t); } while (0)
|
do { if ((x)(t)) {target_halt_resume(t, 0); return true;} else target_check_error(t); } while (0)
|
||||||
|
|
||||||
|
@ -439,9 +409,6 @@ bool cortexm_attach(target *t)
|
||||||
target_check_error(t);
|
target_check_error(t);
|
||||||
|
|
||||||
target_halt_request(t);
|
target_halt_request(t);
|
||||||
if (!cortexm_forced_halt(t))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
/* Request halt on reset */
|
/* Request halt on reset */
|
||||||
target_mem_write32(t, CORTEXM_DEMCR, priv->demcr);
|
target_mem_write32(t, CORTEXM_DEMCR, priv->demcr);
|
||||||
|
|
||||||
|
@ -475,6 +442,22 @@ bool cortexm_attach(target *t)
|
||||||
target_mem_write32(t, CORTEXM_FPB_CTRL,
|
target_mem_write32(t, CORTEXM_FPB_CTRL,
|
||||||
CORTEXM_FPB_CTRL_KEY | CORTEXM_FPB_CTRL_ENABLE);
|
CORTEXM_FPB_CTRL_KEY | CORTEXM_FPB_CTRL_ENABLE);
|
||||||
|
|
||||||
|
uint32_t dhcsr = target_mem_read32(t, CORTEXM_DHCSR);
|
||||||
|
dhcsr = target_mem_read32(t, CORTEXM_DHCSR);
|
||||||
|
if (dhcsr & CORTEXM_DHCSR_S_RESET_ST) {
|
||||||
|
platform_srst_set_val(false);
|
||||||
|
platform_timeout timeout;
|
||||||
|
platform_timeout_set(&timeout, 1000);
|
||||||
|
while (1) {
|
||||||
|
uint32_t dhcsr = target_mem_read32(t, CORTEXM_DHCSR);
|
||||||
|
if (!(dhcsr & CORTEXM_DHCSR_S_RESET_ST))
|
||||||
|
break;
|
||||||
|
if (platform_timeout_is_expired(&timeout)) {
|
||||||
|
DEBUG_WARN("Error releasing from srst\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -171,7 +171,7 @@ extern long cortexm_wait_timeout;
|
||||||
|
|
||||||
#define CORTEXM_TOPT_INHIBIT_SRST (1 << 2)
|
#define CORTEXM_TOPT_INHIBIT_SRST (1 << 2)
|
||||||
|
|
||||||
bool cortexm_probe(ADIv5_AP_t *ap, bool forced);
|
bool cortexm_probe(ADIv5_AP_t *ap);
|
||||||
ADIv5_AP_t *cortexm_ap(target *t);
|
ADIv5_AP_t *cortexm_ap(target *t);
|
||||||
|
|
||||||
bool cortexm_attach(target *t);
|
bool cortexm_attach(target *t);
|
||||||
|
|
Loading…
Reference in New Issue