diff options
author | Gabor Csapo <gaborcsapo@google.com> | 2022-03-18 18:11:49 +0800 |
---|---|---|
committer | Antonio Borneo <borneo.antonio@gmail.com> | 2022-04-03 20:12:03 +0000 |
commit | f0d8c3b0e024d045262ba50a516a3bd66bf22686 (patch) | |
tree | 6c1d9ef087a4d2c889a430c559bb980abbcd2363 /src/jtag/drivers/libusb_helper.h | |
parent | 017d3ddafbfac459a799f7e60613312c61fa3195 (diff) | |
download | riscv-openocd-f0d8c3b0e024d045262ba50a516a3bd66bf22686.zip riscv-openocd-f0d8c3b0e024d045262ba50a516a3bd66bf22686.tar.gz riscv-openocd-f0d8c3b0e024d045262ba50a516a3bd66bf22686.tar.bz2 |
libusb_helper.h: Increase USB timeout
When we debug a target that works as a USB device, halting
the target causes the USB communication with the USB host to
become unresponsive. The host will try to reconnect/reset/setup
the unresponsive device during which communication with other
devices on the same USB bus can get stalled for several seconds.
If the JTAG adapter is on the same bus, we need to make sure
openOCD will wait for packets at least as long as the host USB
stack. Otherwise the USB stack might deliver a valid packet, but
openOCD would ignore it due to the timeout. The xHCI spec uses 5
sec timeouts, so let's use that in openOCD with some margin.
Use this value in all libusb calls. HID API might have a libusb
backend and would probably be victim to the same bug, so it
should use this timeout, too.
Ticket: https://sourceforge.net/p/openocd/tickets/343/
Signed-off-by: Gabor Csapo <gaborcsapo@google.com>
Change-Id: Ia3dc1356e676fe550f57a4c72f7a24ba296b6af2
Reviewed-on: https://review.openocd.org/c/openocd/+/6882
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Diffstat (limited to 'src/jtag/drivers/libusb_helper.h')
-rw-r--r-- | src/jtag/drivers/libusb_helper.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/jtag/drivers/libusb_helper.h b/src/jtag/drivers/libusb_helper.h index 2ddb246..9d51464 100644 --- a/src/jtag/drivers/libusb_helper.h +++ b/src/jtag/drivers/libusb_helper.h @@ -22,6 +22,20 @@ #include <libusb.h> +/* When we debug a target that works as a USB device, halting the target causes the + * USB communication with the USB host to become unresponsive. The host will try + * to reconnect/reset/setup the unresponsive device during which communication + * with other devices on the same USB bus can get stalled for several seconds. + * If the JTAG adapter is on the same bus, we need to make sure openOCD will wait + * for packets at least as long as the host USB stack. Otherwise the USB stack + * might deliver a valid packet, but openOCD would ignore it due to the timeout. + * The xHCI spec uses 5 sec timeouts, so let's use that in openOCD with some margin. + * + * Use this value in all libusb calls. HID API might have a libusb backend and + * would probably be victim to the same bug, so it should use this timeout, too. + */ +#define LIBUSB_TIMEOUT_MS (6000) + /* this callback should return a non NULL value only when the serial could not * be retrieved by the standard 'libusb_get_string_descriptor_ascii' */ typedef char * (*adapter_get_alternate_serial_fn)(struct libusb_device_handle *device, |