mirror of
https://review.coreboot.org/flashrom.git
synced 2025-04-27 23:22:37 +02:00
Remove false alarm of erase/write, use verify '-v' if you are not sure about the integrity
Corresponding to flashrom svn r19 and coreboot v2 svn r1486.
This commit is contained in:
parent
070647d114
commit
8b8897a5fd
2
flash.h
2
flash.h
@ -31,7 +31,7 @@ struct flashchip {
|
|||||||
#define MX_ID 0xC2
|
#define MX_ID 0xC2
|
||||||
#define MX_29F002 0xB0
|
#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_29EE020A 0x10 /* SST 29EE020 device code */
|
||||||
#define SST_28SF040 0x04 /* SST 29EE040 device code */
|
#define SST_28SF040 0x04 /* SST 29EE040 device code */
|
||||||
#define SST_39SF020 0xB6 /* SST 39SF020 device */
|
#define SST_39SF020 0xB6 /* SST 39SF020 device */
|
||||||
|
@ -75,8 +75,7 @@ static int enable_flash_e7500(struct pci_dev *dev, char *name)
|
|||||||
pci_write_byte(dev, 0x4e, new);
|
pci_write_byte(dev, 0x4e, new);
|
||||||
|
|
||||||
if (pci_read_byte(dev, 0x4e) != new) {
|
if (pci_read_byte(dev, 0x4e) != new) {
|
||||||
printf
|
printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
|
||||||
("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
|
|
||||||
0x4e, new, name);
|
0x4e, new, name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -104,15 +103,12 @@ static int enable_flash_vt8235(struct pci_dev *dev, char *name)
|
|||||||
|
|
||||||
ok = pci_write_byte(dev, 0x40, new);
|
ok = pci_write_byte(dev, 0x40, new);
|
||||||
if (ok != 0) {
|
if (ok != 0) {
|
||||||
printf
|
printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
|
||||||
("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
|
|
||||||
old, new, name);
|
old, new, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* enable GPIO15 which is connected to write protect. */
|
/* enable GPIO15 which is connected to write protect. */
|
||||||
base =
|
base = ((pci_read_byte(dev, 0x88) & 0x80) | pci_read_byte(dev, 0x89) << 8);
|
||||||
((pci_read_byte(dev, 0x88) & 0x80) | pci_read_byte(dev, 0x89)
|
|
||||||
<< 8);
|
|
||||||
val = inb(base + 0x4d);
|
val = inb(base + 0x4d);
|
||||||
val |= 0x80;
|
val |= 0x80;
|
||||||
outb(val, base + 0x4d);
|
outb(val, base + 0x4d);
|
||||||
@ -133,8 +129,7 @@ static int enable_flash_vt8231(struct pci_dev *dev, char *name)
|
|||||||
pci_write_byte(dev, 0x40, val);
|
pci_write_byte(dev, 0x40, val);
|
||||||
|
|
||||||
if (pci_read_byte(dev, 0x40) != val) {
|
if (pci_read_byte(dev, 0x40) != val) {
|
||||||
printf
|
printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
|
||||||
("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
|
|
||||||
0x40, val, name);
|
0x40, val, name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -150,8 +145,7 @@ static int enable_flash_cs5530(struct pci_dev *dev, char *name)
|
|||||||
new = pci_read_byte(dev, 0x52);
|
new = pci_read_byte(dev, 0x52);
|
||||||
|
|
||||||
if (new != 0xee) {
|
if (new != 0xee) {
|
||||||
printf
|
printf("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
|
||||||
("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
|
|
||||||
0x52, new, name);
|
0x52, new, name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -167,8 +161,7 @@ static int enable_flash_sc1100(struct pci_dev *dev, char *name)
|
|||||||
new = pci_read_byte(dev, 0x52);
|
new = pci_read_byte(dev, 0x52);
|
||||||
|
|
||||||
if (new != 0xee) {
|
if (new != 0xee) {
|
||||||
printf
|
printf("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
|
||||||
("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
|
|
||||||
0x52, new, name);
|
0x52, new, name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -190,8 +183,7 @@ static int enable_flash_sis5595(struct pci_dev *dev, char *name)
|
|||||||
|
|
||||||
newer = pci_read_byte(dev, 0x45);
|
newer = pci_read_byte(dev, 0x45);
|
||||||
if (newer != new) {
|
if (newer != new) {
|
||||||
printf
|
printf("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
|
||||||
("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
|
|
||||||
0x45, new, name);
|
0x45, new, name);
|
||||||
printf("Stuck at 0x%x\n", newer);
|
printf("Stuck at 0x%x\n", newer);
|
||||||
return -1;
|
return -1;
|
||||||
@ -214,8 +206,7 @@ static int enable_flash_amd8111(struct pci_dev *dev, char *name)
|
|||||||
if (new != old) {
|
if (new != old) {
|
||||||
pci_write_byte(dev, 0x43, new);
|
pci_write_byte(dev, 0x43, new);
|
||||||
if (pci_read_byte(dev, 0x43) != new) {
|
if (pci_read_byte(dev, 0x43) != new) {
|
||||||
printf
|
printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
|
||||||
("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
|
|
||||||
0x43, new, name);
|
0x43, new, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -227,8 +218,7 @@ static int enable_flash_amd8111(struct pci_dev *dev, char *name)
|
|||||||
pci_write_byte(dev, 0x40, new);
|
pci_write_byte(dev, 0x40, new);
|
||||||
|
|
||||||
if (pci_read_byte(dev, 0x40) != new) {
|
if (pci_read_byte(dev, 0x40) != new) {
|
||||||
printf
|
printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
|
||||||
("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
|
|
||||||
0x40, new, name);
|
0x40, new, name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
12
flash_rom.c
12
flash_rom.c
@ -83,8 +83,7 @@ struct flashchip flashchips[] = {
|
|||||||
{"W49F002U", WINBOND_ID, W_49F002U, NULL, 256, 128,
|
{"W49F002U", WINBOND_ID, W_49F002U, NULL, 256, 128,
|
||||||
probe_jedec, erase_chip_jedec, write_49f002, NULL},
|
probe_jedec, erase_chip_jedec, write_49f002, NULL},
|
||||||
{"M29F400BT", ST_ID, ST_M29F400BT, NULL, 512, 64 * 1024,
|
{"M29F400BT", ST_ID, ST_M29F400BT, NULL, 512, 64 * 1024,
|
||||||
probe_m29f400bt, erase_m29f400bt, write_linuxbios_m29f400bt,
|
probe_m29f400bt, erase_m29f400bt, write_linuxbios_m29f400bt, NULL},
|
||||||
NULL},
|
|
||||||
{"82802ab", 137, 173, NULL, 512, 64 * 1024,
|
{"82802ab", 137, 173, NULL, 512, 64 * 1024,
|
||||||
probe_82802ab, erase_82802ab, write_82802ab, NULL},
|
probe_82802ab, erase_82802ab, write_82802ab, NULL},
|
||||||
{"82802ac", 137, 172, NULL, 1024, 64 * 1024,
|
{"82802ac", 137, 172, NULL, 1024, 64 * 1024,
|
||||||
@ -110,13 +109,11 @@ struct flashchip *probe_flash(struct flashchip *flash)
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (flash->name != NULL) {
|
while (flash->name != NULL) {
|
||||||
if (chip_to_probe
|
if (chip_to_probe && strcmp(flash->name, chip_to_probe) != 0) {
|
||||||
&& strcmp(flash->name, chip_to_probe) != 0) {
|
|
||||||
flash++;
|
flash++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
printf("Trying %s, %d KB\n", flash->name,
|
printf("Trying %s, %d KB\n", flash->name, flash->total_size);
|
||||||
flash->total_size);
|
|
||||||
size = flash->total_size * 1024;
|
size = flash->total_size * 1024;
|
||||||
/* BUG? what happens if getpagesize() > size!?
|
/* BUG? what happens if getpagesize() > size!?
|
||||||
-> ``Error MMAP /dev/mem: Invalid argument'' NIKI */
|
-> ``Error MMAP /dev/mem: Invalid argument'' NIKI */
|
||||||
@ -225,8 +222,7 @@ int main(int argc, char *argv[])
|
|||||||
if (optind < argc)
|
if (optind < argc)
|
||||||
filename = argv[optind++];
|
filename = argv[optind++];
|
||||||
|
|
||||||
printf
|
printf("Calibrating timer since microsleep sucks ... takes a second\n");
|
||||||
("Calibrating timer since microsleep sucks ... takes a second\n");
|
|
||||||
myusec_calibrate_delay();
|
myusec_calibrate_delay();
|
||||||
printf("OK, calibrated, now do the deed\n");
|
printf("OK, calibrated, now do the deed\n");
|
||||||
|
|
||||||
|
19
jedec.c
19
jedec.c
@ -120,7 +120,7 @@ int erase_chip_jedec(struct flashchip *flash)
|
|||||||
return (0);
|
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 page_size)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@ -139,16 +139,11 @@ void write_page_jedec(volatile char *bios, char *src, volatile char *dst,
|
|||||||
toggle_ready_jedec(dst - 1);
|
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 *dst)
|
||||||
{
|
{
|
||||||
volatile unsigned char *Temp;
|
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 */
|
/* transfer data from source to destination */
|
||||||
if (*src == 0xFF) {
|
if (*src == 0xFF) {
|
||||||
dst++, src++;
|
dst++, src++;
|
||||||
@ -164,10 +159,7 @@ int wirte_byte_program_jedec(volatile unsigned char *bios, unsigned char *src,
|
|||||||
*Temp = 0xA0;
|
*Temp = 0xA0;
|
||||||
*dst = *src;
|
*dst = *src;
|
||||||
toggle_ready_jedec(bios);
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,7 +170,8 @@ int write_sector_jedec(volatile unsigned char *bios, unsigned char *src,
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < page_size; 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);
|
return (0);
|
||||||
@ -199,7 +192,7 @@ int write_jedec(struct flashchip *flash, unsigned char *buf)
|
|||||||
printf("Programming Page: ");
|
printf("Programming Page: ");
|
||||||
for (i = 0; i < total_size / page_size; i++) {
|
for (i = 0; i < total_size / page_size; i++) {
|
||||||
printf("%04d at address: 0x%08x", i, i * page_size);
|
printf("%04d at address: 0x%08x", i, i * page_size);
|
||||||
write_page_jedec(bios, buf + i * page_size,
|
write_page_write_jedec(bios, buf + i * page_size,
|
||||||
bios + i * page_size, 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");
|
||||||
}
|
}
|
||||||
|
4
jedec.h
4
jedec.h
@ -17,7 +17,7 @@ extern __inline__ void toggle_ready_jedec(volatile char *dst)
|
|||||||
|
|
||||||
tmp1 = *dst & 0x40;
|
tmp1 = *dst & 0x40;
|
||||||
|
|
||||||
while (i++ < 0xFFFFFF) {
|
while (i++ < 0xFFFFFFF) {
|
||||||
tmp2 = *dst & 0x40;
|
tmp2 = *dst & 0x40;
|
||||||
if (tmp1 == tmp2) {
|
if (tmp1 == tmp2) {
|
||||||
break;
|
break;
|
||||||
@ -33,7 +33,7 @@ extern __inline__ void data_polling_jedec(volatile char *dst, char data)
|
|||||||
|
|
||||||
data &= 0x80;
|
data &= 0x80;
|
||||||
|
|
||||||
while (i++ < 0xFFFFFF) {
|
while (i++ < 0xFFFFFFF) {
|
||||||
tmp = *dst & 0x80;
|
tmp = *dst & 0x80;
|
||||||
if (tmp == data) {
|
if (tmp == data) {
|
||||||
break;
|
break;
|
||||||
|
42
pm49fl004.c
42
pm49fl004.c
@ -55,43 +55,6 @@ static __inline__ int erase_block_49fl004(volatile unsigned char *bios,
|
|||||||
return (0);
|
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 write_49fl004(struct flashchip *flash, unsigned char *buf)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@ -106,10 +69,9 @@ int write_49fl004(struct flashchip *flash, unsigned char *buf)
|
|||||||
|
|
||||||
/* write to the sector */
|
/* write to the sector */
|
||||||
printf("%04d at address: 0x%08x", i, i * page_size);
|
printf("%04d at address: 0x%08x", i, i * page_size);
|
||||||
write_block_49fl004(bios, buf + i * page_size,
|
write_sector_jedec(bios, buf + i * page_size,
|
||||||
bios + i * page_size, page_size);
|
bios + i * page_size, page_size);
|
||||||
printf
|
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\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);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
@ -163,8 +163,7 @@ int write_28sf040(struct flashchip *flash, unsigned char *buf)
|
|||||||
printf("%04d at address: 0x%08x", i, i * page_size);
|
printf("%04d at address: 0x%08x", i, i * page_size);
|
||||||
write_sector_28sf040(bios, buf + i * page_size,
|
write_sector_28sf040(bios, buf + i * page_size,
|
||||||
bios + i * page_size, page_size);
|
bios + i * page_size, page_size);
|
||||||
printf
|
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\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");
|
printf("\n");
|
||||||
|
|
||||||
|
@ -33,8 +33,8 @@
|
|||||||
int write_49lf040(struct flashchip *flash, unsigned char *buf)
|
int write_49lf040(struct flashchip *flash, unsigned char *buf)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int total_size = flash->total_size * 1024, page_size =
|
int total_size = flash->total_size * 1024;
|
||||||
flash->page_size;
|
int page_size = flash->page_size;
|
||||||
volatile char *bios = flash->virt_addr;
|
volatile char *bios = flash->virt_addr;
|
||||||
|
|
||||||
printf("Programming Page: ");
|
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);
|
printf("%04d at address: 0x%08x ", i, i * page_size);
|
||||||
write_sector_jedec(bios, buf + i * page_size,
|
write_sector_jedec(bios, buf + i * page_size,
|
||||||
bios + i * page_size, page_size);
|
bios + i * page_size, page_size);
|
||||||
printf
|
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");
|
||||||
("\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);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user