Hello,
A last patch for tonight, to use chips read/erase return codes. erase()
is not
fully modified, though.
flash_read() is unchanged, as I also have a patch pending in this area.
Make good use of it ;-)
Stephan.
Signed-off-by: Stephan Guilloux <stephan.guilloux(a)free.fr>
Index: flashrom-read-return-code/trunk/it87spi.c
===================================================================
--- flashrom-read-return-code/trunk/it87spi.c (révision 547)
+++ flashrom-read-return-code/trunk/it87spi.c (copie de travail)
@@ -238,21 +238,22 @@
int it8716f_spi_chip_read(struct flashchip *flash, uint8_t *buf)
{
int total_size = 1024 * flash->total_size;
+ int rc = 0;
int i;
fast_spi = 0;
if (total_size > 512 * 1024) {
- for (i = 0; i < total_size; i += 3) {
+ for (i = 0; (i < total_size) && (rc == 0); i += 3) {
int toread = 3;
if (total_size - i < toread)
toread = total_size - i;
- spi_nbyte_read(i, buf + i, toread);
+ rc = spi_nbyte_read(i, buf + i, toread);
}
} else {
memcpy(buf, (const char *)flash->virtual_memory, total_size);
}
- return 0;
+ return rc;
}
int it8716f_spi_chip_write_256(struct flashchip *flash, uint8_t *buf)
Index: flashrom-read-return-code/trunk/sb600spi.c
===================================================================
--- flashrom-read-return-code/trunk/sb600spi.c (révision 547)
+++ flashrom-read-return-code/trunk/sb600spi.c (copie de travail)
@@ -45,9 +45,9 @@
int total_size = flash->total_size * 1024;
int page_size = 8;
- for (i = 0; i < total_size / page_size; i++)
- spi_nbyte_read(i * page_size, (void *)(buf + i * page_size),
- page_size);
+ for (i = 0; (i < total_size / page_size) && (rc == 0); i++)
+ rc = spi_nbyte_read(i * page_size, (void *)(buf + i * page_size),
+ page_size);
return rc;
}
Index: flashrom-read-return-code/trunk/flashrom.c
===================================================================
--- flashrom-read-return-code/trunk/flashrom.c (révision 547)
+++ flashrom-read-return-code/trunk/flashrom.c (copie de travail)
@@ -208,12 +208,19 @@
int idx;
int total_size = flash->total_size * 1024;
uint8_t *buf2 = (uint8_t *) calloc(total_size, sizeof(char));
+
+ printf ("Reading flash... ");
if (!flash->read) {
printf("FAILED!\n");
fprintf(stderr, "ERROR: flashrom has no read function for this
flash chip.\n");
return 1;
- } else
- flash->read(flash, buf2);
+ }
+ if (flash->read(flash, buf2)) {
+ printf("FAILED!\n");
+ fprintf(stderr, "ERROR : flashrom cannot read this flash chip.\n");
+ return 1;
+ }
+ printf ("passed\n");
printf("Verifying flash... ");
@@ -286,15 +293,28 @@
fprintf(stderr, "ERROR: flashrom has no erase function for this
flash chip.\n");
return 1;
}
- flash->erase(flash);
+ if (flash->erase(flash)) {
+ printf("FAILED!\n");
+ fprintf(stderr, "ERROR: flashrom cannot erase this flash chip.\n");
+ return 1;
+ }
+ printf ("passed.\n");
if (!flash->read) {
printf("FAILED!\n");
fprintf(stderr, "ERROR: flashrom has no read function for this
flash chip.\n");
return 1;
- } else
- flash->read(flash, buf);
+ }
+ printf ("Reading flash... ");
+ if (flash->read(flash, buf)) {
+ printf("FAILED!\n");
+ fprintf(stderr, "ERROR: flashrom cannot read this flash chip.\n");
+ return 1;
+ }
+ printf ("passed.\n");
+
+ printf ("Checking... ");
for (erasedbytes = 0; erasedbytes < size; erasedbytes++)
if (0xff != buf[erasedbytes]) {
printf("FAILED!\n");
@@ -618,8 +638,12 @@
printf("FAILED!\n");
fprintf(stderr, "ERROR: flashrom has no read function
for this flash chip.\n");
return 1;
- } else
- flashes[0]->read(flashes[0], buf);
+ }
+ if (flashes[0]->read(flashes[0], buf)) {
+ printf("FAILED!\n");
+ fprintf(stderr, "ERROR : flashrom cannot read this
flash chip.\n");
+ return 1;
+ }
if (exclude_end_position - exclude_start_position > 0)
memset(buf + exclude_start_position, 0,