Attention is currently required from: Aarya.

Anastasia Klimchuk has uploaded this change for review.

View Change

[WIP] Fix double invocation of erasers

Change-Id: I92351eba0fd29114ce98b4a839358e92d176af28
Signed-off-by: Anastasia Klimchuk <aklm@flashrom.org>
---
M erasure_layout.c
1 file changed, 15 insertions(+), 7 deletions(-)

git pull ssh://review.coreboot.org:29418/flashrom refs/changes/47/77747/1
diff --git a/erasure_layout.c b/erasure_layout.c
index c9ac44b..06626c3 100644
--- a/erasure_layout.c
+++ b/erasure_layout.c
@@ -304,6 +304,7 @@
goto _end;
}

+ unsigned int last_addr = start_addr;
unsigned int len;
for (unsigned int addr = start_addr; addr < start_addr + block_len; addr += len) {
struct flash_region region;
@@ -337,15 +338,22 @@
msg_cerr("ERASE FAILED!\n");
goto _end;
}
+
+ last_addr = addr + len;
}

- ret = erasefn(flashctx, start_addr, block_len);
- if (ret) {
- msg_cerr("Failed to execute erase command "
- "for offset %#"PRIx32" to %#"PRIx32".\n",
- start_addr, start_addr + block_len);
- ret = -1;
- goto _end;
+ if (last_addr < start_addr + block_len) {
+ // Something is left to erase
+ printf("Left to erase from %#"PRIx32" to %#"PRIx32".\n", last_addr, start_addr + block_len);
+ unsigned int remaining_len = start_addr + block_len - last_addr;
+ ret = erasefn(flashctx, last_addr, remaining_len);
+ if (ret) {
+ msg_cerr("Failed to execute erase command "
+ "for offset %#"PRIx32" to %#"PRIx32".\n",
+ last_addr, last_addr + remaining_len);
+ ret = -1;
+ goto _end;
+ }
}

// adjust curcontents

To view, visit change 77747. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I92351eba0fd29114ce98b4a839358e92d176af28
Gerrit-Change-Number: 77747
Gerrit-PatchSet: 1
Gerrit-Owner: Anastasia Klimchuk <aklm@chromium.org>
Gerrit-Reviewer: Aarya <aarya.chaumal@gmail.com>
Gerrit-Attention: Aarya <aarya.chaumal@gmail.com>
Gerrit-MessageType: newchange