mirror of
https://review.coreboot.org/flashrom.git
synced 2025-04-28 23:43:42 +02:00
Check result of all SPI erase functions
Since block erase functions do not know the block length (it's not specified in any standard), block erase functions now get an additional parameter blocklen. This enables flashrom to verify the erase result for block erase functions at correct boundaries. Tested by Uwe on SB600. Corresponding to flashrom svn r630. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
This commit is contained in:
parent
23290664ed
commit
3431bb70aa
7
flash.h
7
flash.h
@ -425,8 +425,11 @@ int spi_chip_erase_60(struct flashchip *flash);
|
|||||||
int spi_chip_erase_c7(struct flashchip *flash);
|
int spi_chip_erase_c7(struct flashchip *flash);
|
||||||
int spi_chip_erase_60_c7(struct flashchip *flash);
|
int spi_chip_erase_60_c7(struct flashchip *flash);
|
||||||
int spi_chip_erase_d8(struct flashchip *flash);
|
int spi_chip_erase_d8(struct flashchip *flash);
|
||||||
int spi_block_erase_52(const struct flashchip *flash, unsigned long addr);
|
int spi_block_erase_20(struct flashchip *flash, unsigned int addr, unsigned int blocklen);
|
||||||
int spi_block_erase_d8(const struct flashchip *flash, unsigned long addr);
|
int spi_block_erase_52(struct flashchip *flash, unsigned int addr, unsigned int blocklen);
|
||||||
|
int spi_block_erase_d8(struct flashchip *flash, unsigned int addr, unsigned int blocklen);
|
||||||
|
int spi_block_erase_60(struct flashchip *flash, unsigned int addr, unsigned int blocklen);
|
||||||
|
int spi_block_erase_c7(struct flashchip *flash, unsigned int addr, unsigned int blocklen);
|
||||||
int spi_chip_write_1(struct flashchip *flash, uint8_t *buf);
|
int spi_chip_write_1(struct flashchip *flash, uint8_t *buf);
|
||||||
int spi_chip_write_256(struct flashchip *flash, uint8_t *buf);
|
int spi_chip_write_256(struct flashchip *flash, uint8_t *buf);
|
||||||
int spi_chip_read(struct flashchip *flash, uint8_t *buf, int start, int len);
|
int spi_chip_read(struct flashchip *flash, uint8_t *buf, int start, int len);
|
||||||
|
2
ichspi.c
2
ichspi.c
@ -661,7 +661,7 @@ int ich_spi_write_256(struct flashchip *flash, uint8_t * buf)
|
|||||||
* For this, we need to add a block erase function to
|
* For this, we need to add a block erase function to
|
||||||
* struct flashchip.
|
* struct flashchip.
|
||||||
*/
|
*/
|
||||||
rc = spi_block_erase_d8(flash, i * erase_size);
|
rc = spi_block_erase_d8(flash, i * erase_size, erase_size);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
printf("Error erasing block at 0x%x\n", i);
|
printf("Error erasing block at 0x%x\n", i);
|
||||||
break;
|
break;
|
||||||
|
59
spi.c
59
spi.c
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of the flashrom project.
|
* This file is part of the flashrom project.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007, 2008 Carl-Daniel Hailfinger
|
* Copyright (C) 2007, 2008, 2009 Carl-Daniel Hailfinger
|
||||||
* Copyright (C) 2008 coresystems GmbH
|
* Copyright (C) 2008 coresystems GmbH
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -430,6 +430,10 @@ int spi_chip_erase_60(struct flashchip *flash)
|
|||||||
/* FIXME: We assume spi_read_status_register will never fail. */
|
/* FIXME: We assume spi_read_status_register will never fail. */
|
||||||
while (spi_read_status_register() & JEDEC_RDSR_BIT_WIP)
|
while (spi_read_status_register() & JEDEC_RDSR_BIT_WIP)
|
||||||
programmer_delay(1000 * 1000);
|
programmer_delay(1000 * 1000);
|
||||||
|
if (check_erased_range(flash, 0, flash->total_size * 1024)) {
|
||||||
|
fprintf(stderr, "ERASE FAILED!\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -458,6 +462,10 @@ int spi_chip_erase_c7(struct flashchip *flash)
|
|||||||
/* FIXME: We assume spi_read_status_register will never fail. */
|
/* FIXME: We assume spi_read_status_register will never fail. */
|
||||||
while (spi_read_status_register() & JEDEC_RDSR_BIT_WIP)
|
while (spi_read_status_register() & JEDEC_RDSR_BIT_WIP)
|
||||||
programmer_delay(1000 * 1000);
|
programmer_delay(1000 * 1000);
|
||||||
|
if (check_erased_range(flash, 0, flash->total_size * 1024)) {
|
||||||
|
fprintf(stderr, "ERASE FAILED!\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -472,9 +480,9 @@ int spi_chip_erase_60_c7(struct flashchip *flash)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int spi_block_erase_52(const struct flashchip *flash, unsigned long addr)
|
int spi_block_erase_52(struct flashchip *flash, unsigned int addr, unsigned int blocklen)
|
||||||
{
|
{
|
||||||
unsigned char cmd[JEDEC_BE_52_OUTSIZE] = {JEDEC_BE_52};
|
unsigned char cmd[JEDEC_BE_52_OUTSIZE] = {JEDEC_BE_52, };
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
cmd[1] = (addr & 0x00ff0000) >> 16;
|
cmd[1] = (addr & 0x00ff0000) >> 16;
|
||||||
@ -490,6 +498,10 @@ int spi_block_erase_52(const struct flashchip *flash, unsigned long addr)
|
|||||||
*/
|
*/
|
||||||
while (spi_read_status_register() & JEDEC_RDSR_BIT_WIP)
|
while (spi_read_status_register() & JEDEC_RDSR_BIT_WIP)
|
||||||
programmer_delay(100 * 1000);
|
programmer_delay(100 * 1000);
|
||||||
|
if (check_erased_range(flash, addr, blocklen)) {
|
||||||
|
fprintf(stderr, "ERASE FAILED!\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -498,9 +510,9 @@ int spi_block_erase_52(const struct flashchip *flash, unsigned long addr)
|
|||||||
* 32k for SST
|
* 32k for SST
|
||||||
* 4-32k non-uniform for EON
|
* 4-32k non-uniform for EON
|
||||||
*/
|
*/
|
||||||
int spi_block_erase_d8(const struct flashchip *flash, unsigned long addr)
|
int spi_block_erase_d8(struct flashchip *flash, unsigned int addr, unsigned int blocklen)
|
||||||
{
|
{
|
||||||
unsigned char cmd[JEDEC_BE_D8_OUTSIZE] = { JEDEC_BE_D8 };
|
unsigned char cmd[JEDEC_BE_D8_OUTSIZE] = { JEDEC_BE_D8, };
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
cmd[1] = (addr & 0x00ff0000) >> 16;
|
cmd[1] = (addr & 0x00ff0000) >> 16;
|
||||||
@ -516,6 +528,10 @@ int spi_block_erase_d8(const struct flashchip *flash, unsigned long addr)
|
|||||||
*/
|
*/
|
||||||
while (spi_read_status_register() & JEDEC_RDSR_BIT_WIP)
|
while (spi_read_status_register() & JEDEC_RDSR_BIT_WIP)
|
||||||
programmer_delay(100 * 1000);
|
programmer_delay(100 * 1000);
|
||||||
|
if (check_erased_range(flash, addr, blocklen)) {
|
||||||
|
fprintf(stderr, "ERASE FAILED!\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -530,7 +546,7 @@ int spi_chip_erase_d8(struct flashchip *flash)
|
|||||||
printf("Erasing chip: \n");
|
printf("Erasing chip: \n");
|
||||||
|
|
||||||
for (i = 0; i < total_size / erase_size; i++) {
|
for (i = 0; i < total_size / erase_size; i++) {
|
||||||
rc = spi_block_erase_d8(flash, i * erase_size);
|
rc = spi_block_erase_d8(flash, i * erase_size, erase_size);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
printf("Error erasing block at 0x%x\n", i);
|
printf("Error erasing block at 0x%x\n", i);
|
||||||
break;
|
break;
|
||||||
@ -543,9 +559,9 @@ int spi_chip_erase_d8(struct flashchip *flash)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Sector size is usually 4k, though Macronix eliteflash has 64k */
|
/* Sector size is usually 4k, though Macronix eliteflash has 64k */
|
||||||
int spi_sector_erase(const struct flashchip *flash, unsigned long addr)
|
int spi_block_erase_20(struct flashchip *flash, unsigned int addr, unsigned int blocklen)
|
||||||
{
|
{
|
||||||
unsigned char cmd[JEDEC_SE_OUTSIZE] = { JEDEC_SE };
|
unsigned char cmd[JEDEC_SE_OUTSIZE] = { JEDEC_SE, };
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
cmd[1] = (addr & 0x00ff0000) >> 16;
|
cmd[1] = (addr & 0x00ff0000) >> 16;
|
||||||
@ -562,9 +578,31 @@ int spi_sector_erase(const struct flashchip *flash, unsigned long addr)
|
|||||||
*/
|
*/
|
||||||
while (spi_read_status_register() & JEDEC_RDSR_BIT_WIP)
|
while (spi_read_status_register() & JEDEC_RDSR_BIT_WIP)
|
||||||
programmer_delay(10 * 1000);
|
programmer_delay(10 * 1000);
|
||||||
|
if (check_erased_range(flash, addr, blocklen)) {
|
||||||
|
fprintf(stderr, "ERASE FAILED!\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int spi_block_erase_60(struct flashchip *flash, unsigned int addr, unsigned int blocklen)
|
||||||
|
{
|
||||||
|
if ((addr != 0) || (blocklen != flash->total_size * 1024)) {
|
||||||
|
fprintf(stderr, "%s called with incorrect arguments\n", __func__);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return spi_chip_erase_60(flash);
|
||||||
|
}
|
||||||
|
|
||||||
|
int spi_block_erase_c7(struct flashchip *flash, unsigned int addr, unsigned int blocklen)
|
||||||
|
{
|
||||||
|
if ((addr != 0) || (blocklen != flash->total_size * 1024)) {
|
||||||
|
fprintf(stderr, "%s called with incorrect arguments\n", __func__);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return spi_chip_erase_c7(flash);
|
||||||
|
}
|
||||||
|
|
||||||
int spi_write_status_enable(void)
|
int spi_write_status_enable(void)
|
||||||
{
|
{
|
||||||
const unsigned char cmd[JEDEC_EWSR_OUTSIZE] = { JEDEC_EWSR };
|
const unsigned char cmd[JEDEC_EWSR_OUTSIZE] = { JEDEC_EWSR };
|
||||||
@ -810,7 +848,10 @@ int spi_aai_write(struct flashchip *flash, uint8_t *buf)
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
flash->erase(flash);
|
if (flash->erase(flash)) {
|
||||||
|
fprintf(stderr, "ERASE FAILED!\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
result = spi_write_enable();
|
result = spi_write_enable();
|
||||||
if (result)
|
if (result)
|
||||||
return result;
|
return result;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user