diff options
author | Megan Wachs <megan@sifive.com> | 2018-09-18 09:36:19 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-18 09:36:19 -0700 |
commit | 35eed36ffdd082f5abfc16d4cc93511f6e225284 (patch) | |
tree | d41422aa6abcedbbb838d4e2a75f866b0831f849 | |
parent | 933cb875a8fb6243df52208c725b1c6ebc9662e3 (diff) | |
parent | d6a1e27c89fefe7a199a00520ab55201ac7e7edd (diff) | |
download | riscv-openocd-35eed36ffdd082f5abfc16d4cc93511f6e225284.zip riscv-openocd-35eed36ffdd082f5abfc16d4cc93511f6e225284.tar.gz riscv-openocd-35eed36ffdd082f5abfc16d4cc93511f6e225284.tar.bz2 |
Merge pull request #301 from riscv/mpsse_flush
Add wall clock timeout to mpsse_flush()
-rw-r--r-- | src/jtag/drivers/mpsse.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/jtag/drivers/mpsse.c b/src/jtag/drivers/mpsse.c index 06d008b..6c70be6 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 <libusb.h> /* 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: |