sim: Add the K64fBig target
This target simulates running with pretend large sectors on a device
that really has small sectors.
diff --git a/sim/src/area.rs b/sim/src/area.rs
index 9bb7d57..c74f664 100644
--- a/sim/src/area.rs
+++ b/sim/src/area.rs
@@ -79,6 +79,29 @@
});
}
+ // Add a simple slot to the image. This ignores the device layout, and just adds the area as a
+ // single unit. It assumes that the image lines up with image boundaries. This tests
+ // configurations where the partition table uses larger sectors than the underlying flash
+ // device.
+ pub fn add_simple_image(&mut self, base: usize, len: usize, id: FlashId) {
+ let area = vec![FlashArea {
+ flash_id: id,
+ device_id: 42,
+ pad16: 0,
+ off: base as u32,
+ size: len as u32,
+ }];
+
+ self.areas.push(area);
+ self.whole.push(FlashArea {
+ flash_id: id,
+ device_id: 42,
+ pad16: 0,
+ off: base as u32,
+ size: len as u32,
+ });
+ }
+
pub fn get_c(&self) -> CAreaDesc {
let mut areas: CAreaDesc = Default::default();
diff --git a/sim/src/main.rs b/sim/src/main.rs
index 5691ac2..33b2c0c 100644
--- a/sim/src/main.rs
+++ b/sim/src/main.rs
@@ -50,7 +50,7 @@
}
#[derive(Debug, RustcDecodable)]
-enum DeviceName { Stm32f4, K64f }
+enum DeviceName { Stm32f4, K64f, K64fBig }
#[derive(Debug)]
struct AlignArg(u8);
@@ -102,6 +102,17 @@
areadesc.add_image(0x060000, 0x001000, FlashId::ImageScratch);
(flash, areadesc)
}
+ Some(DeviceName::K64fBig) => {
+ // Simulating an STM style flash on top of an NXP style flash. Underlying flash device
+ // uses small sectors, but we tell the bootloader they are large.
+ let flash = Flash::new(vec![4096; 128]);
+
+ let mut areadesc = AreaDesc::new(&flash);
+ areadesc.add_simple_image(0x020000, 0x020000, FlashId::Image0);
+ areadesc.add_simple_image(0x040000, 0x020000, FlashId::Image1);
+ areadesc.add_simple_image(0x060000, 0x020000, FlashId::ImageScratch);
+ (flash, areadesc)
+ }
};
// println!("Areas: {:#?}", areadesc.get_c());