Commit 88294be1 authored by Thomas Altenbach's avatar Thomas Altenbach Committed by Jamie
Browse files

sim: Fix incorrect trailer size computation for overwrite-only



For the overwrite-only upgrade strategy, the trailer size computed by
the simulator and used to determine the maximum image size was not
correct. This commit fixes the issue.

Having an underestimated trailer size was causing the
'oversized_secondary_slot' to fail since the previous commit, because
the oversized images are now generated to have the smallest possible
size.

Signed-off-by: default avatarThomas Altenbach <thomas.altenbach@legrand.com>
parent 66c21afc
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -1805,9 +1805,8 @@ fn image_largest_trailer(dev: &dyn Flash, areadesc: &AreaDesc, slot: &SlotInfo)
            // Using the header size we know, the trailer size, and the slot size, we can compute
            // the largest image possible.
            let trailer = if Caps::OverwriteUpgrade.present() {
                // This computation is incorrect, and we need to figure out the correct size.
                // c::boot_status_sz(dev.align() as u32) as usize
                16 + 4 * dev.align()
                // magic + image-ok + copy-done + swap-info
                c::boot_magic_sz() + 3 * c::boot_max_align()
            } else if Caps::SwapUsingOffset.present() || Caps::SwapUsingMove.present() {
                let sector_size = dev.sector_iter().next().unwrap().size as u32;
                align_up(c::boot_trailer_sz(dev.align() as u32), sector_size) as usize