Commit 259d989f authored by Stephane Le Roy's avatar Stephane Le Roy Committed by Fabio Utzig
Browse files

bootutil: Fix erase of trailer when located in scratch area

Trailer is temporary located in scratch when data of image goes up to last
sector of primary slot. At the end of the swap procedure, the temporary
trailer in scratch must be erased to prevent mcuboot from reading a stale
status from the scratch area. The erase tentative was not correct, this
is fixed.Issue is easily reproduced with an image size of one sector.

Signed-off-by: default avatarStephane Le Roy <stephane.leroy@st.com>
Signed-off-by: default avatarMichel Jaouen <michel.jaouen@st.com>
parent e8294b2a
Loading
Loading
Loading
Loading
+1 −1
Changes for boot/bootutil/src/swap_scratch.c: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -673,7 +673,7 @@ boot_swap_sectors(int idx, uint32_t sz, struct boot_loader_state *state,
        BOOT_STATUS_ASSERT(rc == 0);

        if (erase_scratch) {
            rc = boot_erase_region(fap_scratch, 0, sz);
            rc = boot_erase_region(fap_scratch, 0, flash_area_get_size(fap_scratch));
            assert(rc == 0);
        }
    }