dfu: Does is work for anybody with dfu-util 0.9?
Hi,
I'm using DFU to download firmware to AT91 based device. Registered configurations are:
dfu: register alt0(bootstrap) with device /dev/dataflash0.at91bootstrap
dfu: register alt1(bootloader) with device /dev/dataflash0.barebox
dfu: register alt2(system) with device /dev/nand0.bb
So with the bit of luck even bootstrap is upgradable using DFU, however dfu-util refuses doing anything, bailing out here on dfu_root->next not being NULL:
if (dfu_root == NULL) {
errx(EX_IOERR, "No DFU capable USB device available");
} else if (dfu_root->next != NULL) {
/* We cannot safely support more than one DFU capable device
* with same vendor/product ID, since during DFU we need to do
* a USB bus reset, after which the target device will get a
* new address */
errx(EX_IOERR, "More than one DFU capable USB device found! "
"Try `--list' and specify the serial number "
"or disconnect all but one device\n");
}That comes from src/dfu_util.c:probe_configuration() which check for:
dfu_mode = (intf->bInterfaceProtocol == 2); /* e.g. DSO Nano has bInterfaceProtocol 0 instead of 2 */ if (func_dfu.bcdDFUVersion == 0x011a && intf->bInterfaceProtocol == 0) dfu_mode = 1; /* LPC DFU bootloader has bInterfaceProtocol 1 (Runtime) instead of 2 */ if (desc->idVendor == 0x1fc9 && desc->idProduct == 0x000c && intf->bInterfaceProtocol == 1) dfu_mode = 1; /* * Old Jabra devices may have bInterfaceProtocol 0 instead of 2. * Also runtime PID and DFU pid are the same. * In DFU mode, the configuration descriptor has only 1 interface. */ if (desc->idVendor == 0x0b0e && intf->bInterfaceProtocol == 0 && cfg->bNumInterfaces == 1) dfu_mode = 1;
and as Barebox sets bInterfaceProtocol to one and it is not listed in exceptions individual devices are added for each alt settings.
As a quick hack I'd suggest patch bellow, but I'm not sure whenever it will break someone's setup. DFU code would certainly welcome some polishing/improvements, but time does not permit that on my side for the time being :(
drivers/usb/gadget/dfu.c +1 -1
@@ -233,7 +233,7 @@ dfu_bind(struct usb_configuration *c, struct usb_function *f) desc[i].bNumEndpoints =0 ; desc[i].bInterfaceClass =0xfe ; desc[i].bInterfaceSubClass =1 ; - desc[i].bInterfaceProtocol =1 ; + desc[i].bInterfaceProtocol =2 ; desc[i].bAlternateSetting = i; desc[i].iInterface = us[i +1 ].id; header[i] = (struct usb_descriptor_header *)&desc[i];
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Quoted 11 lines · Ladislav Michl
Hi,
I'm using DFU to download firmware to AT91 based device. Registered configurations are:
dfu: register alt0(bootstrap) with device/dev/dataflash0.at91bootstrap
dfu: register alt1(bootloader) with device/dev/dataflash0.barebox
dfu: register alt2(system) with device/dev/nand0.bb
So with the bit of luck even bootstrap is upgradable using DFU, however dfu-util refuses doing anything, bailing out here ondfu_root->nextnot being NULL:
dfu stopped working for me with the following dfu-utils commit. I never came along fixing it, but a proper patch would surely be welcomed.
Sascha
------------------------------8<--------------------------------
From 377f6f136d3369529f44578acaeee82d7c7d7af9 Mon Sep 17 00:00:00 2001
From: Paul Fertser <[email protected]>
Date: Sun, 10 Aug 2014 14:26:05 +0400
Subject: [PATCH] dfu_util: Ignore alt_index/alt_name specification in runtime
mode
When the device is in runtime mode it needs to be reset first into DFU mode for the list of alternate settings to appear, so unless it is already in the right mode, matching on alt setting number or name should be skipped.
Fixes regression on OpenMoko Freerunner.
--- src/dfu_util.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
src/dfu_util.c +8 -3
@@ -189,13 +189,17 @@ found_dfu:int dfu_mode; intf = &uif->altsetting[alt_idx]; -if (match_iface_alt_index >-1 && match_iface_alt_index != alt_idx) -continue ; +if (intf->bInterfaceClass !=0xfe || intf->bInterfaceSubClass !=1 )continue ; dfu_mode = (intf->bInterfaceProtocol ==2 ); + +if (dfu_mode && + match_iface_alt_index >-1 && match_iface_alt_index != alt_idx) +continue ; +if (dfu_mode) {if ((match_vendor_dfu >=0 && match_vendor_dfu != desc->idVendor) || (match_product_dfu >=0 && match_product_dfu != desc->idProduct)) {
@@ -228,7 +232,8 @@ found_dfu:strcpy (serial_name,"UNKNOWN" );libusb_close (devh); -if (match_iface_alt_name !=NULL &&strcmp (alt_name, match_iface_alt_name)) +if (dfu_mode && + match_iface_alt_name !=NULL &&strcmp (alt_name, match_iface_alt_name))continue ;if (dfu_mode) {
Signature · 13 lines
2.20.1 -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox