From a3817aa2f29ed29c198d5355f1438b8d6075d148 Mon Sep 17 00:00:00 2001 From: dragonmux Date: Sat, 1 Apr 2023 16:45:17 +0100 Subject: [PATCH] riscv_debug: Implemented poll timeouts for halt/resume --- src/target/riscv_debug.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/target/riscv_debug.c b/src/target/riscv_debug.c index bfe98611f69..1d5747a7d17 100644 --- a/src/target/riscv_debug.c +++ b/src/target/riscv_debug.c @@ -747,10 +747,12 @@ static bool riscv_check_error(target_s *const target) static bool riscv_dm_poll_state(riscv_dm_s *const dbg_module, const uint32_t state) { + platform_timeout_s timeout; + platform_timeout_set(&timeout, 500U); /* Poll for the requested state to become set */ uint32_t status = 0; while (!(status & state)) { - if (!riscv_dm_read(dbg_module, RV_DM_STATUS, &status)) + if (!riscv_dm_read(dbg_module, RV_DM_STATUS, &status) || platform_timeout_is_expired(&timeout)) return false; } return true;