[flashrom] [PATCH] Fix verification operation.

Stefan Tauner stefan.tauner at student.tuwien.ac.at
Mon Aug 12 02:00:04 CEST 2013


I broke this in r1702 where I enabled avoidance of the verification step if
we did not modify anything in the erase/write step. The problem is that
all_skipped is initialized to true and hence it would only ever verify if
there have been changes noted in the erase/write step. This obviously
breaks the verification operation (-v/--verify) because there we never
enter the erase/write loop.

The better alternative would be to enable (the implicit) verification
in the write loop and not in cli_classic.c. This would require a bigger
change due to the existance of dont_verify_it. Eventually this is the
right thing to do but not so shortly before a release.

Signed-off-by: Stefan Tauner <stefan.tauner at student.tuwien.ac.at>
---
 cli_classic.c | 6 ++----
 flashrom.c    | 7 +++++--
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/cli_classic.c b/cli_classic.c
index 089cf03..4c71d07 100644
--- a/cli_classic.c
+++ b/cli_classic.c
@@ -175,8 +175,7 @@ int main(int argc, char *argv[])
 				cli_classic_abort_usage();
 			}
 			if (dont_verify_it) {
-				fprintf(stderr, "--verify and --noverify are"
-					"mutually exclusive. Aborting.\n");
+				fprintf(stderr, "--verify and --noverify are mutually exclusive. Aborting.\n");
 				cli_classic_abort_usage();
 			}
 			filename = strdup(optarg);
@@ -184,8 +183,7 @@ int main(int argc, char *argv[])
 			break;
 		case 'n':
 			if (verify_it) {
-				fprintf(stderr, "--verify and --noverify are"
-					"mutually exclusive. Aborting.\n");
+				fprintf(stderr, "--verify and --noverify are mutually exclusive. Aborting.\n");
 				cli_classic_abort_usage();
 			}
 			dont_verify_it = 1;
diff --git a/flashrom.c b/flashrom.c
index db5b1c7..41e7bd8 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -335,6 +335,9 @@ struct shutdown_func_data {
  */
 static int may_register_shutdown = 0;
 
+/* Did we change something or was every erase/write skipped (if any)? */
+static bool all_skipped = true;
+
 static int check_block_eraser(const struct flashctx *flash, int k, int log);
 
 /* Register a function to be executed on programmer shutdown.
@@ -1309,7 +1312,6 @@ static int selfcheck_eraseblocks(const struct flashchip *chip)
 	return ret;
 }
 
-static bool all_skipped = true;
 static int erase_and_write_block_helper(struct flashctx *flash,
 					unsigned int start, unsigned int len,
 					uint8_t *curcontents,
@@ -1995,7 +1997,8 @@ int doit(struct flashctx *flash, int force, const char *filename, int read_it,
 		}
 	}
 
-	if (verify_it && !all_skipped) {
+	/* Verify only if we either did not try to write (verify operation) or actually changed something. */
+	if (verify_it && (!write_it || !all_skipped)) {
 		msg_cinfo("Verifying flash... ");
 
 		if (write_it) {
-- 
Kind regards, Stefan Tauner





More information about the flashrom mailing list