mirror of
https://review.coreboot.org/flashrom.git
synced 2025-07-02 22:43:17 +02:00
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>
This commit is contained in:
19
am29f040b.c
19
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 @@ static int erase_sector_29f040b(chipaddr bios, unsigned long address)
|
||||
/* 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 probe_29f040b(struct flashchip *flash)
|
||||
|
||||
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 @@ int erase_29f040b(struct flashchip *flash)
|
||||
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 @@ int write_29f040b(struct flashchip *flash, uint8_t *buf)
|
||||
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);
|
||||
|
Reference in New Issue
Block a user