mirror of
https://review.coreboot.org/flashrom.git
synced 2025-07-02 14:33:18 +02:00
Move implicit erase out of chip drivers
Flashrom had an implicit erase-on-write for most flash chip and programmer drivers, but it was not entirely consistent. Some drivers had their own hand-rolled partial update functionality which made handling partial updates from generic code impossible. Move implicit erase out of chip drivers, and kill some dead erase functions at the same time. A full chip erase is now performed in the generic code for all flash chips on write, and after that the whole chip is written. Corresponding to flashrom svn r1206. 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:
26
flashrom.c
26
flashrom.c
@ -1509,6 +1509,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* This function signature is horrible. We need to design a better interface,
|
||||
* but right now it allows us to split off the CLI code.
|
||||
* Besides that, the function itself is a textbook example of abysmal code flow.
|
||||
*/
|
||||
int doit(struct flashchip *flash, int force, char *filename, int read_it, int write_it, int erase_it, int verify_it)
|
||||
{
|
||||
@ -1563,12 +1564,7 @@ int doit(struct flashchip *flash, int force, char *filename, int read_it, int wr
|
||||
programmer_shutdown();
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
struct stat image_stat;
|
||||
|
||||
if (flash->unlock)
|
||||
flash->unlock(flash);
|
||||
|
||||
} else if (write_it) {
|
||||
if (flash->tested & TEST_BAD_ERASE) {
|
||||
msg_cerr("Erase is not working on this chip "
|
||||
"and erase is needed for write. ");
|
||||
@ -1590,6 +1586,18 @@ int doit(struct flashchip *flash, int force, char *filename, int read_it, int wr
|
||||
msg_cerr("Continuing anyway.\n");
|
||||
}
|
||||
}
|
||||
if (!flash->write) {
|
||||
msg_cerr("Error: flashrom has no write function for this flash chip.\n");
|
||||
programmer_shutdown();
|
||||
return 1;
|
||||
}
|
||||
if (flash->unlock)
|
||||
flash->unlock(flash);
|
||||
|
||||
}
|
||||
if (write_it || verify_it) {
|
||||
struct stat image_stat;
|
||||
|
||||
if ((image = fopen(filename, "rb")) == NULL) {
|
||||
perror(filename);
|
||||
programmer_shutdown();
|
||||
@ -1625,12 +1633,12 @@ int doit(struct flashchip *flash, int force, char *filename, int read_it, int wr
|
||||
// ////////////////////////////////////////////////////////////
|
||||
|
||||
if (write_it) {
|
||||
msg_cinfo("Writing flash chip... ");
|
||||
if (!flash->write) {
|
||||
msg_cerr("Error: flashrom has no write function for this flash chip.\n");
|
||||
if (erase_flash(flash)) {
|
||||
emergency_help_message();
|
||||
programmer_shutdown();
|
||||
return 1;
|
||||
}
|
||||
msg_cinfo("Writing flash chip... ");
|
||||
ret = flash->write(flash, buf);
|
||||
if (ret) {
|
||||
msg_cerr("FAILED!\n");
|
||||
|
Reference in New Issue
Block a user