dfu-util bug with >1 interface-descriptors

Stefan Schmidt stefan at datenfreihafen.org
Thu Apr 22 15:50:09 CEST 2010


Sorry for the delay. I'm travelling.

On Tue, 2010-04-20 at 13:44, Daniel Hiepler wrote:
> i recently noticed a possible bug in dfu-util: 
> in main.c:585 after "usb_claim_interface()" a
> "usb_set_altinerface(_rt_dif.dev_handle, 0)" call seems to be necessary
> to actually switch to the DFU interface when the USB-Device still uses
> its default interface. 
> usb_claim_interface() doesn't send anything over the bus, but the
> device needs to know when to serve DFU-Requests (like the following
> dfu_get_status() request).

Sounds right to me. I have to re-read the DFU spec over the weekend to be sure.
(Just downloaded 1.0 and 1.1 to make myself comfortable with it again)

> it works without it on devices where the DFU-Interface == 0 or the only
> DFU interface available.
> It doesn't work if a device offers a DFU-Device Descriptor in normal
> runtime mode (to serve appDETACH requests).
> Can someone confirm whether this call causes any harm?

I tested with the following changes:

diff --git a/src/main.c b/src/main.c
index b36a949..0d9e0c0 100644
--- a/src/main.c
+++ b/src/main.c
@@ -588,6 +588,12 @@ int main(int argc, char **argv)
+               if (usb_set_altinterface(_rt_dif.dev_handle, 0) < 0) {
+                       fprintf(stderr, "Cannot set alt interface: %s\n",
+                               usb_strerror());
+                       exit(1);
+               }
                printf("Determining device status: ");
                if (dfu_get_status(_rt_dif.dev_handle, _rt_dif.interface,
&status ) < 0) {
                        fprintf(stderr, "error get_status: %s\n",

No problems so far. Will make some test over the weekend.

Stefan Schmidt

More information about the devel mailing list