[flashrom] [commit] r834 - trunk

svn at flashrom.org svn at flashrom.org
Thu Jan 7 04:32:17 CET 2010


Author: hailfinger
Date: 2010-01-07 04:32:17 +0100 (Thu, 07 Jan 2010)
New Revision: 834

Modified:
   trunk/buspirate_spi.c
   trunk/ft2232_spi.c
   trunk/ichspi.c
   trunk/sb600spi.c
   trunk/wbsio_spi.c
Log:
Programmer debug messages during programmer init/shutdown are useful
because they print hardware settings and desired configuration. They
help in getting a quick overview of hardware and software state on
startup and shutdown.

Programmer debug messages during flash chip access are mostly a
distraction in logs and should only be enabled if someone is having
problems which are suspected to stem from a programmer hardware or
programmer software bug. Disable those messages by default, they can be
reenabled by #define COMM_DEBUG in the affected programmer file.

An added benefit is a tremendous size reduction in verbose
probe/read/write/erase logs because only flash chip driver messages
remain. In some cases, logs will shrink from 65 MB to 10 kB or less.

The right(tm) fix would be two different debug levels (DEBUG and SPEW)
and the ability to differentiate between programmer debug messages and
flash chip debug messages. Until the design for the message printing
infrastructure is finished, this is the best stop-gap measure we can
get.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006 at gmx.net>
Acked-by: Sean Nelson <audioahcked at gmail.com>


Modified: trunk/buspirate_spi.c
===================================================================
--- trunk/buspirate_spi.c	2010-01-07 03:24:05 UTC (rev 833)
+++ trunk/buspirate_spi.c	2010-01-07 03:32:17 UTC (rev 834)
@@ -25,6 +25,17 @@
 #include "flash.h"
 #include "spi.h"
 
+/* Change this to #define if you want lowlevel debugging of commands
+ * sent to the Bus Pirate.
+ */
+#undef COMM_DEBUG
+
+#ifdef COMM_DEBUG
+#define msg_comm_debug printf_debug
+#else
+#define msg_comm_debug(...) do {} while (0)
+#endif
+
 /* Change this to #define if you want to test without a serial implementation */
 #undef FAKE_COMMUNICATION
 
@@ -47,14 +58,14 @@
 {
 	int i, ret = 0;
 
-	printf_debug("%s: write %i, read %i\n", __func__, writecnt, readcnt);
+	msg_comm_debug("%s: write %i, read %i ", __func__, writecnt, readcnt);
 	if (!writecnt && !readcnt) {
 		fprintf(stderr, "Zero length command!\n");
 		return 1;
 	}
-	printf_debug("Sending");
+	msg_comm_debug("Sending");
 	for (i = 0; i < writecnt; i++)
-		printf_debug(" 0x%02x", buf[i]);
+		msg_comm_debug(" 0x%02x", buf[i]);
 #ifdef FAKE_COMMUNICATION
 	/* Placate the caller for now. */
 	if (readcnt) {
@@ -72,10 +83,10 @@
 	if (ret)
 		return ret;
 #endif
-	printf_debug(", receiving");
+	msg_comm_debug(", receiving");
 	for (i = 0; i < readcnt; i++)
-		printf_debug(" 0x%02x", buf[i]);
-	printf_debug("\n");
+		msg_comm_debug(" 0x%02x", buf[i]);
+	msg_comm_debug("\n");
 	return 0;
 }
 

Modified: trunk/ft2232_spi.c
===================================================================
--- trunk/ft2232_spi.c	2010-01-07 03:24:05 UTC (rev 833)
+++ trunk/ft2232_spi.c	2010-01-07 03:32:17 UTC (rev 834)
@@ -29,6 +29,17 @@
 #include "spi.h"
 #include <ftdi.h>
 
+/* Change this to #define if you want lowlevel debugging of commands
+ * sent to the FT2232 SPI controller.
+ */
+#undef COMM_DEBUG
+
+#ifdef COMM_DEBUG
+#define msg_comm_debug printf_debug
+#else
+#define msg_comm_debug(...) do {} while (0)
+#endif
+
 /*
  * The 'H' chips can run internally at either 12MHz or 60MHz.
  * The non-H chips can only run at 12MHz.
@@ -224,7 +235,7 @@
 	 * and deassert CS# all in one shot. If reading, we do three separate
 	 * operations.
 	 */
-	printf_debug("Assert CS#\n");
+	msg_comm_debug("Assert CS#\n");
 	buf[i++] = SET_BITS_LOW;
 	buf[i++] = 0 & ~CS_BIT; /* assertive */
 	buf[i++] = 0x0b;
@@ -266,7 +277,7 @@
 		}
 	}
 
-	printf_debug("De-assert CS#\n");
+	msg_comm_debug("De-assert CS#\n");
 	buf[i++] = SET_BITS_LOW;
 	buf[i++] = CS_BIT;
 	buf[i++] = 0x0b;

