mcuboot/boot
Thomas Altenbach 3c2f837528 bootutil: Properly retrieve image headers after interrupted swap-scratch
For swap using scratch, the boot_read_image_header routine, responsible
for reading the image headers, was always looking for the primary and
secondary image's headers at the beginning of respectively the primary
and secondary slots, regardless of the current boot status.

This means if during a swap-scratch upgrade a reset happens after the
sector containing the image header in the primary or secondary slot has
been erased, invalid image headers were read since at that time the
location of the headers has changed.

Currently, this doesn't seem to cause any issue because the swap-scratch
algorithm is implemented in such a way the content of the headers is no
more necessary when the headers are erased. However, to be able to
decrypt the secondary image when copied to the primary slot instead of
when copied to the scratch area, properly reading the secondary image's
header is required even after it has been erased from the secondary
slot.

To that end, the boot_read_image_header is modified to determine from
the boot status the current location of the image headers and to always
read the actual header, no matter the current state of the upgrade
process.

Signed-off-by: Thomas Altenbach <thomas.altenbach@legrand.com>
(cherry picked from commit f515bb1c44)
2024-11-04 14:23:22 +00:00
..
boot_serial boot: Removed unnecessary if-statement 2024-04-18 10:49:14 +01:00
bootutil bootutil: Properly retrieve image headers after interrupted swap-scratch 2024-11-04 14:23:22 +00:00
cypress Revert "boot: Add MCUBOOT_HW_KEY support for image encryption" 2024-07-09 09:19:43 -06:00
espressif espressif: allow the use of a different toolchain for building 2023-10-17 04:41:37 -03:00
mbed Revert "boot: Add MCUBOOT_HW_KEY support for image encryption" 2024-07-09 09:19:43 -06:00
mynewt mynewt: Igore swap_scratch.c for single application slot 2024-05-23 18:09:36 +02:00
nuttx nuttx: switch to flash_area_get_sector 2023-08-02 11:28:34 +02:00
zcbor zcbor: Make changes to zcbor code to satisfy mynewt compile options 2024-01-30 12:18:51 +00:00
zephyr boot: zephyr: Fix build for nrf9160dk 2024-07-10 07:37:43 +01:00