Commit 84d19682 authored by Carl-Daniel Hailfinger's avatar Carl-Daniel Hailfinger Committed by Stefan Tauner
Browse files

Fix output of erase_and_write_flash and surroundings

See http://www.flashrom.org/pipermail/flashrom/2011-July/007220.html


for a discussion about the details.

Corresponding to flashrom svn r1392.
Signed-off-by: default avatarCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Signed-off-by: default avatarStefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: default avatarCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: default avatarStefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
parent 2e88a9f4
...@@ -1471,7 +1471,6 @@ static int walk_eraseregions(struct flashchip *flash, int erasefunction, ...@@ -1471,7 +1471,6 @@ static int walk_eraseregions(struct flashchip *flash, int erasefunction,
start + len - 1); start + len - 1);
if (do_something(flash, start, len, param1, param2, if (do_something(flash, start, len, param1, param2,
eraser.block_erase)) { eraser.block_erase)) {
msg_cdbg("\n");
return 1; return 1;
} }
start += len; start += len;
...@@ -1522,19 +1521,18 @@ int erase_and_write_flash(struct flashchip *flash, uint8_t *oldcontents, uint8_t ...@@ -1522,19 +1521,18 @@ int erase_and_write_flash(struct flashchip *flash, uint8_t *oldcontents, uint8_t
memcpy(curcontents, oldcontents, size); memcpy(curcontents, oldcontents, size);
for (k = 0; k < NUM_ERASEFUNCTIONS; k++) { for (k = 0; k < NUM_ERASEFUNCTIONS; k++) {
if (k != 0)
msg_cdbg("Looking for another erase function.\n");
if (!usable_erasefunctions) { if (!usable_erasefunctions) {
msg_cdbg("No usable erase functions left.\n"); msg_cdbg("No usable erase functions left.\n");
break; break;
} }
msg_cdbg("Looking at blockwise erase function %i... ", k); msg_cdbg("Trying erase function %i... ", k);
if (check_block_eraser(flash, k, 1)) { if (check_block_eraser(flash, k, 1))
msg_cdbg("Looking for another erase function.\n");
continue; continue;
}
usable_erasefunctions--; usable_erasefunctions--;
msg_cdbg("trying... "); ret = walk_eraseregions(flash, k, &erase_and_write_block_helper,
ret = walk_eraseregions(flash, k, &erase_and_write_block_helper, curcontents, newcontents); curcontents, newcontents);
msg_cdbg("\n");
/* If everything is OK, don't try another erase function. */ /* If everything is OK, don't try another erase function. */
if (!ret) if (!ret)
break; break;
...@@ -1544,14 +1542,19 @@ int erase_and_write_flash(struct flashchip *flash, uint8_t *oldcontents, uint8_t ...@@ -1544,14 +1542,19 @@ int erase_and_write_flash(struct flashchip *flash, uint8_t *oldcontents, uint8_t
*/ */
if (!usable_erasefunctions) if (!usable_erasefunctions)
continue; continue;
/* Reading the whole chip may take a while, inform the user even
* in non-verbose mode.
*/
msg_cinfo("Reading current flash chip contents... ");
if (flash->read(flash, curcontents, 0, size)) { if (flash->read(flash, curcontents, 0, size)) {
/* Now we are truly screwed. Read failed as well. */ /* Now we are truly screwed. Read failed as well. */
msg_cerr("Can't read anymore!\n"); msg_cerr("Can't read anymore! Aborting.\n");
/* We have no idea about the flash chip contents, so /* We have no idea about the flash chip contents, so
* retrying with another erase function is pointless. * retrying with another erase function is pointless.
*/ */
break; break;
} }
msg_cinfo("done. ");
} }
/* Free the scratchpad. */ /* Free the scratchpad. */
free(curcontents); free(curcontents);
...@@ -1559,7 +1562,7 @@ int erase_and_write_flash(struct flashchip *flash, uint8_t *oldcontents, uint8_t ...@@ -1559,7 +1562,7 @@ int erase_and_write_flash(struct flashchip *flash, uint8_t *oldcontents, uint8_t
if (ret) { if (ret) {
msg_cerr("FAILED!\n"); msg_cerr("FAILED!\n");
} else { } else {
msg_cinfo("Done.\n"); msg_cinfo("Erase/write done.\n");
} }
return ret; return ret;
} }
...@@ -1938,13 +1941,13 @@ int doit(struct flashchip *flash, int force, const char *filename, int read_it, ...@@ -1938,13 +1941,13 @@ int doit(struct flashchip *flash, int force, const char *filename, int read_it,
* preserved, but in that case we might perform unneeded erase which * preserved, but in that case we might perform unneeded erase which
* takes time as well. * takes time as well.
*/ */
msg_cdbg("Reading old flash chip contents... "); msg_cinfo("Reading old flash chip contents... ");
if (flash->read(flash, oldcontents, 0, size)) { if (flash->read(flash, oldcontents, 0, size)) {
ret = 1; ret = 1;
msg_cdbg("FAILED.\n"); msg_cinfo("FAILED.\n");
goto out; goto out;
} }
msg_cdbg("done.\n"); msg_cinfo("done.\n");
// This should be moved into each flash part's code to do it // This should be moved into each flash part's code to do it
// cleanly. This does the job. // cleanly. This does the job.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment