Skip to content

Commit 5b90dc8

Browse files
committed
sim: image trailer size differentiation
Differentiated image trailer size for swap-using-scratch with max-align-32 feature and without it. Signed-off-by: Andrzej Puzdrowski <[email protected]>
1 parent 5310d55 commit 5b90dc8

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

sim/src/image.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1487,6 +1487,20 @@ enum ImageSize {
14871487
Largest,
14881488
}
14891489

1490+
#[cfg(not(feature = "max-align-32"))]
1491+
fn tralier_estimation(dev: &dyn Flash) -> usize {
1492+
1493+
c::boot_trailer_sz(dev.align() as u32) as usize
1494+
}
1495+
1496+
#[cfg(feature = "max-align-32")]
1497+
fn tralier_estimation(dev: &dyn Flash) -> usize {
1498+
1499+
let sector_size = dev.sector_iter().next().unwrap().size as u32;
1500+
1501+
align_up(c::boot_trailer_sz(dev.align() as u32), sector_size) as usize
1502+
}
1503+
14901504
/// Install a "program" into the given image. This fakes the image header, or at least all of the
14911505
/// fields used by the given code. Returns a copy of the image that was written.
14921506
fn install_image(flash: &mut SimMultiFlash, slot: &SlotInfo, len: ImageSize,
@@ -1526,7 +1540,7 @@ fn install_image(flash: &mut SimMultiFlash, slot: &SlotInfo, len: ImageSize,
15261540
let sector_size = dev.sector_iter().next().unwrap().size as u32;
15271541
align_up(c::boot_trailer_sz(dev.align() as u32), sector_size) as usize
15281542
} else if Caps::SwapUsingScratch.present() {
1529-
c::boot_trailer_sz(dev.align() as u32) as usize
1543+
tralier_estimation(dev)
15301544
} else {
15311545
panic!("The maximum image size can't be calculated.")
15321546
};

0 commit comments

Comments
 (0)