- bwPollTimeout is set to 10 ms, from the DFU spec, this is the minimum time, in milliseconds, that the host should wait before sending a subsequent DFU_GETSTATUS request. Without this, I get 25 seconds value and dfu-util waits twice 25s during download - when in IDEL and receiving DETACH, first return 0 to make dfu-util happy, then use a dfudetach variable to exit dfu (without an USB reset as per the comment on line 425) and return to runtime mode. - tested on i.MX25 & i.MX35 Signed-off-by: Eric Bénard <eric@xxxxxxxxxx> --- drivers/usb/gadget/dfu.c | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-) diff --git a/drivers/usb/gadget/dfu.c b/drivers/usb/gadget/dfu.c index 0a0d244..f26c1e4 100644 --- a/drivers/usb/gadget/dfu.c +++ b/drivers/usb/gadget/dfu.c @@ -67,6 +67,7 @@ static int dfualt; static int dfufd = -EINVAL;; static struct usb_dfu_dev *dfu_devs; static int dfu_num_alt; +static int dfudetach; /* USB DFU functional descriptor */ static struct usb_dfu_func_descriptor usb_dfu_func = { @@ -204,6 +205,9 @@ static int dfu_status(struct usb_function *f, const struct usb_ctrlrequest *ctrl dstat->bStatus = dfu->dfu_status; dstat->bState = dfu->dfu_state; dstat->iString = 0; + dstat->bwPollTimeout[0] = 10; + dstat->bwPollTimeout[1] = 0; + dstat->bwPollTimeout[2] = 0; return sizeof(*dstat); } @@ -425,6 +429,8 @@ static int dfu_setup(struct usb_function *f, const struct usb_ctrlrequest *ctrl) * least the Linux USB stack likes to send a number of resets * in a row :( */ dfu->dfu_state = DFU_STATE_dfuMANIFEST_WAIT_RST; + value = 0; + dfudetach = 1; break; default: dfu->dfu_state = DFU_STATE_dfuERROR; @@ -690,11 +696,12 @@ int usb_dfu_register(struct usb_dfu_pdata *pdata) while (1) { usb_gadget_poll(); - if (ctrlc()) + if (ctrlc() || dfudetach) goto out; } out: + dfudetach = 0; usb_composite_unregister(&dfu_driver); return 0; -- 1.7.7.4 _______________________________________________ barebox mailing list barebox@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/barebox