mcuboot/boot/bootutil
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
..
include/bootutil Revert "boot: Add MCUBOOT_HW_KEY support for image encryption" 2024-07-09 09:19:43 -06:00
src bootutil: Properly retrieve image headers after interrupted swap-scratch 2024-11-04 14:23:22 +00:00
zephyr zephyr: direct inclusion of the hooks file 2022-08-04 11:17:19 +02:00
CMakeLists.txt bootutil/crypto: Have a single ECDSA verification module 2023-04-26 13:57:53 +02:00
pkg.yml mynewt: Igore swap_scratch.c for single application slot 2024-05-23 18:09:36 +02:00