[flashrom] [PATCH] Differentiate ultimate error messages depending on programmer used.

Stefan Tauner stefan.tauner at student.tuwien.ac.at
Sat Jul 6 23:19:37 CEST 2013


With every newly supported programmer the information regarding reboots
on failures becomes more ridiculous. With this patch it is only shown when
the internal programmer module was selected.

Example outputs for external programmers:
1) non-fatal:
[…]
Reading current flash chip contents... done. FAILED at 0x00000000! Expected=0xff, Found=0x28, failed byte count from 0x00000000-0x0001ffff: 0x1fde7
ERASE FAILED!
FAILED!
Uh oh. Erase/write failed. Checking if anything changed.
Good. It seems nothing was changed.
Writing to the flash chip apparently didn't do anything.
Please check the connections (especially those to write protection pins) between
the programmer and the flash chip. If you think the error is caused by flashrom
please report this on IRC at chat.freenode.net (channel #flashrom) or
mail flashrom at flashrom.org, thanks!

2) fatal:
[…]
Verifying flash... FAILED at 0x00000000! Expected=0x0f, Found=0xff, failed byte count from 0x00000000-0x0001ffff: 0x1fde6
Your flash chip is in an unknown state.
Please report this on IRC at chat.freenode.net (channel #flashrom) or
mail flashrom at flashrom.org, thanks!

Signed-off-by: Stefan Tauner <stefan.tauner at student.tuwien.ac.at>
---

Tests with a failing internal programmer or a review/ack would be appreciated :)

 flashrom.c | 46 ++++++++++++++++++++++++++++------------------
 1 file changed, 28 insertions(+), 18 deletions(-)

diff --git a/flashrom.c b/flashrom.c
index 43b7b11..2a89a85 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -1492,26 +1492,37 @@ int erase_and_write_flash(struct flashctx *flash, uint8_t *oldcontents,
 	return ret;
 }
 
-void nonfatal_help_message(void)
+static void nonfatal_help_message(void)
 {
-	msg_gerr("Writing to the flash chip apparently didn't do anything.\n"
-		"This means we have to add special support for your board, "
-		  "programmer or flash chip.\n"
-		"Please report this on IRC at irc.freenode.net (channel "
-		  "#flashrom) or\n"
-		"mail flashrom at flashrom.org!\n"
-		"-------------------------------------------------------------"
-		  "------------------\n"
-		"You may now reboot or simply leave the machine running.\n");
+	msg_gerr("Writing to the flash chip apparently didn't do anything.\n");
+#if CONFIG_INTERNAL == 1
+	if (programmer == PROGRAMMER_INTERNAL)
+		msg_gerr("This means we have to add special support for your board, programmer or flash chip.\n"
+			 "Please report this on IRC at chat.freenode.net (channel #flashrom) or\n"
+			 "mail flashrom at flashrom.org, thanks!\n"
+			 "-------------------------------------------------------------------------------\n"
+			 "You may now reboot or simply leave the machine running.\n");
+	else
+#endif
+		msg_gerr("Please check the connections (especially those to write protection pins) between\n"
+			 "the programmer and the flash chip. If you think the error is caused by flashrom\n"
+			 "please report this on IRC at chat.freenode.net (channel #flashrom) or\n"
+			 "mail flashrom at flashrom.org, thanks!\n");
 }
 
-void emergency_help_message(void)
+static void emergency_help_message(void)
 {
-	msg_gerr("Your flash chip is in an unknown state.\n"
-		"Get help on IRC at chat.freenode.net (channel #flashrom) or\n"
-		"mail flashrom at flashrom.org with the subject \"FAILED: <your board name>\"!\n"
-		"-------------------------------------------------------------------------------\n"
-		"DO NOT REBOOT OR POWEROFF!\n");
+	msg_gerr("Your flash chip is in an unknown state.\n");
+#if CONFIG_INTERNAL == 1
+	if (programmer == PROGRAMMER_INTERNAL)
+		msg_gerr("Get help on IRC at chat.freenode.net (channel #flashrom) or\n"
+			"mail flashrom at flashrom.org with the subject \"FAILED: <your board name>\"!\n"
+			"-------------------------------------------------------------------------------\n"
+			"DO NOT REBOOT OR POWEROFF!\n");
+	else
+#endif
+		msg_gerr("Please report this on IRC at chat.freenode.net (channel #flashrom) or\n"
+			 "mail flashrom at flashrom.org, thanks!\n");
 }
 
 /* The way to go if you want a delimited list of programmers */
@@ -1972,8 +1983,7 @@ int doit(struct flashctx *flash, int force, const char *filename, int read_it,
 				 "anything changed.\n");
 			if (!flash->chip->read(flash, newcontents, 0, size)) {
 				if (!memcmp(oldcontents, newcontents, size)) {
-					msg_cinfo("Good. It seems nothing was "
-						  "changed.\n");
+					msg_cinfo("Good. It seems nothing was changed.\n");
 					nonfatal_help_message();
 					ret = 1;
 					goto out;
-- 
Kind regards, Stefan Tauner





More information about the flashrom mailing list