summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Rigby <john.rigby@linaro.org>2012-08-01 15:50:55 -0600
committerJohn Rigby <john.rigby@linaro.org>2012-08-01 15:58:30 -0600
commit870a05851d23d3a697f37596569beb09663cc8e1 (patch)
tree9a77be0a57e681e9c4410a76ac2306d721d46f7b
parent27d77171a1b9f0caa60bd8aa310381bacaadf054 (diff)
throttle usb downloadHEADmaster
to work around what seems to be a musb fifo overrun on some panda versions Signed-off-by: John Rigby <john.rigby@linaro.org>
-rw-r--r--usbboot.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/usbboot.c b/usbboot.c
index bafcccf..da75498 100644
--- a/usbboot.c
+++ b/usbboot.c
@@ -36,6 +36,15 @@
#include "usb.h"
+void throttled_usb_write(void *usb, void *data, int sz)
+{
+ while (sz > 0) {
+ usb_write(usb, data, 64);
+ data += 64;
+ sz -= 64;
+ }
+}
+
int usb_boot(usb_handle * usb,
void *data1, unsigned sz1, void *data2, unsigned sz2)
{
@@ -99,7 +108,7 @@ int usb_boot(usb_handle * usb,
}
sleep(1);
fprintf(stderr, "transferring %d bytes of data\n", sz2);
- usb_write(usb, data2, sz2);
+ throttled_usb_write(usb, data2, sz2);
fprintf(stderr, "write finished, waiting for \"OKAY\"\n");
usb_read(usb, response, sizeof(response));
if (strncmp("OKAY", response, 4) == 0) {