From 8832d4be97ee4291f1f06ae06d69f35902305ab8 Mon Sep 17 00:00:00 2001 From: Tim Newsome Date: Tue, 13 Sep 2022 10:17:56 -0700 Subject: [PATCH] Add error message when dmstatus read times out. Otherwise OpenOCD simply doesn't work without giving any indication why. Change-Id: I21703fc1a0d9bed2f59da95f8a8395fe139484a4 Signed-off-by: Tim Newsome --- src/target/riscv/riscv-013.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/target/riscv/riscv-013.c b/src/target/riscv/riscv-013.c index 24895e9ef..a2d887e0b 100644 --- a/src/target/riscv/riscv-013.c +++ b/src/target/riscv/riscv-013.c @@ -701,8 +701,14 @@ int dmstatus_read_timeout(struct target *target, uint32_t *dmstatus, int dmstatus_read(struct target *target, uint32_t *dmstatus, bool authenticated) { - return dmstatus_read_timeout(target, dmstatus, authenticated, + int result = dmstatus_read_timeout(target, dmstatus, authenticated, riscv_command_timeout_sec); + if (result == ERROR_TIMEOUT_REACHED) + LOG_TARGET_ERROR(target, "DMSTATUS read didn't complete in %d seconds. The target is " + "either really slow or broken. You could increase the " + "timeout with `riscv set_command_timeout_sec`.", + riscv_command_timeout_sec); + return result; } static void increase_ac_busy_delay(struct target *target)