From 1c5cf8023c44605f25b7d9eab9b726a5986bdb75 Mon Sep 17 00:00:00 2001 From: Tim Newsome Date: Tue, 9 May 2023 11:13:29 -0700 Subject: [PATCH] target/riscv: Reset DTM when it reports an error. The error state is sticky, so this has to be done to recover. Change-Id: I589f3cdab0f2351fd25f89951830cbc16c39bd93 Signed-off-by: Tim Newsome --- src/target/riscv/riscv-013.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/target/riscv/riscv-013.c b/src/target/riscv/riscv-013.c index b4e165595..52c1fc1b8 100644 --- a/src/target/riscv/riscv-013.c +++ b/src/target/riscv/riscv-013.c @@ -590,6 +590,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) @@ -598,6 +599,7 @@ static int dmi_op_timeout(struct target *target, uint32_t *data_in, if (status != DMI_STATUS_SUCCESS) { LOG_ERROR("Failed %s at 0x%x; status=%d", op_name, address, status); + dtmcontrol_scan(target, DTM_DTMCS_DMIRESET); return ERROR_FAIL; } @@ -622,6 +624,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)