summaryrefslogtreecommitdiffstats
path: root/flashrom.c
diff options
context:
space:
mode:
authorPeter Stuge <peter@stuge.se>2008-12-05 02:22:30 +0000
committerPeter Stuge <peter@stuge.se>2008-12-05 02:22:30 +0000
commitf0c811dd15d09bee9c5ff34ed96930b3720a6f79 (patch)
tree3f3bf981b01be6ba1c5330dc6289eabdd9678ce7 /flashrom.c
parent052cdc337e0c57156d6eb6ea36d707a232a2fa1a (diff)
downloadast2050-flashrom-f0c811dd15d09bee9c5ff34ed96930b3720a6f79.zip
ast2050-flashrom-f0c811dd15d09bee9c5ff34ed96930b3720a6f79.tar.gz
Check if erase succeeds and exit with error on failure
Flashrom used to exit 0 even if erase failed. Not anymore. Corresponding to flashrom svn r359 and coreboot v2 svn r3797. Signed-off-by: Peter Stuge <peter@stuge.se> Acked-by: Stefan Reinauer <stepan@coresystems.de>
Diffstat (limited to 'flashrom.c')
-rw-r--r--flashrom.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/flashrom.c b/flashrom.c
index a75e452..4dd2ea1 100644
--- a/flashrom.c
+++ b/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);
OpenPOWER on IntegriCloud