[PATCH 6/7] DFU : disable state fix

Renaud C. r.cerrato at til-technologies.fr
Tue Mar 12 12:38:14 EDT 2013


When an USB_REQ_DFU_DETACH request is received, the device state switch
to DFU_STATE_appDETACH, and then wait for an usb reset to switch
to DFU_STATE_dfuIDLE (through dfu_disable() being called).

I noticed that using dfu-util v0.7 on my AT91SAM9260 board, the programming
failed because of the device not entering the DFU_STATE_dfuIDLE after an
usb reset (staying in the DFU_STATE_appDETACH state).

According to the current implementation, once the USB_REQ_DFU_DETACH is
sent and right after the usb reset, if the DFU client set more than one
configuration (by iterating over them for example), the device state will
reset to the DFU_STATE_appDETACH state on the 2nd iteration because of the
following line in set_config (composite.c, line 362) :

...
if(cdev->config)
    reset_config();   // will call dfu_disable() again!
...

The attached patch is a *try* to fix the issue by leaving the device in
the DFU_STATE_dfuIDLE state after an usb reset if already in that
state. dfu-util will complain about the device already in
the DFU_STATE_dfuIDLE on the next start, but everything is still working.

This may need a REVISIT, but since the dfu_disable() gets called on both
configuration change and usb reset, we can't do this easily for now..
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/barebox/attachments/20130312/e9296ea4/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dfu-disable-state-fix.patch
Type: application/octet-stream
Size: 904 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/barebox/attachments/20130312/e9296ea4/attachment.obj>


More information about the barebox mailing list