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:
David Brown 2021-06-03 15:29:11 -06:00 committed by David Brown
parent 695e591cf5
commit 0dfb810d36
2 changed files with 31 additions and 0 deletions

View File

@ -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 /// Adds a new flash area that fails statistically
fn mark_bad_status_with_rate(&self, flash: &mut SimMultiFlash, slot: usize, fn mark_bad_status_with_rate(&self, flash: &mut SimMultiFlash, slot: usize,
rate: f32) { rate: f32) {

View File

@ -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!(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!(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 various combinations of incorrect dependencies.
test_shell!(dependency_combos, r, { test_shell!(dependency_combos, r, {
// Only test setups with two images. // Only test setups with two images.