Skip to content

Commit

Permalink
riscv_debug: Implemented poll timeouts for halt/resume
Browse files Browse the repository at this point in the history
  • Loading branch information
dragonmux committed Jul 20, 2023
1 parent 142db83 commit fbec35e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/target/riscv_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit fbec35e

Please sign in to comment.