Namyoon Woo has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/44907 )
Change subject: Only write back emulated image if modified ......................................................................
Only write back emulated image if modified
When the image is not modified, there is no point in writing it back. In fact we may not have file permissions to do so.
Signed-off-by: Namyoon Woo namyoon@google.com Change-Id: I3bf2d7edb28a9a1e5406b67a88a0ee6e07db83e3 --- M dummyflasher.c 1 file changed, 9 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/07/44907/1
diff --git a/dummyflasher.c b/dummyflasher.c index d1b7366..ea3907e 100644 --- a/dummyflasher.c +++ b/dummyflasher.c @@ -50,6 +50,7 @@ static enum emu_chip emu_chip = EMULATE_NONE; static char *emu_persistent_image = NULL; static unsigned int emu_chip_size = 0; +static int emu_modified; /* is the image modified since reading it? */ #if EMULATE_SPI_CHIP static unsigned int emu_max_byteprogram_size = 0; static unsigned int emu_max_aai_size = 0; @@ -137,7 +138,7 @@ msg_pspew("%s\n", __func__); #if EMULATE_CHIP if (emu_chip != EMULATE_NONE) { - if (emu_persistent_image) { + if (emu_persistent_image && emu_modified) { msg_pdbg("Writing %s\n", emu_persistent_image); write_buf_to_file(flashchip_contents, emu_chip_size, emu_persistent_image); free(emu_persistent_image); @@ -727,6 +728,7 @@ return 1; } memcpy(flashchip_contents + offs, writearr + 4, writecnt - 4); + emu_modified = 1; break; case JEDEC_AAI_WORD_PROGRAM: if (!emu_max_aai_size) @@ -763,6 +765,7 @@ memcpy(flashchip_contents + aai_offs, writearr + 1, 2); aai_offs += 2; } + emu_modified = 1; break; case JEDEC_WRDI: if (emu_max_aai_size) @@ -784,6 +787,7 @@ msg_pdbg("Unaligned SECTOR ERASE 0x20: 0x%x\n", offs); offs &= ~(emu_jedec_se_size - 1); memset(flashchip_contents + offs, 0xff, emu_jedec_se_size); + emu_modified = 1; break; case JEDEC_BE_52: if (!emu_jedec_be_52_size) @@ -801,6 +805,7 @@ msg_pdbg("Unaligned BLOCK ERASE 0x52: 0x%x\n", offs); offs &= ~(emu_jedec_be_52_size - 1); memset(flashchip_contents + offs, 0xff, emu_jedec_be_52_size); + emu_modified = 1; break; case JEDEC_BE_D8: if (!emu_jedec_be_d8_size) @@ -818,6 +823,7 @@ msg_pdbg("Unaligned BLOCK ERASE 0xd8: 0x%x\n", offs); offs &= ~(emu_jedec_be_d8_size - 1); memset(flashchip_contents + offs, 0xff, emu_jedec_be_d8_size); + emu_modified = 1; break; case JEDEC_CE_60: if (!emu_jedec_ce_60_size) @@ -833,6 +839,7 @@ /* JEDEC_CE_60_OUTSIZE is 1 (no address) -> no offset. */ /* emu_jedec_ce_60_size is emu_chip_size. */ memset(flashchip_contents, 0xff, emu_jedec_ce_60_size); + emu_modified = 1; break; case JEDEC_CE_C7: if (!emu_jedec_ce_c7_size) @@ -848,6 +855,7 @@ /* JEDEC_CE_C7_OUTSIZE is 1 (no address) -> no offset. */ /* emu_jedec_ce_c7_size is emu_chip_size. */ memset(flashchip_contents, 0xff, emu_jedec_ce_c7_size); + emu_modified = 1; break; case JEDEC_SFDP: if (emu_chip != EMULATE_MACRONIX_MX25L6436)
Namyoon Woo has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/44907 )
Change subject: Only write back emulated image if modified ......................................................................
Patch Set 1:
This is to sync with the one in chromiumos repo. Original patch is https://chromium-review.googlesource.com/c/chromiumos/third_party/flashrom/+....
Edward O'Callaghan has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/44907 )
Change subject: Only write back emulated image if modified ......................................................................
Patch Set 1:
(1 comment)
https://review.coreboot.org/c/flashrom/+/44907/1/dummyflasher.c File dummyflasher.c:
https://review.coreboot.org/c/flashrom/+/44907/1/dummyflasher.c@53 PS1, Line 53: ed; init the value to zero?
Hello build bot (Jenkins), Edward O'Callaghan, Angel Pons,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/flashrom/+/44907
to look at the new patch set (#2).
Change subject: Only write back emulated image if modified ......................................................................
Only write back emulated image if modified
When the image is not modified, there is no point in writing it back. In fact we may not have file permissions to do so.
Signed-off-by: Namyoon Woo namyoon@google.com Change-Id: I3bf2d7edb28a9a1e5406b67a88a0ee6e07db83e3 --- M dummyflasher.c 1 file changed, 9 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/07/44907/2
Namyoon Woo has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/44907 )
Change subject: Only write back emulated image if modified ......................................................................
Patch Set 2:
(1 comment)
https://review.coreboot.org/c/flashrom/+/44907/1/dummyflasher.c File dummyflasher.c:
https://review.coreboot.org/c/flashrom/+/44907/1/dummyflasher.c@53 PS1, Line 53: ed;
init the value to zero?
Done
Edward O'Callaghan has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/44907 )
Change subject: Only write back emulated image if modified ......................................................................
Patch Set 4: Code-Review+2
Edward O'Callaghan has uploaded a new patch set (#6) to the change originally created by Namyoon Woo. ( https://review.coreboot.org/c/flashrom/+/44907 )
Change subject: dummyflasher.c: Only write back emulated image if modified ......................................................................
dummyflasher.c: Only write back emulated image if modified
When the image is not modified, there is no point in writing it back. In fact we may not have file permissions to do so.
Signed-off-by: Namyoon Woo namyoon@google.com Change-Id: I3bf2d7edb28a9a1e5406b67a88a0ee6e07db83e3 --- M dummyflasher.c 1 file changed, 9 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/07/44907/6
Edward O'Callaghan has submitted this change. ( https://review.coreboot.org/c/flashrom/+/44907 )
Change subject: dummyflasher.c: Only write back emulated image if modified ......................................................................
dummyflasher.c: Only write back emulated image if modified
When the image is not modified, there is no point in writing it back. In fact we may not have file permissions to do so.
Signed-off-by: Namyoon Woo namyoon@google.com Change-Id: I3bf2d7edb28a9a1e5406b67a88a0ee6e07db83e3 Reviewed-on: https://review.coreboot.org/c/flashrom/+/44907 Reviewed-by: Edward O'Callaghan quasisec@chromium.org Tested-by: build bot (Jenkins) no-reply@coreboot.org --- M dummyflasher.c 1 file changed, 9 insertions(+), 1 deletion(-)
Approvals: build bot (Jenkins): Verified Edward O'Callaghan: Looks good to me, approved
diff --git a/dummyflasher.c b/dummyflasher.c index b2b3b54..145fe11 100644 --- a/dummyflasher.c +++ b/dummyflasher.c @@ -50,6 +50,7 @@ static enum emu_chip emu_chip = EMULATE_NONE; static char *emu_persistent_image = NULL; static unsigned int emu_chip_size = 0; +static int emu_modified = 0; /* is the image modified since reading it? */ #if EMULATE_SPI_CHIP static unsigned int emu_max_byteprogram_size = 0; static unsigned int emu_max_aai_size = 0; @@ -137,7 +138,7 @@ msg_pspew("%s\n", __func__); #if EMULATE_CHIP if (emu_chip != EMULATE_NONE) { - if (emu_persistent_image) { + if (emu_persistent_image && emu_modified) { msg_pdbg("Writing %s\n", emu_persistent_image); write_buf_to_file(flashchip_contents, emu_chip_size, emu_persistent_image); free(emu_persistent_image); @@ -698,6 +699,7 @@ return 1; } memcpy(flashchip_contents + offs, writearr + 4, writecnt - 4); + emu_modified = 1; break; case JEDEC_AAI_WORD_PROGRAM: if (!emu_max_aai_size) @@ -734,6 +736,7 @@ memcpy(flashchip_contents + aai_offs, writearr + 1, 2); aai_offs += 2; } + emu_modified = 1; break; case JEDEC_WRDI: if (emu_max_aai_size) @@ -755,6 +758,7 @@ msg_pdbg("Unaligned SECTOR ERASE 0x20: 0x%x\n", offs); offs &= ~(emu_jedec_se_size - 1); memset(flashchip_contents + offs, 0xff, emu_jedec_se_size); + emu_modified = 1; break; case JEDEC_BE_52: if (!emu_jedec_be_52_size) @@ -772,6 +776,7 @@ msg_pdbg("Unaligned BLOCK ERASE 0x52: 0x%x\n", offs); offs &= ~(emu_jedec_be_52_size - 1); memset(flashchip_contents + offs, 0xff, emu_jedec_be_52_size); + emu_modified = 1; break; case JEDEC_BE_D8: if (!emu_jedec_be_d8_size) @@ -789,6 +794,7 @@ msg_pdbg("Unaligned BLOCK ERASE 0xd8: 0x%x\n", offs); offs &= ~(emu_jedec_be_d8_size - 1); memset(flashchip_contents + offs, 0xff, emu_jedec_be_d8_size); + emu_modified = 1; break; case JEDEC_CE_60: if (!emu_jedec_ce_60_size) @@ -804,6 +810,7 @@ /* JEDEC_CE_60_OUTSIZE is 1 (no address) -> no offset. */ /* emu_jedec_ce_60_size is emu_chip_size. */ memset(flashchip_contents, 0xff, emu_jedec_ce_60_size); + emu_modified = 1; break; case JEDEC_CE_C7: if (!emu_jedec_ce_c7_size) @@ -819,6 +826,7 @@ /* JEDEC_CE_C7_OUTSIZE is 1 (no address) -> no offset. */ /* emu_jedec_ce_c7_size is emu_chip_size. */ memset(flashchip_contents, 0xff, emu_jedec_ce_c7_size); + emu_modified = 1; break; case JEDEC_SFDP: if (emu_chip != EMULATE_MACRONIX_MX25L6436)