Use improved abstraction for verify_range(). The new abstraction can handle out-of-band chip communication protocols as well. Check SPI chip erase results with check_erased_range().
Signed-off-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Index: flashrom-check_erased_range_use_flash_read/spi.c =================================================================== --- flashrom-check_erased_range_use_flash_read/spi.c (Revision 602) +++ flashrom-check_erased_range_use_flash_read/spi.c (Arbeitskopie) @@ -430,6 +430,10 @@ /* FIXME: We assume spi_read_status_register will never fail. */ while (spi_read_status_register() & JEDEC_RDSR_BIT_WIP) programmer_delay(1000 * 1000); + if (check_erased_range(flash, 0, flash->total_size * 1024)) { + fprintf(stderr, "ERASE FAILED!\n"); + return -1; + } return 0; }
@@ -458,6 +462,10 @@ /* FIXME: We assume spi_read_status_register will never fail. */ while (spi_read_status_register() & JEDEC_RDSR_BIT_WIP) programmer_delay(1000 * 1000); + if (check_erased_range(flash, 0, flash->total_size * 1024)) { + fprintf(stderr, "ERASE FAILED!\n"); + return -1; + } return 0; }
Index: flashrom-check_erased_range_use_flash_read/flashrom.c =================================================================== --- flashrom-check_erased_range_use_flash_read/flashrom.c (Revision 602) +++ flashrom-check_erased_range_use_flash_read/flashrom.c (Arbeitskopie) @@ -262,7 +262,6 @@ int verify_range(struct flashchip *flash, uint8_t *cmpbuf, int start, int len, char *message) { int i, j, starthere, lenhere, ret = 0; - chipaddr bios = flash->virtual_memory; int page_size = flash->page_size; uint8_t *readbuf = malloc(page_size);
@@ -298,7 +297,7 @@ starthere = max(start, i * page_size); /* Length of bytes in the range in this page. */ lenhere = min(start + len, (i + 1) * page_size) - starthere; - chip_readn(readbuf, bios + starthere, lenhere); + flash->read(flash, readbuf, starthere, lenhere); for (j = 0; j < lenhere; j++) { if (cmpbuf[starthere - start + j] != readbuf[j]) { fprintf(stderr, "%s FAILED at 0x%08x! "