Menu

#42 dfu-util sends a detach request before reset

none
open
nobody
doc (13)
2019-05-01
2017-04-21
Ait Ahcene
No

Hi,

I am trying to execute this command:

dfu-util -a18 -D usb_test.bin -R --verbose

The transfer goes fine but I get the "can't detach" message everytime I add the "-R" option.

dfu-util 0.8.4

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2014 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/

dfu-util: Invalid DFU suffix signature
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!
dfu-util: Cannot open DFU device 17e9:4305
Opening DFU capable USB device...
ID 8087:0a99
Run-time device DFU version 0110
Claiming USB DFU Interface...
Setting Alternate Setting #18 ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 0110
Device returned transfer size 2048
Copying data from PC to DFU device
Download    [=========================] 100%        16976 bytes
Download done.
Sent a total of 16976 bytes
state(6) = dfuMANIFEST-SYNC, status(0) = No error condition is present
state(2) = dfuIDLE, status(0) = No error condition is present
Done!
dfu-util: can't detach
Resetting USB to switch back to runtime mode

I compared the dfu-util main.c with the DFU 1.1 specification and there is something that doesn't seem to match. Just before issuing a final reset (if the "-R" option is present), dfu-util sends a DFU_DETACH request:

    if (final_reset) {
        if (dfu_detach(dfu_root->dev_handle, dfu_root->interface, 1000) < 0) {
            /* Even if detach failed, just carry on to leave the
                           device in a known state */
            warnx("can't detach");
        }
        printf("Resetting USB to switch back to runtime mode\n");
        ret = libusb_reset_device(dfu_root->dev_handle);
        if (ret < 0 && ret != LIBUSB_ERROR_NOT_FOUND) {
            errx(EX_IOERR, "error resetting after download: %s", libusb_error_name(ret));
        }
    }

According to the specification, the DFU_DETACH should only be issued in appIDLE state so in runtime mode, not in DFU mode. So, how come there is a dfu_detach request before the reset ?

Thanks.

Discussion

  • Tormod Volden

    Tormod Volden - 2017-06-03

    The original dfu-util was written for the OpenMoko bootloader that has the possibility to switch back to runtime mode through a DFU detach. The same functionality ended up in the uboot DFU bootloader which is widely used, so we have kept this. To my knowledge it doesn't disturb any supported device. It is a really benign message, but it could maybe be improved in wording. Ideally we should only do this dfu_detach on the devices which we know support it.

     
  • Tormod Volden

    Tormod Volden - 2017-06-03
    • labels: --> doc
     

Anonymous
Anonymous

Add attachments
Cancel





MongoDB Logo MongoDB