Closed smunaut closed 3 years ago
Hi @smunaut, thanks for bringing this up. At a glance, it looks like dfu-util
uses the following rules:
That should be pretty straightforward to implement here, though I'll have to do some testing to make sure it doesn't break DFU for any of the devices I have lying around. Looking through the dfu-util bug tracker, it seems like the libusb
SET_INTERFACE
support sometimes breaks on some versions on some platforms.
So a SET_INTERFACE on a interface with a single alt setting is allowed to fail, so if it does, you should ignore it. It's perfectly valid for a device to STALL on that.
It makes sense that a device might STALL the request, but from the dfu-util
comments, the implication seems to be that some devices might just crash in response to an unexpected SET_INTERFACE
request. I'm not sure whether that's something that the dfu-util
authors have actually encountered in the wild or if it's a just-in-case thing.
Hi @smunaut, I've started #15 to try to address this.
From testing on Windows and Linux, it seems that on Windows the OS automagically sends the SET_INTERFACE
request to select alternate 0 and subsequently the USB backend suppresses any redundant SET_INTERFACE
requests. On Linux it sends SET_INTERFACE
requests only when requested.
I tested on the test website linked in the PR and this worked for me here (on linux).
As a side note, it's also be nice to be able to skip the reset() at the end of download phase. Devices with multiple interfaces can be because you have multiple part the firmware or multiple MCU etc ... that need to be updated together / stay in sync and so you download fw #0, then fw #1 and then only you reset.
Hmm, I see, I guess I could refactor do_download()
to only reset the device in certain states instead of always resetting it. I'll add it to my list of things to do if I ever get around to making improvements again.
Some devices with several alt settings for the DFU interface expect a call to SET_INTERFACE even if the alt settings you want to use is the default 0 one.
dfu-util
issues SET_INTERFACE all the time to deal with that, but seems the web impl doesn.