Skip to content

Commit 5310d55

Browse files
committed
sim: corrected maximal image size calculation
Corrected the maximal image size calculation for the swap using scratch mode. Previously the vale which is appropriate for the swap using move mode was used. Signed-off-by: Andrzej Puzdrowski <[email protected]>
1 parent 334b6a6 commit 5310d55

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

sim/src/image.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1522,14 +1522,19 @@ fn install_image(flash: &mut SimMultiFlash, slot: &SlotInfo, len: ImageSize,
15221522
// This computation is incorrect, and we need to figure out the correct size.
15231523
// c::boot_status_sz(dev.align() as u32) as usize
15241524
16 + 4 * dev.align()
1525-
} else {
1525+
} else if Caps::SwapUsingMove.present() {
15261526
let sector_size = dev.sector_iter().next().unwrap().size as u32;
15271527
align_up(c::boot_trailer_sz(dev.align() as u32), sector_size) as usize
1528+
} else if Caps::SwapUsingScratch.present() {
1529+
c::boot_trailer_sz(dev.align() as u32) as usize
1530+
} else {
1531+
panic!("The maximum image size can't be calculated.")
15281532
};
15291533
let tlv_len = tlv.estimate_size();
15301534
info!("slot: 0x{:x}, HDR: 0x{:x}, trailer: 0x{:x}",
15311535
slot_len, HDR_SIZE, trailer);
15321536
slot_len - HDR_SIZE - trailer - tlv_len
1537+
15331538
}
15341539
};
15351540

0 commit comments

Comments
 (0)