Skip to content

Commit 1b24247

Browse files
committed
sim: swap-move: Update expected post-upgrade secondary trailer content
When swap-move is used, the secondary slot's trailer is no longer expected to be empty after an upgrade has been performed. Instead, the secondary slot should contain a valid trailer with only the 'copy_done' flag set. Signed-off-by: Thomas Altenbach <thomas.altenbach@legrand.com>
1 parent 73270e4 commit 1b24247

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

sim/src/image.rs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -742,8 +742,7 @@ impl Images {
742742
fails += 1;
743743
}
744744

745-
if !self.verify_trailers(&flash, 1, BOOT_MAGIC_UNSET,
746-
BOOT_FLAG_UNSET, BOOT_FLAG_UNSET) {
745+
if !self.verify_post_upgrade_secondary_trailer(&flash) {
747746
warn!("Mismatched trailer for the secondary slot");
748747
fails += 1;
749748
}
@@ -792,8 +791,7 @@ impl Images {
792791
error!("Mismatched trailer for the primary slot");
793792
fails += 1;
794793
}
795-
if !self.verify_trailers(&flash, 1, BOOT_MAGIC_UNSET,
796-
BOOT_FLAG_UNSET, BOOT_FLAG_UNSET) {
794+
if !self.verify_post_upgrade_secondary_trailer(&flash) {
797795
error!("Mismatched trailer for the secondary slot");
798796
fails += 1;
799797
}
@@ -852,13 +850,14 @@ impl Images {
852850
warn!("Primary slot image verification FAIL");
853851
fails += 1;
854852
}
853+
855854
if !self.verify_trailers(&flash, 0, BOOT_MAGIC_GOOD,
856855
BOOT_FLAG_UNSET, BOOT_FLAG_SET) {
857856
warn!("Mismatched trailer for the primary slot");
858857
fails += 1;
859858
}
860-
if !self.verify_trailers(&flash, 1, BOOT_MAGIC_UNSET,
861-
BOOT_FLAG_UNSET, BOOT_FLAG_UNSET) {
859+
860+
if !self.verify_post_upgrade_secondary_trailer(&flash) {
862861
warn!("Mismatched trailer for the secondary slot");
863862
fails += 1;
864863
}
@@ -1530,8 +1529,7 @@ impl Images {
15301529
warn!("Mismatched trailer for the primary slot before revert");
15311530
fails += 1;
15321531
}
1533-
if !self.verify_trailers(&flash, 1, BOOT_MAGIC_UNSET,
1534-
BOOT_FLAG_UNSET, BOOT_FLAG_UNSET) {
1532+
if !self.verify_post_upgrade_secondary_trailer(&flash) {
15351533
warn!("Mismatched trailer for the secondary slot before revert");
15361534
fails += 1;
15371535
}
@@ -1670,6 +1668,17 @@ impl Images {
16701668
})
16711669
}
16721670

1671+
// Verify the trailers in the secondary slot contains the expected values after an upgrade.
1672+
fn verify_post_upgrade_secondary_trailer(&self, flash: &SimMultiFlash) -> bool {
1673+
if Caps::SwapUsingMove.present() {
1674+
return self.verify_trailers(&flash, 1, BOOT_MAGIC_GOOD,
1675+
BOOT_FLAG_UNSET, BOOT_FLAG_SET);
1676+
} else {
1677+
return self.verify_trailers(&flash, 1, BOOT_MAGIC_UNSET,
1678+
BOOT_FLAG_UNSET, BOOT_FLAG_UNSET);
1679+
}
1680+
}
1681+
16731682
/// Mark each of the images for permanent upgrade.
16741683
fn mark_permanent_upgrades(&self, flash: &mut SimMultiFlash, slot: usize) {
16751684
for image in &self.images {

0 commit comments

Comments
 (0)