1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-10-21 01:30:53 +02:00

erase: Print message when prepare_flash_access failed

prepare_flash_access provides check the required conditions for
erase operation to be performed. If the check fails, operation
aborts, i.e. erase does not start. However for the user this
information is not clearly messaged, and even more, user still
has emergency_help_message.

The patch adds message for the user when prepare_flash_access failed
and operation itself hasn't started.

The message can be repro with dummyflasher

for erase
./flashrom -p dummy:hwwp=yes,emulate=S25FL128L --wp-enable \
  --wp-range 0x00040000,0x00fc0000 \
  -l <(echo '00000000:0004ffff part1') -i part1 -E

for write
./flashrom -p dummy:hwwp=yes,emulate=S25FL128L --wp-enable \
  --wp-range 0x00040000,0x00fc0000 \
  -l <(echo '00000000:0004ffff part1') -i part1 -w <some file>

BEFORE

for erase, output ends with:

can_change_target_regions: cannot fully update part1 region
 (00000000..0x04ffff) due to chip's write-protection.
At least one target region is not fully writable. Aborting.
Your flash chip is in an unknown state.
Please report this to the mailing list at flashrom@flashrom.org or
on chat (see https://flashrom.org/contact.html for details), thanks!

So it says "Aborting" but then
"Your flash chip is in an unknown state" and likely the user
will focus on the second part, the scary message

for write, the operation is actually Aborting
(no unknown state message)

AFTER

for erase, output ends with:

can_change_target_regions: cannot fully update part1 region
 (00000000..0x04ffff) due to chip's write-protection.
At least one target region is not fully writable. Aborting.
Error: some of the required checks to prepare flash access failed.
Earlier messages should give more details.
Erase operation has not started.

for write I added the same info for consistency:

can_change_target_regions: cannot fully update part1 region
 (00000000..0x04ffff) due to chip's write-protection.
At least one target region is not fully writable. Aborting.
Error: some of the required checks to prepare flash access failed.
Earlier messages should give more details.
Write operation has not started.

Change-Id: Id251c2b7f12df3378feb84b5761581dd272240be
Tested-by: Michał Iwanicki <michal.iwanicki@3mdeb.com>
Signed-off-by: Anastasia Klimchuk <aklm@flashrom.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/89413
Reviewed-by: Peter Marheine <pmarheine@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Michał Iwanicki <michal.iwanicki@3mdeb.com>
Reviewed-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
This commit is contained in:
Anastasia Klimchuk
2025-10-03 22:33:41 +10:00
parent 829c0e4e6a
commit 05961d847a
4 changed files with 23 additions and 13 deletions

View File

@@ -285,7 +285,7 @@ void full_chip_erase_with_wp_dummyflasher_test_success(void **state)
/* Try erasing the chip again. Now that WP is active, the first 4 KiB is
protected and we're trying to erase the whole chip, erase should
fail. */
assert_int_equal(1, flashrom_flash_erase(&flash));
assert_int_equal(ERROR_FLASHROM_PREPARE_FLASH_ACCESS, flashrom_flash_erase(&flash));
teardown(&layout);