Modified: trunk/ichspi.c
===================================================================
--- trunk/ichspi.c	2010-01-07 03:24:05 UTC (rev 833)
+++ trunk/ichspi.c	2010-01-07 03:32:17 UTC (rev 834)
@@ -36,6 +36,17 @@
 #include "flash.h"
 #include "spi.h"
 
+/* Change this to #define if you want lowlevel debugging of commands
+ * sent to the ICH/VIA SPI controller.
+ */
+#undef COMM_DEBUG
+
+#ifdef COMM_DEBUG
+#define msg_comm_debug printf_debug
+#else
+#define msg_comm_debug(...) do {} while (0)
+#endif
+
 /* ICH9 controller register definition */
 #define ICH9_REG_FADDR         0x08	/* 32 Bits */
 #define ICH9_REG_FDATA0                0x10	/* 64 Bytes */
@@ -624,7 +635,7 @@
 	uint32_t remaining = page_size;
 	int towrite;
 
-	printf_debug("ich_spi_write_page: offset=%d, number=%d, buf=%p\n",
+	msg_comm_debug("ich_spi_write_page: offset=%d, number=%d, buf=%p\n",
 		     offset, page_size, bytes);
 
 	for (; remaining > 0; remaining -= towrite) {

Modified: trunk/sb600spi.c
===================================================================
--- trunk/sb600spi.c	2010-01-07 03:24:05 UTC (rev 833)
+++ trunk/sb600spi.c	2010-01-07 03:32:17 UTC (rev 834)
@@ -24,6 +24,17 @@
 #include "flash.h"
 #include "spi.h"
 
+/* Change this to #define if you want lowlevel debugging of commands
+ * sent to the SB600/SB700 SPI controller.
+ */
+#undef COMM_DEBUG
+
+#ifdef COMM_DEBUG
+#define msg_comm_debug printf_debug
+#else
+#define msg_comm_debug(...) do {} while (0)
+#endif
+
 /* This struct is unused, but helps visualize the SB600 SPI BAR layout.
  *struct sb600_spi_controller {
  *	unsigned int spi_cntrl0;	/ * 00h * /
@@ -105,7 +116,7 @@
 
 	writecnt--;
 
-	printf_debug("%s, cmd=%x, writecnt=%x, readcnt=%x\n",
+	msg_comm_debug("%s, cmd=%x, writecnt=%x, readcnt=%x\n",
 		     __func__, cmd, writecnt, readcnt);
 
 	if (readcnt > 8) {
@@ -135,10 +146,10 @@
 
 	/* Send the write byte to FIFO. */
 	for (count = 0; count < writecnt; count++, writearr++) {
-		printf_debug(" [%x]", *writearr);
+		msg_comm_debug(" [%x]", *writearr);
 		mmio_writeb(*writearr, sb600_spibar + 0xC);
 	}
-	printf_debug("\n");
+	msg_comm_debug("\n");
 
 	/*
 	 * We should send the data by sequence, which means we need to reset
@@ -164,16 +175,16 @@
 	/* Skip the bytes we sent. */
 	for (count = 0; count < writecnt; count++) {
 		cmd = mmio_readb(sb600_spibar + 0xC);
-		printf_debug("[ %2x]", cmd);
+		msg_comm_debug("[ %2x]", cmd);
 	}
 
-	printf_debug("The FIFO pointer after skipping is %d.\n",
+	msg_comm_debug("The FIFO pointer after skipping is %d.\n",
 		     mmio_readb(sb600_spibar + 0xd) & 0x07);
 	for (count = 0; count < readcnt; count++, readarr++) {
 		*readarr = mmio_readb(sb600_spibar + 0xC);
-		printf_debug("[%02x]", *readarr);
+		msg_comm_debug("[%02x]", *readarr);
 	}
-	printf_debug("\n");
+	msg_comm_debug("\n");
 
 	return 0;
 }

Modified: trunk/wbsio_spi.c
===================================================================
--- trunk/wbsio_spi.c	2010-01-07 03:24:05 UTC (rev 833)
+++ trunk/wbsio_spi.c	2010-01-07 03:32:17 UTC (rev 834)
@@ -2,6 +2,7 @@
  * This file is part of the flashrom project.
  *
  * Copyright (C) 2008 Peter Stuge <peter at stuge.se>
+ * Copyright (C) 2009,2010 Carl-Daniel Hailfinger
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -21,6 +22,17 @@
 #include "flash.h"
 #include "spi.h"
 
+/* Change this to #define if you want lowlevel debugging of commands
+ * sent to the Winbond W836xx SPI controller.
+ */
+#undef COMM_DEBUG
+
+#ifdef COMM_DEBUG
+#define msg_comm_debug printf_debug
+#else
+#define msg_comm_debug(...) do {} while (0)
+#endif
+
 #define WBSIO_PORT1	0x2e
 #define WBSIO_PORT2	0x4e
 
@@ -62,7 +74,7 @@
 		if (0 == (wbsio_spibase = wbsio_get_spibase(WBSIO_PORT2)))
 			return 1;
 
-	printf_debug("\nwbsio_spibase = 0x%x\n", wbsio_spibase);
+	msg_comm_debug("\nwbsio_spibase = 0x%x\n", wbsio_spibase);
 
 	buses_supported |= CHIP_BUSTYPE_SPI;
 	spi_controller = SPI_CONTROLLER_WBSIO;
@@ -96,42 +108,42 @@
 	int i;
 	uint8_t mode = 0;
 
-	printf_debug("%s:", __func__);
+	msg_comm_debug("%s:", __func__);
 
 	if (1 == writecnt && 0 == readcnt) {
 		mode = 0x10;
 	} else if (2 == writecnt && 0 == readcnt) {
 		OUTB(writearr[1], wbsio_spibase + 4);
-		printf_debug(" data=0x%02x", writearr[1]);
+		msg_comm_debug(" data=0x%02x", writearr[1]);
 		mode = 0x20;
 	} else if (1 == writecnt && 2 == readcnt) {
 		mode = 0x30;
 	} else if (4 == writecnt && 0 == readcnt) {
-		printf_debug(" addr=0x%02x", (writearr[1] & 0x0f));
+		msg_comm_debug(" addr=0x%02x", (writearr[1] & 0x0f));
 		for (i = 2; i < writecnt; i++) {
 			OUTB(writearr[i], wbsio_spibase + i);
-			printf_debug("%02x", writearr[i]);
+			msg_comm_debug("%02x", writearr[i]);
 		}
 		mode = 0x40 | (writearr[1] & 0x0f);
 	} else if (5 == writecnt && 0 == readcnt) {
-		printf_debug(" addr=0x%02x", (writearr[1] & 0x0f));
+		msg_comm_debug(" addr=0x%02x", (writearr[1] & 0x0f));
 		for (i = 2; i < 4; i++) {
 			OUTB(writearr[i], wbsio_spibase + i);
-			printf_debug("%02x", writearr[i]);
+			msg_comm_debug("%02x", writearr[i]);
 		}
 		OUTB(writearr[i], wbsio_spibase + i);
-		printf_debug(" data=0x%02x", writearr[i]);
+		msg_comm_debug(" data=0x%02x", writearr[i]);
 		mode = 0x50 | (writearr[1] & 0x0f);
 	} else if (8 == writecnt && 0 == readcnt) {
-		printf_debug(" addr=0x%02x", (writearr[1] & 0x0f));
+		msg_comm_debug(" addr=0x%02x", (writearr[1] & 0x0f));
 		for (i = 2; i < 4; i++) {
 			OUTB(writearr[i], wbsio_spibase + i);
-			printf_debug("%02x", writearr[i]);
+			msg_comm_debug("%02x", writearr[i]);
 		}
-		printf_debug(" data=0x");
+		msg_comm_debug(" data=0x");
 		for (; i < writecnt; i++) {
 			OUTB(writearr[i], wbsio_spibase + i);
-			printf_debug("%02x", writearr[i]);
+			msg_comm_debug("%02x", writearr[i]);
 		}
 		mode = 0x60 | (writearr[1] & 0x0f);
 	} else if (5 == writecnt && 4 == readcnt) {
@@ -142,14 +154,14 @@
 		 */
 		;
 	} else if (4 == writecnt && readcnt >= 1 && readcnt <= 4) {
-		printf_debug(" addr=0x%02x", (writearr[1] & 0x0f));
+		msg_comm_debug(" addr=0x%02x", (writearr[1] & 0x0f));
 		for (i = 2; i < writecnt; i++) {
 			OUTB(writearr[i], wbsio_spibase + i);
-			printf_debug("%02x", writearr[i]);
+			msg_comm_debug("%02x", writearr[i]);
 		}
 		mode = ((7 + readcnt) << 4) | (writearr[1] & 0x0f);
 	}
-	printf_debug(" cmd=%02x mode=%02x\n", writearr[0], mode);
+	msg_comm_debug(" cmd=%02x mode=%02x\n", writearr[0], mode);
 
 	if (!mode) {
 		fprintf(stderr, "%s: unsupported command type wr=%d rd=%d\n",
@@ -165,12 +177,12 @@
 	if (!readcnt)
 		return 0;
 
-	printf_debug("%s: returning data =", __func__);
+	msg_comm_debug("%s: returning data =", __func__);
 	for (i = 0; i < readcnt; i++) {
 		readarr[i] = INB(wbsio_spibase + 4 + i);
-		printf_debug(" 0x%02x", readarr[i]);
+		msg_comm_debug(" 0x%02x", readarr[i]);
 	}
-	printf_debug("\n");
+	msg_comm_debug("\n");
 	return 0;
 }
 





More information about the flashrom mailing list