From: Tormod Volden <debian.tor...@gmail.com> There is an extra DFU state check after the transfer size has been determined. The order should not matter so move it around.
Signed-off-by: Tormod Volden <debian.tor...@gmail.com> --- This is just to make the code cleaner and better structured. It has been like this since the start of the git history, but I do not think there is any reason for having this check /after/ requesting the functional descriptor. If someone can test it on sam7DFU device that would be nice. I think the early code was made for this device. Tormod src/main.c | 30 +++++++++++++++--------------- 1 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/main.c b/src/main.c index e03ec3f..39a3bcd 100644 --- a/src/main.c +++ b/src/main.c @@ -905,6 +905,21 @@ status_again: break; } + if (DFU_STATUS_OK != status.bStatus ) { + printf("WARNING: DFU Status: '%s'\n", + dfu_status_to_string(status.bStatus)); + /* Clear our status & try again. */ + dfu_clear_status(dif->dev_handle, dif->interface); + dfu_get_status(dif->dev_handle, dif->interface, &status); + + if (DFU_STATUS_OK != status.bStatus) { + fprintf(stderr, "Error: %d\n", status.bStatus); + exit(1); + } + if (!(quirks & QUIRK_POLLTIMEOUT)) + usleep(status.bwPollTimeout * 1000); + } + /* Retrieve DFU mode DFU functional descriptor */ ret = usb_get_extra_descriptor(dif, USB_DT_DFU, dif->interface, &func_dfu, sizeof(func_dfu)); @@ -948,21 +963,6 @@ status_again: printf("Adjusted transfer size to %i\n", transfer_size); } - if (DFU_STATUS_OK != status.bStatus ) { - printf("WARNING: DFU Status: '%s'\n", - dfu_status_to_string(status.bStatus)); - /* Clear our status & try again. */ - dfu_clear_status(dif->dev_handle, dif->interface); - dfu_get_status(dif->dev_handle, dif->interface, &status); - - if (DFU_STATUS_OK != status.bStatus) { - fprintf(stderr, "Error: %d\n", status.bStatus); - exit(1); - } - if (!(quirks & QUIRK_POLLTIMEOUT)) - usleep(status.bwPollTimeout * 1000); - } - switch (mode) { case MODE_UPLOAD: file.fd = open(file.name, O_WRONLY|O_CREAT|O_EXCL, 0644); -- 1.7.5.4 _______________________________________________ devel mailing list devel@lists.openmoko.org https://lists.openmoko.org/mailman/listinfo/devel