From 5924d9f30cd68333d37caa7ac8cad43f036148dc Mon Sep 17 00:00:00 2001 From: Amaury Pouly Date: Wed, 17 May 2023 12:09:32 +0100 Subject: [PATCH] target/riscv-013: clear sticky error when DMI operation fails When a DMI operation does not succeed (either because of a timeout or an error), the specification says that the error in the `op` field is sticky and needs to cleared by writing `dmireset` in `dtmcs`. This is already done for timeouts in increase_dmi_busy_delay but not for errors. Change-Id: I7c5f27a5cf145511a1a8b64a45a586521e1cbe41 Signed-off-by: Amaury Pouly Reviewed-on: https://review.openocd.org/c/openocd/+/7688 Tested-by: jenkins Reviewed-by: Tim Newsome Reviewed-by: Jan Matyas --- src/target/riscv/riscv-013.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/target/riscv/riscv-013.c b/src/target/riscv/riscv-013.c index 4e6c8dc36d..2f4a8fe2e6 100644 --- a/src/target/riscv/riscv-013.c +++ b/src/target/riscv/riscv-013.c @@ -598,6 +598,7 @@ static int dmi_op_timeout(struct target *target, uint32_t *data_in, break; } else { LOG_ERROR("failed %s at 0x%x, status=%d", op_name, address, status); + dtmcontrol_scan(target, DTM_DTMCS_DMIRESET); return ERROR_FAIL; } if (time(NULL) - start > timeout_sec) @@ -630,6 +631,7 @@ static int dmi_op_timeout(struct target *target, uint32_t *data_in, LOG_ERROR("Failed %s (NOP) at 0x%x; status=%d", op_name, address, status); } + dtmcontrol_scan(target, DTM_DTMCS_DMIRESET); return ERROR_FAIL; } if (time(NULL) - start > timeout_sec) -- 2.30.2