From 03942f867a0de1eff13828e15b9798a1e589b169 Mon Sep 17 00:00:00 2001 From: Matthias Welwarsky Date: Wed, 13 Jul 2016 11:48:48 +0200 Subject: [PATCH] adi_v5_jtag: clear sticky overrun condition in WAIT timeout If WAIT recovery fails (times out), an ABORT command is issued to the DAP but under some conditions the SSTICKYORUN bit in CTRL/STAT is not cleared as well, which renders the DP unusable. This happens when trying to access e.g. the ROM table of powered-down cores, on many targets. Change-Id: Id0a7ba6180069eee562871314f520f938df9718f Signed-off-by: Matthias Welwarsky Reviewed-on: http://openocd.zylin.com/3476 Tested-by: jenkins Reviewed-by: Andreas Fritiofson --- src/target/adi_v5_jtag.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/target/adi_v5_jtag.c b/src/target/adi_v5_jtag.c index 36d5cad513..2717c9e369 100644 --- a/src/target/adi_v5_jtag.c +++ b/src/target/adi_v5_jtag.c @@ -448,7 +448,12 @@ static int jtagdp_overrun_check(struct adiv5_dap *dap) /* timeout happened */ if (tmp->ack != JTAG_ACK_OK_FAULT) { LOG_ERROR("Timeout during WAIT recovery"); + dap->select = DP_SELECT_INVALID; jtag_ap_q_abort(dap, NULL); + /* clear the sticky overrun condition */ + adi_jtag_scan_inout_check_u32(dap, JTAG_DP_DPACC, + DP_CTRL_STAT, DPAP_WRITE, + dap->dp_ctrl_stat | SSTICKYORUN, NULL, 0); retval = ERROR_JTAG_DEVICE_ERROR; } } @@ -525,8 +530,14 @@ static int jtagdp_overrun_check(struct adiv5_dap *dap) if (retval == ERROR_OK) { if (el->ack != JTAG_ACK_OK_FAULT) { LOG_ERROR("Timeout during WAIT recovery"); + dap->select = DP_SELECT_INVALID; jtag_ap_q_abort(dap, NULL); + /* clear the sticky overrun condition */ + adi_jtag_scan_inout_check_u32(dap, JTAG_DP_DPACC, + DP_CTRL_STAT, DPAP_WRITE, + dap->dp_ctrl_stat | SSTICKYORUN, NULL, 0); retval = ERROR_JTAG_DEVICE_ERROR; + break; } } else break; -- 2.30.2