Flashrom only checks for very few chips if the erase worked
And even when it checks if the erase worked, the result of that check is
often ignored.
Convert all erase functions and actually check return codes
almost everywhere.
Check inside all erase_* routines if erase worked, not outside.
erase_sector_jedec and erase_block_jedec have changed prototypes to
enable erase checking.
Uwe successfully tested LPC on an CK804 box and SPI on some SB600 box.
Corresponding to flashrom svn r595.
Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Signed-off-by: Urja Rannikko <urjaman@gmail.com>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
diff --git a/am29f040b.c b/am29f040b.c
index 2dc4c36..7f1269c 100644
--- a/am29f040b.c
+++ b/am29f040b.c
@@ -20,8 +20,11 @@
#include "flash.h"
-static int erase_sector_29f040b(chipaddr bios, unsigned long address)
+static int erase_sector_29f040b(struct flashchip *flash, unsigned long address)
{
+ int page_size = flash->page_size;
+ chipaddr bios = flash->virtual_memory;
+
chip_writeb(0xAA, bios + 0x555);
chip_writeb(0x55, bios + 0x2AA);
chip_writeb(0x80, bios + 0x555);
@@ -34,6 +37,10 @@
/* wait for Toggle bit ready */
toggle_ready_jedec(bios + address);
+ if (check_erased_range(flash, address, page_size)) {
+ fprintf(stderr, "ERASE FAILED!\n");
+ return -1;
+ }
return 0;
}
@@ -86,6 +93,7 @@
int erase_29f040b(struct flashchip *flash)
{
+ int total_size = flash->total_size * 1024;
chipaddr bios = flash->virtual_memory;
chip_writeb(0xAA, bios + 0x555);
@@ -98,6 +106,10 @@
programmer_delay(10);
toggle_ready_jedec(bios);
+ if (check_erased_range(flash, 0, total_size)) {
+ fprintf(stderr, "ERASE FAILED!\n");
+ return -1;
+ }
return 0;
}
@@ -111,7 +123,10 @@
printf("Programming page ");
for (i = 0; i < total_size / page_size; i++) {
/* erase the page before programming */
- erase_sector_29f040b(bios, i * page_size);
+ if (erase_sector_29f040b(flash, i * page_size)) {
+ fprintf(stderr, "ERASE FAILED!\n");
+ return -1;
+ }
/* write to the sector */
printf("%04d at address: ", i);