diff --git a/src/platforms/common/jtagtap.c b/src/platforms/common/jtagtap.c index ab91c55a197..b8eca99b525 100644 --- a/src/platforms/common/jtagtap.c +++ b/src/platforms/common/jtagtap.c @@ -53,8 +53,12 @@ void jtagtap_init(void) jtag_proc.tap_idle_cycles = 1; /* Ensure we're in JTAG mode */ +#if 1 + jtagtap_cycle(true, false, 51U); +#else for (size_t i = 0; i <= 50U; ++i) jtagtap_next(true, false); /* 50 + 1 idle cycles for SWD reset */ +#endif jtagtap_tms_seq(0xe73cU, 16U); /* SWD to JTAG sequence */ } @@ -100,8 +104,10 @@ static bool jtagtap_next_no_delay() __attribute__((optimize(3))); static bool jtagtap_next_no_delay() { gpio_set(TCK_PORT, TCK_PIN); + __asm__("nop" ::: "memory"); const uint16_t result = gpio_get(TDO_PORT, TDO_PIN); gpio_clear(TCK_PORT, TCK_PIN); + __asm__("nop" ::: "memory"); return result != 0; } @@ -327,6 +333,7 @@ static void jtagtap_cycle_no_delay(const size_t clock_cycles) gpio_set(TCK_PORT, TCK_PIN); __asm__ volatile("nop" ::: "memory"); gpio_clear(TCK_PORT, TCK_PIN); + __asm__ volatile("nop" ::: "memory"); } }