r2766 - trunk/src/host/dfu-util/src

laforge at sita.openmoko.org laforge at sita.openmoko.org
Tue Aug 21 21:05:16 CEST 2007


Author: laforge
Date: 2007-08-21 21:05:10 +0200 (Tue, 21 Aug 2007)
New Revision: 2766

Modified:
   trunk/src/host/dfu-util/src/main.c
Log:
Don't obtain the transfer size via the DFU functional descriptor
if the user has specified it on the command line.  Apparently there
are some devices that violate the DFU spec (*sigh*) by not implementing the
functional descriptor.  Taken from 
https://bugzilla.openmoko.org/cgi-bin/bugzilla/show_bug.cgi?id=654
(Nick Hibma)


Modified: trunk/src/host/dfu-util/src/main.c
===================================================================
--- trunk/src/host/dfu-util/src/main.c	2007-08-21 18:59:58 UTC (rev 2765)
+++ trunk/src/host/dfu-util/src/main.c	2007-08-21 19:05:10 UTC (rev 2766)
@@ -631,23 +631,25 @@
 		break;
 	}
 
-	/* Obtain DFU functional descriptor */
-	ret = usb_get_descriptor(dif->dev_handle, 0x21, dif->interface,
-				 &func_dfu, sizeof(func_dfu));
-	if (ret < 0) {
-		fprintf(stderr, "Error obtaining DFU functional "
-			"descriptor: %s\n", usb_strerror());
-		exit(1);
+	if (!transfer_size) {
+		/* Obtain DFU functional descriptor */
+		ret = usb_get_descriptor(dif->dev_handle, 0x21, dif->interface,
+					 &func_dfu, sizeof(func_dfu));
+		if (ret < 0) {
+			fprintf(stderr, "Error obtaining DFU functional "
+				"descriptor: %s\n", usb_strerror());
+			transfer_size = page_size;
+		} else {
+		    /* FIXME: Endian! */
+		    transfer_size = func_dfu.wTransferSize;
+		}
 	}
-	/* FIXME: Endian! */
-	if (!transfer_size)
-		transfer_size = func_dfu.wTransferSize;
 
+	if (transfer_size > page_size)
+		transfer_size = page_size;
+	
 	printf("Transfer Size = 0x%04x\n", transfer_size);
 
-	if (func_dfu.wTransferSize > page_size)
-		func_dfu.wTransferSize = page_size;
-	
 	if (DFU_STATUS_OK != status.bStatus ) {
 		printf("WARNING: DFU Status: '%s'\n",
 			dfu_status_to_string(status.bStatus));





More information about the commitlog mailing list