Commit d3e860b0 authored by Bernhard Nortmann's avatar Bernhard Nortmann
Browse files

fel: Lower timeout to a more practical value



The previous timeout of 60 seconds was mostly based on scenarios
where large ("write") transfers take place. But it could easily
become annoying if users are awaiting completion of simpler
commands like "read" or "hexdump", and for some reason FEL fails
to respond.

Therefore I've decided to lower the timeout value to 10 seconds,
adjust the maximum chunk size accordingly and - while at it -
improve the source comments documenting their relationship.
Signed-off-by: default avatarBernhard Nortmann <bernhard.nortmann@web.de>
parent dc1b5889
......@@ -77,7 +77,8 @@ static const int AW_USB_WRITE = 0x12;
static int AW_USB_FEL_BULK_EP_OUT;
static int AW_USB_FEL_BULK_EP_IN;
static int timeout = 60000;
static int timeout = 10000; /* 10 seconds */
static bool verbose = false; /* If set, makes the 'fel' tool more talkative */
static uint32_t uboot_entry = 0; /* entry point (address) of U-Boot */
static uint32_t uboot_size = 0; /* size of U-Boot binary */
......@@ -92,7 +93,16 @@ static void pr_info(const char *fmt, ...)
}
}
static const int AW_USB_MAX_BULK_SEND = 4 * 1024 * 1024; /* 4 MiB per bulk request */
/*
* AW_USB_MAX_BULK_SEND and the timeout constant are related.
* Both need to be selected in a way that transferring the maximum chunk size
* with (SoC-specific) slow transfer speed won't time out.
*
* The 512 KiB here are chosen based on the assumption that we want a 10 seconds
* timeout, and "slow" transfers take place at approx. 64 KiB/sec - so we can
* expect the maximum chunk being transmitted within 8 seconds or less.
*/
static const int AW_USB_MAX_BULK_SEND = 512 * 1024; /* 512 KiB per bulk request */
void usb_bulk_send(libusb_device_handle *usb, int ep, const void *data,
size_t length, bool progress)
......@@ -101,6 +111,7 @@ void usb_bulk_send(libusb_device_handle *usb, int ep, const void *data,
* With no progress notifications, we'll use the maximum chunk size.
* Otherwise, it's useful to lower the size (have more chunks) to get
* more frequent status updates. 128 KiB per request seem suitable.
* (Worst case of "slow" transfers -> one update every two seconds.)
*/
size_t max_chunk = progress ? 128 * 1024 : AW_USB_MAX_BULK_SEND;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment