]> git.sur5r.net Git - u-boot/blobdiff - cmd/dfu.c
dfu: usb: f_dfu: Set deferred call for dfu_flush() function
[u-boot] / cmd / dfu.c
index 6d95ce922312af4dd4d303fceeddd7d751e36ff4..d8aae262232e82a066ae83ea0e82057e41f26c26 100644 (file)
--- a/cmd/dfu.c
+++ b/cmd/dfu.c
@@ -79,6 +79,26 @@ static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                if (ctrlc())
                        goto exit;
 
+               if (dfu_get_defer_flush()) {
+                       /*
+                        * Call to usb_gadget_handle_interrupts() is necessary
+                        * to act on ZLP OUT transaction from HOST PC after
+                        * transmitting the whole file.
+                        *
+                        * If this ZLP OUT packet is NAK'ed, the HOST libusb
+                        * function fails after timeout (by default it is set to
+                        * 5 seconds). In such situation the dfu-util program
+                        * exits with error message.
+                        */
+                       usb_gadget_handle_interrupts(controller_index);
+                       ret = dfu_flush(dfu_get_defer_flush(), NULL, 0, 0);
+                       dfu_set_defer_flush(NULL);
+                       if (ret) {
+                               error("Deferred dfu_flush() failed!");
+                               goto exit;
+                       }
+               }
+
                WATCHDOG_RESET();
                usb_gadget_handle_interrupts(controller_index);
        }