This is an automated email from Gerrit. "Tomas Vanek <van...@fbl.cz>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/6745
-- gerrit commit 8f20c8a4c04d0539adf3290463237dd8ec788346 Author: Tomas Vanek <van...@fbl.cz> Date: Tue Nov 23 10:06:51 2021 +0100 target/cortex_m: make reset robust again [WIP] After merging [1] 'reset halt' does not work on not responding Cortex-M. Relax the examined tests and try to set vector catch VC_CORERESET if debug_ap is available. Try to re-examine after reset deassert. [1] 98d9f1168cbd (target: reset target examined flag if target::examine() fails) Change-Id: Ie2e018610026180af5997d70231061a275f05c76 Signed-off-by: Tomas Vanek <van...@fbl.cz> diff --git a/src/target/cortex_m.c b/src/target/cortex_m.c index 721cf0a24..ca4110e95 100644 --- a/src/target/cortex_m.c +++ b/src/target/cortex_m.c @@ -1401,8 +1401,9 @@ static int cortex_m_assert_reset(struct target *target) struct armv7m_common *armv7m = &cortex_m->armv7m; enum cortex_m_soft_reset_config reset_config = cortex_m->soft_reset_config; - LOG_DEBUG("target->state: %s", - target_state_name(target)); + LOG_DEBUG("target->state: %s,%s examined", + target_state_name(target), + target_was_examined(target) ? "" : " not"); enum reset_types jtag_reset_config = jtag_get_reset_config(); @@ -1421,14 +1422,14 @@ static int cortex_m_assert_reset(struct target *target) bool srst_asserted = false; - if (!target_was_examined(target)) { + if (!armv7m->debug_ap) { if (jtag_reset_config & RESET_HAS_SRST) { adapter_assert_reset(); if (target->reset_halt) - LOG_ERROR("Target not examined, will not halt after reset!"); + LOG_ERROR("Debug AP not available, will not halt after reset!"); return ERROR_OK; } else { - LOG_ERROR("Target not examined, reset NOT asserted!"); + LOG_ERROR("Debug AP not available, reset NOT asserted!"); return ERROR_FAIL; } } @@ -1539,7 +1540,7 @@ static int cortex_m_assert_reset(struct target *target) if (retval != ERROR_OK) return retval; - if (target->reset_halt) { + if (target->reset_halt && target_was_examined(target)) { retval = target_halt(target); if (retval != ERROR_OK) return retval; @@ -1552,8 +1553,9 @@ static int cortex_m_deassert_reset(struct target *target) { struct armv7m_common *armv7m = &target_to_cm(target)->armv7m; - LOG_DEBUG("target->state: %s", - target_state_name(target)); + LOG_DEBUG("target->state: %s,%s examined", + target_state_name(target), + target_was_examined(target) ? "" : " not"); /* deassert reset lines */ adapter_deassert_reset(); @@ -1562,7 +1564,7 @@ static int cortex_m_deassert_reset(struct target *target) if ((jtag_reset_config & RESET_HAS_SRST) && !(jtag_reset_config & RESET_SRST_NO_GATING) && - target_was_examined(target)) { + armv7m->debug_ap) { int retval = dap_dp_init_or_reconnect(armv7m->debug_ap->dap); if (retval != ERROR_OK) { @@ -1571,6 +1573,9 @@ static int cortex_m_deassert_reset(struct target *target) } } + if (!target_was_examined(target) && !target->defer_examine)) + target_examine_one(target); + return ERROR_OK; } --