Ticket #673 (closed defect: fixed)
[PATCH] Handle the DFU status value correctly during download
| Reported by: | nick@… | Owned by: | werner@… |
|---|---|---|---|
| Priority: | high | Milestone: | |
| Component: | host utilities | Version: | current svn head |
| Severity: | normal | Keywords: | VERIFIED |
| Cc: | buglog@… | Blocked By: | |
| Blocking: | Estimated Completion (week): | ||
| HasPatchForReview: | PatchReviewResult: | ||
| Reproducible: |
Description
During download you can end up in an endless loop if the dst.bStatus changes
to != DFU_STATUS_OK. dfu-util never recovers and keeps sending GET_STATUS
requests.
Fail the transfer as DFU_STATUS seems to indicate a fatal error in all cases
except DFU_STATUS_OK.
Index: sam7dfu.c
===================================================================
--- sam7dfu.c (revision 2384)
+++ sam7dfu.c (working copy)
@@ -127,8 +127,11 @@
goto out_close;
}
usleep(5000);
- dst.bStatus != DFU_STATUS_OK);
+ } while (dst.bState != DFU_STATE_dfuDNLOAD_IDLE);
+ if (dst.bStatus != DFU_STATUS_OK) {
+ printf(" failed!\n");
+ goto get_status;
+ }
hashes_todo = (bytes_sent / bytes_per_hash) - hashes;
hashes += hashes_todo;

... and return a correct error value to the caller, so we get an error in $?
after exit of the program.
Index: sam7dfu.c
===================================================================
--- sam7dfu.c (revision 2384)
+++ sam7dfu.c (working copy)
@@ -127,8 +127,15 @@
+ } while (dst.bState != DFU_STATE_dfuDNLOAD_IDLE);
+ if (dst.bStatus != DFU_STATUS_OK) {
+ printf(" failed!\n");
+ printf("state(%u) = %s, status(%u) = %s\n",
dst.bState,
+ dfu_state_to_string(dst.bState), dst.bStatus,
+ dfu_status_to_string(dst.bStatus));
+ ret = -1;
+ goto out_close;
+ }