sim: get status area size from bootutil
Add new bootutil function that returns the size of the status area.
The simulator was updated to remove the custom calculation and get
the size directly from bootutil, avoiding breakages the happen when
both are not in sync.
Signed-off-by: Fabio Utzig <utzig@apache.org>
diff --git a/sim/mcuboot-sys/src/c.rs b/sim/mcuboot-sys/src/c.rs
index f3de302..6df89e4 100644
--- a/sim/mcuboot-sys/src/c.rs
+++ b/sim/mcuboot-sys/src/c.rs
@@ -36,10 +36,14 @@
(result, asserts)
}
-pub fn boot_trailer_sz(align: u8) -> u32 {
+pub fn boot_trailer_sz(align: u32) -> u32 {
unsafe { raw::boot_trailer_sz(align) }
}
+pub fn boot_status_sz(align: u32) -> u32 {
+ unsafe { raw::boot_status_sz(align) }
+}
+
pub fn boot_magic_sz() -> usize {
unsafe { raw::boot_magic_sz() as usize }
}
@@ -81,7 +85,8 @@
// for information and tracking.
pub fn invoke_boot_go(sim_ctx: *mut CSimContext, areadesc: *const CAreaDesc) -> libc::c_int;
- pub fn boot_trailer_sz(min_write_sz: u8) -> u32;
+ pub fn boot_trailer_sz(min_write_sz: u32) -> u32;
+ pub fn boot_status_sz(min_write_sz: u32) -> u32;
pub fn boot_magic_sz() -> u32;
pub fn boot_max_align() -> u32;
diff --git a/sim/src/image.rs b/sim/src/image.rs
index 8d6fb91..b7f8ed6 100644
--- a/sim/src/image.rs
+++ b/sim/src/image.rs
@@ -657,19 +657,11 @@
}
fn trailer_sz(&self, align: usize) -> usize {
- c::boot_trailer_sz(align as u8) as usize
+ c::boot_trailer_sz(align as u32) as usize
}
- // FIXME: could get status sz from bootloader
fn status_sz(&self, align: usize) -> usize {
- let bias = if Caps::EncRsa.present() || Caps::EncKw.present() ||
- Caps::EncEc256.present() {
- 32
- } else {
- 0
- };
-
- self.trailer_sz(align) - (16 + 32 + bias)
+ c::boot_status_sz(align as u32) as usize
}
/// This test runs a simple upgrade with no fails in the images, but