Skip to content

Commit

Permalink
adiv5: Reduce spam-polling
Browse files Browse the repository at this point in the history
* Touching DHCSR of a stm32f103 target results in 1.2 ms of
  SWDP_ACK_WAIT packets on wire anyway, so let's sleep for 1 ms
  (especially since SysTick precision allows it)
  • Loading branch information
ALTracer committed Nov 25, 2023
1 parent 9d2ce70 commit 7df4414
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/target/adiv5.c
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,8 @@ static uint32_t cortexm_initial_halt(adiv5_access_port_s *ap)
if ((dhcsr & (CORTEXM_DHCSR_S_HALT | CORTEXM_DHCSR_C_DEBUGEN)) ==
(CORTEXM_DHCSR_S_HALT | CORTEXM_DHCSR_C_DEBUGEN))
return dhcsr;
/* Reduce spam-polling */
platform_delay(1);
}

return 0U;
Expand Down Expand Up @@ -508,6 +510,8 @@ static bool cortexm_prepare(adiv5_access_port_s *ap)
DEBUG_ERROR("Error releasing from reset\n");
return false;
}
/* Reduce spam-polling */
platform_delay(2);
}
/* Core is now in a good state */
return true;
Expand Down Expand Up @@ -922,6 +926,8 @@ void adiv5_dp_init(adiv5_debug_port_s *const dp)
DEBUG_WARN("adiv5: power-down failed\n");
break;
}
/* Reduce spam-polling */
platform_delay(3);
}

platform_timeout_set(&timeout, 201);
Expand Down
3 changes: 3 additions & 0 deletions src/target/adiv5_swd.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,9 @@ uint32_t firmware_swdp_low_access(adiv5_debug_port_s *dp, const uint8_t RnW, con
ADIV5_DP_ABORT_ORUNERRCLR | ADIV5_DP_ABORT_WDERRCLR | ADIV5_DP_ABORT_STKERRCLR |
ADIV5_DP_ABORT_STKCMPCLR);
}
/* Reduce spam-polling on SWDP WAIT */
if (ack == SWDP_ACK_WAIT)
platform_delay(1);
} while ((ack == SWDP_ACK_WAIT || ack == SWDP_ACK_FAULT) && !platform_timeout_is_expired(&timeout));

if (ack == SWDP_ACK_WAIT) {
Expand Down

0 comments on commit 7df4414

Please sign in to comment.