Skip to content

Commit 9527f3e

Browse files
committed
fw/system/firmware_storage: fix slot invalidation
To invalidate a slot it is sufficient to erase its first sector. Reading the firmware header is pointless (and dangerous without any validation!), e.g. if already erased. Signed-off-by: Gerard Marull-Paretas <[email protected]>
1 parent dd6d058 commit 9527f3e

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/fw/system/firmware_storage.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,10 @@ void firmware_storage_invalidate_firmware_slot(uint8_t slot) {
7676
slot_start = FLASH_REGION_FIRMWARE_SLOT_1_BEGIN;
7777
}
7878

79-
FirmwareHeader hdr = firmware_storage_read_firmware_header(slot_start);
8079
flash_region_erase_optimal_range(slot_start,
8180
slot_start,
82-
ROUND_TO_MOD_CEIL((slot_start + hdr.fw_start), SUBSECTOR_SIZE_BYTES),
83-
ROUND_TO_MOD_CEIL((slot_start + hdr.fw_start), SUBSECTOR_SIZE_BYTES));
81+
slot_start + SUBSECTOR_SIZE_BYTES,
82+
slot_start + SUBSECTOR_SIZE_BYTES);
8483
}
8584

8685
#endif

0 commit comments

Comments
 (0)