sim: Test DIRECT_XIP configuration
Perform simplistic test of the DIRECT_XIP configuration (both with single and multi-images). This verifies that the bootloader indicates the upgrade image should be booted. Signed-off-by: David Brown <david.brown@linaro.org>
This commit is contained in:
parent
695e591cf5
commit
0dfb810d36
|
@ -969,6 +969,35 @@ impl Images {
|
|||
}
|
||||
}
|
||||
|
||||
/// Test the direct XIP configuration. With this mode, flash images are never moved, and the
|
||||
/// bootloader merely selects which partition is the proper one to boot.
|
||||
pub fn run_direct_xip(&self) -> bool {
|
||||
if !Caps::DirectXip.present() {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Clone the flash so we can tell if unchanged.
|
||||
let mut flash = self.flash.clone();
|
||||
|
||||
let result = c::boot_go(&mut flash, &self.areadesc, None, true);
|
||||
|
||||
// Ensure the boot was successful.
|
||||
let resp = if let Some(resp) = result.resp() {
|
||||
resp
|
||||
} else {
|
||||
panic!("Boot didn't return a valid result");
|
||||
};
|
||||
|
||||
// This configuration should always try booting from the first upgrade slot.
|
||||
if let Some((offset, _, dev_id)) = self.areadesc.find(FlashId::Image1) {
|
||||
assert_eq!(offset, resp.image_off as usize);
|
||||
assert_eq!(dev_id, resp.flash_dev_id);
|
||||
} else {
|
||||
panic!("Unable to find upgrade image");
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
/// Adds a new flash area that fails statistically
|
||||
fn mark_bad_status_with_rate(&self, flash: &mut SimMultiFlash, slot: usize,
|
||||
rate: f32) {
|
||||
|
|
|
@ -59,6 +59,8 @@ sim_test!(status_write_fails_complete, make_image(&NO_DEPS, true), run_with_stat
|
|||
sim_test!(status_write_fails_with_reset, make_image(&NO_DEPS, true), run_with_status_fails_with_reset());
|
||||
sim_test!(downgrade_prevention, make_image(&REV_DEPS, true), run_nodowngrade());
|
||||
|
||||
sim_test!(direct_xip_first, make_no_upgrade_image(&NO_DEPS), run_direct_xip());
|
||||
|
||||
// Test various combinations of incorrect dependencies.
|
||||
test_shell!(dependency_combos, r, {
|
||||
// Only test setups with two images.
|
||||
|
|
Loading…
Reference in New Issue