help needed with dfu-util issue on Freerunner

Paul Fertser fercerpav at gmail.com
Sun Aug 10 12:26:05 CEST 2014


Tormod Volden <lists.tormod at gmail.com> writes:
> Further, it would be helpful to run dfu-util with gdb or another
> debugger and step through the enumeration and matching of interfaces,
> and see why the interface (name) is not recognized.

The reason is that initially freerunner's u-boot is in runtime mode, so
alt_name comparison fails the first time probe_devices() is invoked, so
dfu-util has no chance to continue and reset it from runtime to dfu
mode. A patch inline.

PS: regarding configure.ac, it's my strong enough impression that
MAINTAINER_MODE macro should be removed from there, it only adds
confusion and never does anything useful IMHO.

>From 7af120685753890c6e8f0db1984c4665e4266b5d Mon Sep 17 00:00:00 2001
From: Paul Fertser <fercerpav at gmail.com>
Date: Sun, 10 Aug 2014 14:22:15 +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's
already in the right mode, matching on alt setting number or name
should be skipped.

Signed-off-by: Paul Fertser <fercerpav at gmail.com>
---
 src/dfu_util.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/dfu_util.c b/src/dfu_util.c
index bb40e94..cc92c19 100644
--- a/src/dfu_util.c
+++ b/src/dfu_util.c
@@ -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) {
-- 
1.8.3.2



More information about the devel mailing list