mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ladislav Michl <ladis@linux-mips.org>
To: barebox@lists.infradead.org
Subject: dfu: Does is work for anybody with dfu-util 0.9?
Date: Fri, 11 Jan 2019 11:22:35 +0100	[thread overview]
Message-ID: <20190111102235.GA3464@lenoch> (raw)

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 :(

diff --git a/drivers/usb/gadget/dfu.c b/drivers/usb/gadget/dfu.c
index c2b3d481a..aee86906a 100644
--- a/drivers/usb/gadget/dfu.c
+++ b/drivers/usb/gadget/dfu.c
@@ -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];
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

             reply	other threads:[~2019-01-11 10:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-11 10:22 Ladislav Michl [this message]
2019-01-11 11:02 ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190111102235.GA3464@lenoch \
    --to=ladis@linux-mips.org \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox