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@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,
Hi Stephan,
On 26.05.2009 02:51, Stephan GUILLOUX wrote:
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.
Signed-off-by: Stephan Guilloux stephan.guilloux@free.fr
Index: flashrom-read-return-code/trunk/it87spi.c [...] Index: flashrom-read-return-code/trunk/sb600spi.c [...]
I just sent a patch which refactors reading and probably conflicts with this part of your patch.
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 @@
- if (flash->read(flash, buf2)) {
printf("FAILED!\n");
fprintf(stderr, "ERROR : flashrom cannot read this flash chip.\n");
This error message is misleading. It's not the fault of the flash chip. I think the "FAILED" output is enough.
@@ -286,15 +293,28 @@
- if (flash->erase(flash)) {
printf("FAILED!\n");
fprintf(stderr, "ERROR: flashrom cannot erase this flash chip.\n");
Same here and in other places in the patch.
Can you take a look at my patch and check if it fixes the issues you pointed out in the first part of your patch?
Can you resubmit the second part of your patch with changed error messages?
Thanks.
Regards, Carl-Daniel