summaryrefslogtreecommitdiffstats
path: root/m29f400bt.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 /m29f400bt.c
parent084546449983c1d6f147c1a3e381e225887e322c (diff)
downloadast2050-flashrom-30f7cb2f3c570c99b61bd5df72621f44f1bdd0d0.zip
ast2050-flashrom-30f7cb2f3c570c99b61bd5df72621f44f1bdd0d0.tar.gz
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 'm29f400bt.c')
-rw-r--r--m29f400bt.c57
1 files changed, 47 insertions, 10 deletions
diff --git a/m29f400bt.c b/m29f400bt.c
index 85f9dc0..ace6dae 100644
--- a/m29f400bt.c
+++ b/m29f400bt.c
@@ -98,11 +98,17 @@ int erase_m29f400bt(struct flashchip *flash)
programmer_delay(10);
toggle_ready_jedec(bios);
+ if (check_erased_range(flash, 0, flash->total_size * 1024)) {
+ fprintf(stderr, "ERASE FAILED!\n");
+ return -1;
+ }
return 0;
}
-int block_erase_m29f400bt(chipaddr bios, chipaddr dst)
+int block_erase_m29f400bt(struct flashchip *flash, int start, int len)
{
+ chipaddr bios = flash->virtual_memory;
+ chipaddr dst = bios + start;
chip_writeb(0xAA, bios + 0xAAA);
chip_writeb(0x55, bios + 0x555);
@@ -116,6 +122,10 @@ int block_erase_m29f400bt(chipaddr bios, chipaddr dst)
programmer_delay(10);
toggle_ready_jedec(bios);
+ if (check_erased_range(flash, start, len)) {
+ fprintf(stderr, "ERASE FAILED!\n");
+ return -1;
+ }
return 0;
}
@@ -146,26 +156,41 @@ int write_m29f400bt(struct flashchip *flash, uint8_t *buf)
printf("total_size/page_size = %d\n", total_size / page_size);
for (i = 0; i < (total_size / page_size) - 1; i++) {
printf("%04d at address: 0x%08x\n", i, i * page_size);
- block_erase_m29f400bt(bios, bios + i * page_size);
+ if (block_erase_m29f400bt(flash, i * page_size, page_size)) {
+ fprintf(stderr, "ERASE FAILED!\n");
+ return -1;
+ }
write_page_m29f400bt(bios, buf + i * page_size,
bios + i * page_size, page_size);
printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
}
printf("%04d at address: 0x%08x\n", 7, 0x70000);
- block_erase_m29f400bt(bios, bios + 0x70000);
+ if (block_erase_m29f400bt(flash, 0x70000, 32 * 1024)) {
+ fprintf(stderr, "ERASE FAILED!\n");
+ return -1;
+ }
write_page_m29f400bt(bios, buf + 0x70000, bios + 0x70000, 32 * 1024);
printf("%04d at address: 0x%08x\n", 8, 0x78000);
- block_erase_m29f400bt(bios, bios + 0x78000);
+ if (block_erase_m29f400bt(flash, 0x78000, 8 * 1024)) {
+ fprintf(stderr, "ERASE FAILED!\n");
+ return -1;
+ }
write_page_m29f400bt(bios, buf + 0x78000, bios + 0x78000, 8 * 1024);
printf("%04d at address: 0x%08x\n", 9, 0x7a000);
- block_erase_m29f400bt(bios, bios + 0x7a000);
+ if (block_erase_m29f400bt(flash, 0x7a000, 8 * 1024)) {
+ fprintf(stderr, "ERASE FAILED!\n");
+ return -1;
+ }
write_page_m29f400bt(bios, buf + 0x7a000, bios + 0x7a000, 8 * 1024);
printf("%04d at address: 0x%08x\n", 10, 0x7c000);
- block_erase_m29f400bt(bios, bios + 0x7c000);
+ if (block_erase_m29f400bt(flash, 0x7c000, 16 * 1024)) {
+ fprintf(stderr, "ERASE FAILED!\n");
+ return -1;
+ }
write_page_m29f400bt(bios, buf + 0x7c000, bios + 0x7c000, 16 * 1024);
printf("\n");
@@ -195,19 +220,31 @@ int write_coreboot_m29f400bt(struct flashchip *flash, uint8_t *buf)
* 64 0x00000 0x0ffff BOTTOM
*********************************/
printf("%04d at address: 0x%08x\n", 7, 0x00000);
- block_erase_m29f400bt(bios, bios + 0x00000);
+ if (block_erase_m29f400bt(flash, 0x00000, 64 * 1024)) {
+ fprintf(stderr, "ERASE FAILED!\n");
+ return -1;
+ }
write_page_m29f400bt(bios, buf + 0x00000, bios + 0x00000, 64 * 1024);
printf("%04d at address: 0x%08x\n", 7, 0x10000);
- block_erase_m29f400bt(bios, bios + 0x10000);
+ if (block_erase_m29f400bt(flash, 0x10000, 64 * 1024)) {
+ fprintf(stderr, "ERASE FAILED!\n");
+ return -1;
+ }
write_page_m29f400bt(bios, buf + 0x10000, bios + 0x10000, 64 * 1024);
printf("%04d at address: 0x%08x\n", 7, 0x20000);
- block_erase_m29f400bt(bios, bios + 0x20000);
+ if (block_erase_m29f400bt(flash, 0x20000, 64 * 1024)) {
+ fprintf(stderr, "ERASE FAILED!\n");
+ return -1;
+ }
write_page_m29f400bt(bios, buf + 0x20000, bios + 0x20000, 64 * 1024);
printf("%04d at address: 0x%08x\n", 7, 0x30000);
- block_erase_m29f400bt(bios, bios + 0x30000);
+ if (block_erase_m29f400bt(flash, 0x30000, 64 * 1024)) {
+ fprintf(stderr, "ERASE FAILED!\n");
+ return -1;
+ }
write_page_m29f400bt(bios, buf + 0x30000, bios + 0x30000, 64 * 1024);
printf("\n");
OpenPOWER on IntegriCloud