aboutsummaryrefslogtreecommitdiff
path: root/embassy-boot/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'embassy-boot/src/lib.rs')
-rw-r--r--embassy-boot/src/lib.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/embassy-boot/src/lib.rs b/embassy-boot/src/lib.rs
index 8849055e8..7d5cc58f9 100644
--- a/embassy-boot/src/lib.rs
+++ b/embassy-boot/src/lib.rs
@@ -25,6 +25,7 @@ pub use firmware_updater::{
25 FirmwareUpdaterError, 25 FirmwareUpdaterError,
26}; 26};
27 27
28pub(crate) const REVERT_MAGIC: u8 = 0xC0;
28pub(crate) const BOOT_MAGIC: u8 = 0xD0; 29pub(crate) const BOOT_MAGIC: u8 = 0xD0;
29pub(crate) const SWAP_MAGIC: u8 = 0xF0; 30pub(crate) const SWAP_MAGIC: u8 = 0xF0;
30pub(crate) const DFU_DETACH_MAGIC: u8 = 0xE0; 31pub(crate) const DFU_DETACH_MAGIC: u8 = 0xE0;
@@ -37,6 +38,8 @@ pub enum State {
37 Boot, 38 Boot,
38 /// Bootloader has swapped the active partition with the dfu partition and will attempt boot. 39 /// Bootloader has swapped the active partition with the dfu partition and will attempt boot.
39 Swap, 40 Swap,
41 /// Bootloader has reverted the active partition with the dfu partition and will attempt boot.
42 Revert,
40 /// Application has received a request to reboot into DFU mode to apply an update. 43 /// Application has received a request to reboot into DFU mode to apply an update.
41 DfuDetach, 44 DfuDetach,
42} 45}
@@ -157,6 +160,9 @@ mod tests {
157 // Running again should cause a revert 160 // Running again should cause a revert
158 assert_eq!(State::Swap, bootloader.prepare_boot(&mut page).unwrap()); 161 assert_eq!(State::Swap, bootloader.prepare_boot(&mut page).unwrap());
159 162
163 // Next time we know it was reverted
164 assert_eq!(State::Revert, bootloader.prepare_boot(&mut page).unwrap());
165
160 let mut read_buf = [0; FIRMWARE_SIZE]; 166 let mut read_buf = [0; FIRMWARE_SIZE];
161 flash.active().read(0, &mut read_buf).unwrap(); 167 flash.active().read(0, &mut read_buf).unwrap();
162 assert_eq!(ORIGINAL, read_buf); 168 assert_eq!(ORIGINAL, read_buf);