The DFU spec says that bwPollTimeout is the amount of time that should pass between DFU_GETSTATUS requests. If the status is already good, we do not need to sleep as we will not poll again.
This speeds up DFU downloads directly into memory. Signed-off-by: Bernard Blackham <[email protected]> diff --git a/src/dfu_load.c b/src/dfu_load.c index 3a4f382..f6dc8ce 100644 --- a/src/dfu_load.c +++ b/src/dfu_load.c @@ -163,14 +163,18 @@ int dfuload_do_dnload(struct usb_dev_handle *usb_handle, int interface, fprintf(stderr, "Error during download get_status\n"); goto out_close; } + + if (dst.bState == DFU_STATE_dfuDNLOAD_IDLE || + dst.bState == DFU_STATE_dfuERROR) + break; + /* Wait while device executes flashing */ if (quirks & QUIRK_POLLTIMEOUT) usleep(DEFAULT_POLLTIMEOUT * 1000); else usleep(dst.bwPollTimeout * 1000); - } while (dst.bState != DFU_STATE_dfuDNLOAD_IDLE && - dst.bState != DFU_STATE_dfuERROR); + } while (1); if (dst.bStatus != DFU_STATUS_OK) { printf(" failed!\n"); printf("state(%u) = %s, status(%u) = %s\n", dst.bState, _______________________________________________ devel mailing list [email protected] https://lists.openmoko.org/mailman/listinfo/devel
