diff options
author | Peter Stuge <peter@stuge.se> | 2008-12-05 02:22:30 +0000 |
---|---|---|
committer | Peter Stuge <peter@stuge.se> | 2008-12-05 02:22:30 +0000 |
commit | b4b56e669b910d8595eae6af21b3e86dc3d26c9d (patch) | |
tree | fcae755a6ba9fcf0f3c76ddd2a81dd3d21f1b5dd /util | |
parent | e94e2e3d406af2b9c45fba2ecc16643307213c72 (diff) | |
download | coreboot-b4b56e669b910d8595eae6af21b3e86dc3d26c9d.tar.xz |
flashrom: Check if erase succeeds and exit with error on failure.
flashrom used to exit 0 even if erase failed. Not anymore.
Signed-off-by: Peter Stuge <peter@stuge.se>
Acked-by: Stefan Reinauer <stepan@coresystems.de>
git-svn-id: svn://svn.coreboot.org/coreboot/trunk@3797 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'util')
-rw-r--r-- | util/flashrom/flashrom.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/util/flashrom/flashrom.c b/util/flashrom/flashrom.c index a75e452927..4dd2ea1250 100644 --- a/util/flashrom/flashrom.c +++ b/util/flashrom/flashrom.c @@ -250,6 +250,7 @@ int main(int argc, char *argv[]) { uint8_t *buf; unsigned long size; + size_t erasedbytes; FILE *image; /* Probe for up to three flash chips. */ struct flashchip *flash, *flashes[3]; @@ -533,13 +534,25 @@ int main(int argc, char *argv[]) if (erase_it) { printf("Erasing flash chip... "); - if (!flash->erase) { - fprintf(stderr, "Error: flashrom has no erase function for this flash chip.\n"); + if (NULL == flash->erase) { + printf("FAILED!\n"); + fprintf(stderr, "ERROR: flashrom has no erase function for this flash chip.\n"); return 1; } flash->erase(flash); - printf("done.\n"); - exit(0); + if (NULL == flash->read) + memcpy(buf, (const char *)flash->virtual_memory, size); + else + flash->read(flash, buf); + for (erasedbytes = 0; erasedbytes <= size; erasedbytes++) + if (0xff != buf[erasedbytes]) { + printf("FAILED!\n"); + fprintf(stderr, "ERROR at 0x%08x: Expected=0xff, Read=0x%02x\n", + erasedbytes, buf[erasedbytes]); + return 1; + } + printf("SUCCESS.\n"); + return 0; } else if (read_it) { if ((image = fopen(filename, "w")) == NULL) { perror(filename); |