From 42d38a9dd1ef58870635c0e003b1a37e89a51ba7 Mon Sep 17 00:00:00 2001 From: Carl-Daniel Hailfinger Date: Tue, 19 Oct 2010 22:06:20 +0000 Subject: Always read the flash chip before writing This will allow flashrom to skip erase of already-erased blocks and to skip write of blocks which already have the wanted contents. Avoid emergency messages by checking if the chip contents after a failed write operation (erase/write) are unchanged. Keep the emergency messages after a failed pure erase. That part is debatable because if someone wants erase, he pretty sure doesn't care about the flash contents anymore. Please note that this introduces additional overhead of a full chip read before write. This is frowned upon by people with slow programmers. A followup patch will make this configurable. Corresponding to flashrom svn r1215. Signed-off-by: Carl-Daniel Hailfinger Acked-by: Stefan Reinauer --- layout.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'layout.c') diff --git a/layout.c b/layout.c index c01e09c..b24e4dd 100644 --- a/layout.c +++ b/layout.c @@ -205,7 +205,7 @@ int find_romentry(char *name) return -1; } -int handle_romentries(uint8_t *buffer, struct flashchip *flash) +int handle_romentries(struct flashchip *flash, uint8_t *oldcontents, uint8_t *newcontents) { int i; @@ -225,13 +225,12 @@ int handle_romentries(uint8_t *buffer, struct flashchip *flash) // normal will be updated and the rest will be kept. for (i = 0; i < romimages; i++) { - if (rom_entries[i].included) continue; - flash->read(flash, buffer + rom_entries[i].start, - rom_entries[i].start, - rom_entries[i].end - rom_entries[i].start + 1); + memcpy(newcontents + rom_entries[i].start, + oldcontents + rom_entries[i].start, + rom_entries[i].end - rom_entries[i].start + 1); } return 0; -- cgit v1.1