Trying to use oversized initrd files (20 MB or more) can fail
with the "libusb usb_bulk_send error -1" error message.

To address this problem, we can split the transfer into smaller
chunks and the problem disappears. Effectively, this is a revert
of the older "fel: Increase timeout to 60 seconds instead of
splitting bulk transfers" commmit.

Signed-off-by: Siarhei Siamashka <siarhei.siamas...@gmail.com>
---
 fel.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fel.c b/fel.c
index ed3bf64..965b270 100644
--- a/fel.c
+++ b/fel.c
@@ -73,11 +73,14 @@ static void pr_info(const char *fmt, ...)
        }
 }
 
+static const int AW_USB_MAX_BULK_SEND = 4 * 1024 * 1024; // 4 MiB per bulk 
request
+
 void usb_bulk_send(libusb_device_handle *usb, int ep, const void *data, int 
length)
 {
        int rc, sent;
        while (length > 0) {
-               rc = libusb_bulk_transfer(usb, ep, (void *)data, length, &sent, 
timeout);
+               int len = length < AW_USB_MAX_BULK_SEND ? length : 
AW_USB_MAX_BULK_SEND;
+               rc = libusb_bulk_transfer(usb, ep, (void *)data, len, &sent, 
timeout);
                if (rc != 0) {
                        fprintf(stderr, "libusb usb_bulk_send error %d\n", rc);
                        exit(2);
-- 
2.0.5

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to