diff options
author | Li-Ta Lo <ollie@lanl.gov> | 2004-03-27 00:18:15 +0000 |
---|---|---|
committer | Li-Ta Lo <ollie@lanl.gov> | 2004-03-27 00:18:15 +0000 |
commit | 39daaac582766e94a6f2f8ad00900e623d514d7a (patch) | |
tree | cc57154b046ac9a4c48c92f275b3ca2cb7169142 /util | |
parent | 4cd79f3f86e5b57419932917750b022989e36b0c (diff) |
removed false alarm of erase/write, use verify '-v' if you are not sure about the integrity
git-svn-id: svn://svn.coreboot.org/coreboot/trunk@1486 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'util')
-rw-r--r-- | util/flash_and_burn/flash.h | 2 | ||||
-rw-r--r-- | util/flash_and_burn/flash_enable.c | 44 | ||||
-rw-r--r-- | util/flash_and_burn/flash_rom.c | 90 | ||||
-rw-r--r-- | util/flash_and_burn/jedec.c | 21 | ||||
-rw-r--r-- | util/flash_and_burn/jedec.h | 4 | ||||
-rw-r--r-- | util/flash_and_burn/pm49fl004.c | 44 | ||||
-rw-r--r-- | util/flash_and_burn/sst28sf040.c | 3 | ||||
-rw-r--r-- | util/flash_and_burn/sst49lf040.c | 7 |
8 files changed, 77 insertions, 138 deletions
diff --git a/util/flash_and_burn/flash.h b/util/flash_and_burn/flash.h index f5ecbf25e3..3dfefe259a 100644 --- a/util/flash_and_burn/flash.h +++ b/util/flash_and_burn/flash.h @@ -31,7 +31,7 @@ struct flashchip { #define MX_ID 0xC2 #define MX_29F002 0xB0 -#define SST_ID 0xBF /* SST Manufacturer ID[B code */ +#define SST_ID 0xBF /* SST Manufacturer ID code */ #define SST_29EE020A 0x10 /* SST 29EE020 device code */ #define SST_28SF040 0x04 /* SST 29EE040 device code */ #define SST_39SF020 0xB6 /* SST 39SF020 device */ diff --git a/util/flash_and_burn/flash_enable.c b/util/flash_and_burn/flash_enable.c index 02861f153d..67819da875 100644 --- a/util/flash_and_burn/flash_enable.c +++ b/util/flash_and_burn/flash_enable.c @@ -75,9 +75,8 @@ static int enable_flash_e7500(struct pci_dev *dev, char *name) pci_write_byte(dev, 0x4e, new); if (pci_read_byte(dev, 0x4e) != new) { - printf - ("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n", - 0x4e, new, name); + printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n", + 0x4e, new, name); return -1; } return 0; @@ -104,15 +103,12 @@ static int enable_flash_vt8235(struct pci_dev *dev, char *name) ok = pci_write_byte(dev, 0x40, new); if (ok != 0) { - printf - ("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n", - old, new, name); + printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n", + old, new, name); } /* enable GPIO15 which is connected to write protect. */ - base = - ((pci_read_byte(dev, 0x88) & 0x80) | pci_read_byte(dev, 0x89) - << 8); + base = ((pci_read_byte(dev, 0x88) & 0x80) | pci_read_byte(dev, 0x89) << 8); val = inb(base + 0x4d); val |= 0x80; outb(val, base + 0x4d); @@ -133,9 +129,8 @@ static int enable_flash_vt8231(struct pci_dev *dev, char *name) pci_write_byte(dev, 0x40, val); if (pci_read_byte(dev, 0x40) != val) { - printf - ("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n", - 0x40, val, name); + printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n", + 0x40, val, name); return -1; } return 0; @@ -150,9 +145,8 @@ static int enable_flash_cs5530(struct pci_dev *dev, char *name) new = pci_read_byte(dev, 0x52); if (new != 0xee) { - printf - ("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n", - 0x52, new, name); + printf("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n", + 0x52, new, name); return -1; } return 0; @@ -167,9 +161,8 @@ static int enable_flash_sc1100(struct pci_dev *dev, char *name) new = pci_read_byte(dev, 0x52); if (new != 0xee) { - printf - ("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n", - 0x52, new, name); + printf("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n", + 0x52, new, name); return -1; } return 0; @@ -190,9 +183,8 @@ static int enable_flash_sis5595(struct pci_dev *dev, char *name) newer = pci_read_byte(dev, 0x45); if (newer != new) { - printf - ("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n", - 0x45, new, name); + printf("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n", + 0x45, new, name); printf("Stuck at 0x%x\n", newer); return -1; } @@ -214,9 +206,8 @@ static int enable_flash_amd8111(struct pci_dev *dev, char *name) if (new != old) { pci_write_byte(dev, 0x43, new); if (pci_read_byte(dev, 0x43) != new) { - printf - ("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n", - 0x43, new, name); + printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n", + 0x43, new, name); } } @@ -227,9 +218,8 @@ static int enable_flash_amd8111(struct pci_dev *dev, char *name) pci_write_byte(dev, 0x40, new); if (pci_read_byte(dev, 0x40) != new) { - printf - ("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n", - 0x40, new, name); + printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n", + 0x40, new, name); return -1; } return 0; diff --git a/util/flash_and_burn/flash_rom.c b/util/flash_and_burn/flash_rom.c index dff8d182d7..4ce5d8bdc9 100644 --- a/util/flash_and_burn/flash_rom.c +++ b/util/flash_and_burn/flash_rom.c @@ -48,47 +48,46 @@ #include "mx29f002.h" struct flashchip flashchips[] = { - {"Am29F040B", AMD_ID, AM_29F040B, NULL, 512, 64 * 1024, - probe_29f040b, erase_29f040b, write_29f040b, NULL}, - {"At29C040A", ATMEL_ID, AT_29C040A, NULL, 512, 256, - probe_jedec, erase_chip_jedec, write_jedec, NULL}, - {"Mx29f002", MX_ID, MX_29F002, NULL, 256, 64 * 1024, - probe_29f002, erase_29f002, write_29f002, NULL}, - {"SST29EE020A", SST_ID, SST_29EE020A, NULL, 256, 128, - probe_jedec, erase_chip_jedec, write_jedec, NULL}, - {"SST28SF040A", SST_ID, SST_28SF040, NULL, 512, 256, - probe_28sf040, erase_28sf040, write_28sf040, NULL}, - {"SST39SF020A", SST_ID, SST_39SF020, NULL, 256, 4096, - probe_jedec, erase_chip_jedec, write_39sf020, NULL}, - {"SST39VF020", SST_ID, SST_39VF020, NULL, 256, 4096, - probe_jedec, erase_chip_jedec, write_39sf020, NULL}, - {"SST49LF040", SST_ID, SST_49LF040, NULL, 512, 4096, - probe_jedec, erase_chip_jedec, write_49lf040, NULL}, - {"SST49LF080A", SST_ID, SST_49LF080A, NULL, 1024, 4096, - probe_jedec, erase_chip_jedec, write_49lf040, NULL}, - {"SST49LF002A", SST_ID, SST_49LF002A, NULL, 256, 4096, - probe_jedec, erase_chip_jedec, write_49lf040, NULL}, - {"SST49LF003A", SST_ID, SST_49LF003A, NULL, 384, 4096, - probe_jedec, erase_chip_jedec, write_49lf040, NULL}, - {"SST49LF004A", SST_ID, SST_49LF004A, NULL, 512, 4096, - probe_jedec, erase_chip_jedec, write_49lf040, NULL}, - {"SST49LF008A", SST_ID, SST_49LF008A, NULL, 1024, 4096, - probe_jedec, erase_chip_jedec, write_49lf040, NULL}, - {"Pm49FL004", PMC_ID, PMC_49FL004, NULL, 512, 64 * 1024, - probe_jedec, erase_chip_jedec, write_49fl004, NULL}, - {"W29C011", WINBOND_ID, W_29C011, NULL, 128, 128, - probe_jedec, erase_chip_jedec, write_jedec, NULL}, - {"W29C020C", WINBOND_ID, W_29C020C, NULL, 256, 128, - probe_jedec, erase_chip_jedec, write_jedec, NULL}, - {"W49F002U", WINBOND_ID, W_49F002U, NULL, 256, 128, - probe_jedec, erase_chip_jedec, write_49f002, NULL}, - {"M29F400BT", ST_ID, ST_M29F400BT, NULL, 512, 64 * 1024, - probe_m29f400bt, erase_m29f400bt, write_linuxbios_m29f400bt, - NULL}, - {"82802ab", 137, 173, NULL, 512, 64 * 1024, - probe_82802ab, erase_82802ab, write_82802ab, NULL}, - {"82802ac", 137, 172, NULL, 1024, 64 * 1024, - probe_82802ab, erase_82802ab, write_82802ab, NULL}, + {"Am29F040B", AMD_ID, AM_29F040B, NULL, 512, 64 * 1024, + probe_29f040b, erase_29f040b, write_29f040b, NULL}, + {"At29C040A", ATMEL_ID, AT_29C040A, NULL, 512, 256, + probe_jedec, erase_chip_jedec, write_jedec, NULL}, + {"Mx29f002", MX_ID, MX_29F002, NULL, 256, 64 * 1024, + probe_29f002, erase_29f002, write_29f002, NULL}, + {"SST29EE020A", SST_ID, SST_29EE020A, NULL, 256, 128, + probe_jedec, erase_chip_jedec, write_jedec, NULL}, + {"SST28SF040A", SST_ID, SST_28SF040, NULL, 512, 256, + probe_28sf040, erase_28sf040, write_28sf040, NULL}, + {"SST39SF020A", SST_ID, SST_39SF020, NULL, 256, 4096, + probe_jedec, erase_chip_jedec, write_39sf020,NULL}, + {"SST39VF020", SST_ID, SST_39VF020, NULL, 256, 4096, + probe_jedec, erase_chip_jedec, write_39sf020,NULL}, + {"SST49LF040", SST_ID, SST_49LF040, NULL, 512, 4096, + probe_jedec, erase_chip_jedec, write_49lf040,NULL}, + {"SST49LF080A", SST_ID, SST_49LF080A, NULL, 1024, 4096, + probe_jedec, erase_chip_jedec, write_49lf040,NULL}, + {"SST49LF002A", SST_ID, SST_49LF002A, NULL, 256, 4096, + probe_jedec, erase_chip_jedec, write_49lf040,NULL}, + {"SST49LF003A", SST_ID, SST_49LF003A, NULL, 384, 4096, + probe_jedec, erase_chip_jedec, write_49lf040,NULL}, + {"SST49LF004A", SST_ID, SST_49LF004A, NULL, 512, 4096, + probe_jedec, erase_chip_jedec, write_49lf040,NULL}, + {"SST49LF008A", SST_ID, SST_49LF008A, NULL, 1024, 4096, + probe_jedec, erase_chip_jedec, write_49lf040,NULL}, + {"Pm49FL004", PMC_ID, PMC_49FL004, NULL, 512, 64 * 1024, + probe_jedec, erase_chip_jedec, write_49fl004,NULL}, + {"W29C011", WINBOND_ID, W_29C011, NULL, 128, 128, + probe_jedec, erase_chip_jedec, write_jedec, NULL}, + {"W29C020C", WINBOND_ID, W_29C020C, NULL, 256, 128, + probe_jedec, erase_chip_jedec, write_jedec, NULL}, + {"W49F002U", WINBOND_ID, W_49F002U, NULL, 256, 128, + probe_jedec, erase_chip_jedec, write_49f002, NULL}, + {"M29F400BT", ST_ID, ST_M29F400BT, NULL, 512, 64 * 1024, + probe_m29f400bt, erase_m29f400bt, write_linuxbios_m29f400bt, NULL}, + {"82802ab", 137, 173, NULL, 512, 64 * 1024, + probe_82802ab, erase_82802ab, write_82802ab, NULL}, + {"82802ac", 137, 172, NULL, 1024, 64 * 1024, + probe_82802ab, erase_82802ab, write_82802ab, NULL}, {"MD-2802 (M-Systems DiskOnChip Millennium Module)", MSYSTEMS_ID, MSYSTEMS_MD2802, NULL, 8, 8 * 1024, @@ -110,13 +109,11 @@ struct flashchip *probe_flash(struct flashchip *flash) } while (flash->name != NULL) { - if (chip_to_probe - && strcmp(flash->name, chip_to_probe) != 0) { + if (chip_to_probe && strcmp(flash->name, chip_to_probe) != 0) { flash++; continue; } - printf("Trying %s, %d KB\n", flash->name, - flash->total_size); + printf("Trying %s, %d KB\n", flash->name, flash->total_size); size = flash->total_size * 1024; /* BUG? what happens if getpagesize() > size!? -> ``Error MMAP /dev/mem: Invalid argument'' NIKI */ @@ -225,8 +222,7 @@ int main(int argc, char *argv[]) if (optind < argc) filename = argv[optind++]; - printf - ("Calibrating timer since microsleep sucks ... takes a second\n"); + printf("Calibrating timer since microsleep sucks ... takes a second\n"); myusec_calibrate_delay(); printf("OK, calibrated, now do the deed\n"); diff --git a/util/flash_and_burn/jedec.c b/util/flash_and_burn/jedec.c index c76339caeb..b4c069fe82 100644 --- a/util/flash_and_burn/jedec.c +++ b/util/flash_and_burn/jedec.c @@ -120,7 +120,7 @@ int erase_chip_jedec(struct flashchip *flash) return (0); } -void write_page_jedec(volatile char *bios, char *src, volatile char *dst, +void write_page_write_jedec(volatile char *bios, char *src, volatile char *dst, int page_size) { int i; @@ -139,16 +139,11 @@ void write_page_jedec(volatile char *bios, char *src, volatile char *dst, toggle_ready_jedec(dst - 1); } -int wirte_byte_program_jedec(volatile unsigned char *bios, unsigned char *src, +int write_byte_program_jedec(volatile unsigned char *bios, unsigned char *src, volatile unsigned char *dst) { volatile unsigned char *Temp; - if (*dst != 0xff) { - printf("FATAL: dst %p not erased (val 0x%x)\n", - dst, *dst); - return (-1); - } /* transfer data from source to destination */ if (*src == 0xFF) { dst++, src++; @@ -164,10 +159,7 @@ int wirte_byte_program_jedec(volatile unsigned char *bios, unsigned char *src, *Temp = 0xA0; *dst = *src; toggle_ready_jedec(bios); - if (*dst != *src) - printf("BAD! dst 0x%lx val 0x%x src 0x%x\n", - (unsigned long) dst, *dst, *src); - dst++, src++; + return 0; } @@ -178,7 +170,8 @@ int write_sector_jedec(volatile unsigned char *bios, unsigned char *src, int i; for (i = 0; i < page_size; i++) { - wirte_byte_program_jedec(bios, src, dst); + write_byte_program_jedec(bios, src, dst); + dst++, src++; } return (0); @@ -199,8 +192,8 @@ int write_jedec(struct flashchip *flash, unsigned char *buf) printf("Programming Page: "); for (i = 0; i < total_size / page_size; i++) { printf("%04d at address: 0x%08x", i, i * page_size); - write_page_jedec(bios, buf + i * page_size, - bios + i * page_size, page_size); + write_page_write_jedec(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("\n"); diff --git a/util/flash_and_burn/jedec.h b/util/flash_and_burn/jedec.h index 4a86913189..5e7bf2e135 100644 --- a/util/flash_and_burn/jedec.h +++ b/util/flash_and_burn/jedec.h @@ -17,7 +17,7 @@ extern __inline__ void toggle_ready_jedec(volatile char *dst) tmp1 = *dst & 0x40; - while (i++ < 0xFFFFFF) { + while (i++ < 0xFFFFFFF) { tmp2 = *dst & 0x40; if (tmp1 == tmp2) { break; @@ -33,7 +33,7 @@ extern __inline__ void data_polling_jedec(volatile char *dst, char data) data &= 0x80; - while (i++ < 0xFFFFFF) { + while (i++ < 0xFFFFFFF) { tmp = *dst & 0x80; if (tmp == data) { break; diff --git a/util/flash_and_burn/pm49fl004.c b/util/flash_and_burn/pm49fl004.c index 4cffc14b25..cbb1f7ef9d 100644 --- a/util/flash_and_burn/pm49fl004.c +++ b/util/flash_and_burn/pm49fl004.c @@ -55,43 +55,6 @@ static __inline__ int erase_block_49fl004(volatile unsigned char *bios, return (0); } -static __inline__ int write_block_49fl004(volatile char *bios, - unsigned char *src, - volatile unsigned char *dst, - unsigned int page_size) -{ - int i; - volatile char *Temp; - - for (i = 0; i < page_size; i++) { - if (*dst != 0xff) { - printf("FATAL: dst %p not erased (val 0x%x\n", dst, - *dst); - return (-1); - } - /* transfer data from source to destination */ - if (*src == 0xFF) { - dst++, src++; - /* If the data is 0xFF, don't program it */ - continue; - } - Temp = (bios + 0x5555); - *Temp = 0xAA; - Temp = bios + 0x2AAA; - *Temp = 0x55; - Temp = bios + 0x5555; - *Temp = 0xA0; - *dst = *src; - toggle_ready_jedec(bios); - if (*dst != *src) - printf("BAD! dst 0x%lx val 0x%x src 0x%x\n", - (unsigned long) dst, *dst, *src); - dst++, src++; - } - - return (0); -} - int write_49fl004(struct flashchip *flash, unsigned char *buf) { int i; @@ -106,10 +69,9 @@ int write_49fl004(struct flashchip *flash, unsigned char *buf) /* write to the sector */ printf("%04d at address: 0x%08x", i, i * page_size); - write_block_49fl004(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"); + write_sector_jedec(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"); fflush(stdout); } printf("\n"); diff --git a/util/flash_and_burn/sst28sf040.c b/util/flash_and_burn/sst28sf040.c index 7b487aa57a..1853f156b0 100644 --- a/util/flash_and_burn/sst28sf040.c +++ b/util/flash_and_burn/sst28sf040.c @@ -163,8 +163,7 @@ int write_28sf040(struct flashchip *flash, unsigned char *buf) printf("%04d at address: 0x%08x", i, i * page_size); write_sector_28sf040(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("\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("\n"); diff --git a/util/flash_and_burn/sst49lf040.c b/util/flash_and_burn/sst49lf040.c index f18e733e7a..624a8655ef 100644 --- a/util/flash_and_burn/sst49lf040.c +++ b/util/flash_and_burn/sst49lf040.c @@ -33,8 +33,8 @@ int write_49lf040(struct flashchip *flash, unsigned char *buf) { int i; - int total_size = flash->total_size * 1024, page_size = - flash->page_size; + int total_size = flash->total_size * 1024; + int page_size = flash->page_size; volatile char *bios = flash->virt_addr; printf("Programming Page: "); @@ -48,8 +48,7 @@ int write_49lf040(struct flashchip *flash, unsigned char *buf) printf("%04d at address: 0x%08x ", i, i * page_size); write_sector_jedec(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\b"); + 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\b"); fflush(stdout); } printf("\n"); |