Edward O'Callaghan has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/47859 )
Change subject: dummyflasher.c: Allow filling with either 0x00 or 0xff ......................................................................
dummyflasher.c: Allow filling with either 0x00 or 0xff
This upstreams a ChromiumOS feature that allows the user of the dummyflasher spi master to either fill with 0x00 or 0xff in the fake flash content by way of a spi master param.
BUG=b:140394053 BRANCH=none TEST=none
Change-Id: I37c6dee932e449201d8bbfb03ca6d139da3cb6a2 Signed-off-by: Edward O'Callaghan quasisec@google.com --- M dummyflasher.c 1 file changed, 22 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/59/47859/1
diff --git a/dummyflasher.c b/dummyflasher.c index 82aa3c8..d9c4085 100644 --- a/dummyflasher.c +++ b/dummyflasher.c @@ -52,6 +52,7 @@ enum emu_chip emu_chip; char *emu_persistent_image; unsigned int emu_chip_size; + int erase_to_zero; int emu_modified; /* is the image modified since reading it? */ uint8_t emu_status; /* If "freq" parameter is passed in from command line, commands will delay @@ -454,6 +455,21 @@ free(tmp); return 1; } + + /* Should emulated flash erase to zero (yes/no)? */ + tmp = extract_programmer_param("erase_to_zero"); + if (tmp) { + if (!strcmp(tmp, "yes")) { + msg_pdbg("Emulated chip will erase to 0x00\n"); + data->erase_to_zero = 1; + } else if (!strcmp(tmp, "no")) { + msg_pdbg("Emulated chip will erase to 0xff\n"); + } else { + msg_perr("erase_to_zero can be "yes" or "no"\n"); + return 1; + } + } + free(tmp); flashchip_contents = malloc(data->emu_chip_size); if (!flashchip_contents) { @@ -478,8 +494,9 @@ } #endif
- msg_pdbg("Filling fake flash chip with 0xff, size %i\n", data->emu_chip_size); - memset(flashchip_contents, 0xff, data->emu_chip_size); + msg_pdbg("Filling fake flash chip with 0x%02x, size %i\n", + data->erase_to_zero ? 0x00 : 0xff, data->emu_chip_size); + memset(flashchip_contents, data->erase_to_zero ? 0x00 : 0xff, data->emu_chip_size);
/* Will be freed by shutdown function if necessary. */ data->emu_persistent_image = extract_programmer_param("image"); @@ -1052,6 +1069,9 @@ msg_cdbg("%s: set flash->total_size to %dK bytes.\n", __func__, flash->chip->total_size);
+ if (emu_data->erase_to_zero) + flash->chip->feature_bits |= FEATURE_ERASED_ZERO; + /* Update the first count of each of the block_erasers. */ for (i = 0; i < NUM_ERASEFUNCTIONS; i++) { struct block_eraser *eraser = &flash->chip->block_erasers[i];
Hello Sam McNally, Nico Huber, Namyoon Woo, Angel Pons,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/flashrom/+/47859
to look at the new patch set (#2).
Change subject: dummyflasher.c: Allow filling with either 0x00 or 0xff ......................................................................
dummyflasher.c: Allow filling with either 0x00 or 0xff
This upstreams a ChromiumOS feature that allows the user of the dummyflasher spi master to either fill with 0x00 or 0xff in the fake flash content by way of a spi master param.
BUG=b:140394053 BRANCH=none TEST=none
Change-Id: I37c6dee932e449201d8bbfb03ca6d139da3cb6a2 Signed-off-by: Edward O'Callaghan quasisec@google.com --- M dummyflasher.c 1 file changed, 23 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/59/47859/2
Namyoon Woo has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/47859 )
Change subject: dummyflasher.c: Allow filling with either 0x00 or 0xff ......................................................................
Patch Set 2: Code-Review+1
Sam McNally has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/47859 )
Change subject: dummyflasher.c: Allow filling with either 0x00 or 0xff ......................................................................
Patch Set 2:
(1 comment)
https://review.coreboot.org/c/flashrom/+/47859/2/dummyflasher.c File dummyflasher.c:
https://review.coreboot.org/c/flashrom/+/47859/2/dummyflasher.c@474 PS2, Line 474: free(tmp); This free was here before. The "emulate" param won't be freed with this change.
Please also move the blank line after the free; it should be attached to the block where tmp was allocated.
Hello Sam McNally, build bot (Jenkins), Nico Huber, Namyoon Woo, Angel Pons,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/flashrom/+/47859
to look at the new patch set (#3).
Change subject: dummyflasher.c: Allow filling with either 0x00 or 0xff ......................................................................
dummyflasher.c: Allow filling with either 0x00 or 0xff
This upstreams a ChromiumOS feature that allows the user of the dummyflasher spi master to either fill with 0x00 or 0xff in the fake flash content by way of a spi master param.
BUG=b:140394053 BRANCH=none TEST=none
Change-Id: I37c6dee932e449201d8bbfb03ca6d139da3cb6a2 Signed-off-by: Edward O'Callaghan quasisec@google.com --- M dummyflasher.c 1 file changed, 24 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/59/47859/3
Edward O'Callaghan has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/47859 )
Change subject: dummyflasher.c: Allow filling with either 0x00 or 0xff ......................................................................
Patch Set 3:
(1 comment)
https://review.coreboot.org/c/flashrom/+/47859/2/dummyflasher.c File dummyflasher.c:
https://review.coreboot.org/c/flashrom/+/47859/2/dummyflasher.c@474 PS2, Line 474: free(tmp);
This free was here before. The "emulate" param won't be freed with this change. […]
Fixed. It's just leaky in ours which is no surprise.
Sam McNally has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/47859 )
Change subject: dummyflasher.c: Allow filling with either 0x00 or 0xff ......................................................................
Patch Set 3: Code-Review+2
Edward O'Callaghan has submitted this change. ( https://review.coreboot.org/c/flashrom/+/47859 )
Change subject: dummyflasher.c: Allow filling with either 0x00 or 0xff ......................................................................
dummyflasher.c: Allow filling with either 0x00 or 0xff
This upstreams a ChromiumOS feature that allows the user of the dummyflasher spi master to either fill with 0x00 or 0xff in the fake flash content by way of a spi master param.
BUG=b:140394053 BRANCH=none TEST=none
Change-Id: I37c6dee932e449201d8bbfb03ca6d139da3cb6a2 Signed-off-by: Edward O'Callaghan quasisec@google.com Reviewed-on: https://review.coreboot.org/c/flashrom/+/47859 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Sam McNally sammc@google.com --- M dummyflasher.c 1 file changed, 24 insertions(+), 2 deletions(-)
Approvals: build bot (Jenkins): Verified Sam McNally: Looks good to me, approved
diff --git a/dummyflasher.c b/dummyflasher.c index 82aa3c8..92c30ee 100644 --- a/dummyflasher.c +++ b/dummyflasher.c @@ -52,6 +52,7 @@ enum emu_chip emu_chip; char *emu_persistent_image; unsigned int emu_chip_size; + int erase_to_zero; int emu_modified; /* is the image modified since reading it? */ uint8_t emu_status; /* If "freq" parameter is passed in from command line, commands will delay @@ -455,6 +456,23 @@ return 1; } free(tmp); + + /* Should emulated flash erase to zero (yes/no)? */ + tmp = extract_programmer_param("erase_to_zero"); + if (tmp) { + if (!strcmp(tmp, "yes")) { + msg_pdbg("Emulated chip will erase to 0x00\n"); + data->erase_to_zero = 1; + } else if (!strcmp(tmp, "no")) { + msg_pdbg("Emulated chip will erase to 0xff\n"); + } else { + msg_perr("erase_to_zero can be "yes" or "no"\n"); + free(tmp); + return 1; + } + } + free(tmp); + flashchip_contents = malloc(data->emu_chip_size); if (!flashchip_contents) { msg_perr("Out of memory!\n"); @@ -478,8 +496,9 @@ } #endif
- msg_pdbg("Filling fake flash chip with 0xff, size %i\n", data->emu_chip_size); - memset(flashchip_contents, 0xff, data->emu_chip_size); + msg_pdbg("Filling fake flash chip with 0x%02x, size %i\n", + data->erase_to_zero ? 0x00 : 0xff, data->emu_chip_size); + memset(flashchip_contents, data->erase_to_zero ? 0x00 : 0xff, data->emu_chip_size);
/* Will be freed by shutdown function if necessary. */ data->emu_persistent_image = extract_programmer_param("image"); @@ -1052,6 +1071,9 @@ msg_cdbg("%s: set flash->total_size to %dK bytes.\n", __func__, flash->chip->total_size);
+ if (emu_data->erase_to_zero) + flash->chip->feature_bits |= FEATURE_ERASED_ZERO; + /* Update the first count of each of the block_erasers. */ for (i = 0; i < NUM_ERASEFUNCTIONS; i++) { struct block_eraser *eraser = &flash->chip->block_erasers[i];