From 26a23dd1cb4a2cf71ee3382ff7ed0983761923fc Mon Sep 17 00:00:00 2001 From: Uwe Bonnes Date: Sat, 7 Nov 2020 17:54:25 +0100 Subject: [PATCH] stlinkv2: Try harder to open an AP. Problem seen on STM32L0 with probably long sleep periods. --- src/platforms/hosted/stlinkv2.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/platforms/hosted/stlinkv2.c b/src/platforms/hosted/stlinkv2.c index 42941c8f..4f180269 100644 --- a/src/platforms/hosted/stlinkv2.c +++ b/src/platforms/hosted/stlinkv2.c @@ -31,6 +31,7 @@ #include "exception.h" #include "jtag_devs.h" #include "target.h" +#include "cortexm.h" #include #include @@ -348,7 +349,8 @@ static int stlink_send_recv_retry(uint8_t *txbuf, size_t txsize, if (res == STLINK_ERROR_OK) return res; uint32_t now = platform_time_ms(); - if (((now - start) > 1000) || (res != STLINK_ERROR_WAIT)) { + if (((now - start) > cortexm_wait_timeout) || + (res != STLINK_ERROR_WAIT)) { DEBUG_WARN("write_retry failed. "); return res; } @@ -829,8 +831,8 @@ static bool stlink_ap_setup(int ap) ap, }; uint8_t data[2]; - send_recv(info.usb_link, cmd, 16, data, 2); DEBUG_PROBE("Open AP %d\n", ap); + stlink_send_recv_retry(cmd, 16, data, 2); int res = stlink_usb_error_check(data, true); if (res) { if (Stlink.ver_hw == 30) {