diff --git a/src/jtag/drivers/mpsse.c b/src/jtag/drivers/mpsse.c index 06d008b47..6c70be6ad 100644 --- a/src/jtag/drivers/mpsse.c +++ b/src/jtag/drivers/mpsse.c @@ -22,6 +22,7 @@ #include "mpsse.h" #include "helper/log.h" +#include "helper/time_support.h" #include /* Compatibility define for older libusb-1.0 */ @@ -892,6 +893,7 @@ int mpsse_flush(struct mpsse_ctx *ctx) } /* Polling loop, more or less taken from libftdi */ + int64_t start = timeval_ms(); while (!write_result.done || !read_result.done) { struct timeval timeout_usb; @@ -914,6 +916,11 @@ int mpsse_flush(struct mpsse_ctx *ctx) break; } } + + if (timeval_ms() - start > 2000) { + LOG_ERROR("Timed out handling USB events in mpsse_flush()."); + break; + } } error_check: