summaryrefslogtreecommitdiffstats
path: root/sst_fwhub.c
diff options
context:
space:
mode:
authorCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2009-06-15 17:23:36 +0000
committerCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2009-06-15 17:23:36 +0000
commit30f7cb2f3c570c99b61bd5df72621f44f1bdd0d0 (patch)
treed714754c298d7d247786e19c4b2b4afd6067a795 /sst_fwhub.c
parent084546449983c1d6f147c1a3e381e225887e322c (diff)
downloadflashrom-30f7cb2f3c570c99b61bd5df72621f44f1bdd0d0.tar.gz
flashrom-30f7cb2f3c570c99b61bd5df72621f44f1bdd0d0.tar.bz2
flashrom-30f7cb2f3c570c99b61bd5df72621f44f1bdd0d0.zip
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>
Diffstat (limited to 'sst_fwhub.c')
-rw-r--r--sst_fwhub.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/sst_fwhub.c b/sst_fwhub.c
index 5fbacdd3d..e7ae9e93e 100644
--- a/sst_fwhub.c
+++ b/sst_fwhub.c
@@ -94,7 +94,7 @@ int probe_sst_fwhub(struct flashchip *flash)
return 1;
}
-int erase_sst_fwhub_block(struct flashchip *flash, int offset)
+int erase_sst_fwhub_block(struct flashchip *flash, int offset, int page_size)
{
uint8_t blockstatus = clear_sst_fwhub_block_lock(flash, offset);
@@ -104,7 +104,10 @@ int erase_sst_fwhub_block(struct flashchip *flash, int offset)
return 1;
}
- erase_block_jedec(flash->virtual_memory, offset);
+ if (erase_block_jedec(flash, offset, page_size)) {
+ fprintf(stderr, "ERASE FAILED!\n");
+ return -1;
+ }
toggle_ready_jedec(flash->virtual_memory);
return 0;
@@ -114,15 +117,10 @@ int erase_sst_fwhub(struct flashchip *flash)
{
int i;
unsigned int total_size = flash->total_size * 1024;
- chipaddr bios = flash->virtual_memory;
- for (i = 0; i < total_size; i += flash->page_size)
- erase_sst_fwhub_block(flash, i);
-
- // dumb check if erase was successful.
- for (i = 0; i < total_size; i++) {
- if (chip_readb(bios + i) != 0xff) {
- printf("ERASE FAILED!\n");
+ for (i = 0; i < total_size; i += flash->page_size) {
+ if (erase_sst_fwhub_block(flash, i, flash->page_size)) {
+ fprintf(stderr, "ERASE FAILED!\n");
return -1;
}
}
@@ -139,8 +137,10 @@ int write_sst_fwhub(struct flashchip *flash, uint8_t *buf)
uint8_t blockstatus;
// FIXME: We want block wide erase instead of ironing the whole chip
- if (erase_sst_fwhub(flash))
+ if (erase_sst_fwhub(flash)) {
+ fprintf(stderr, "ERASE FAILED!\n");
return -1;
+ }
printf("Programming page: ");
for (i = 0; i < total_size / page_size; i++) {