aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/pages/bootloader.adoc6
-rw-r--r--embassy-boot/src/boot_loader.rs12
2 files changed, 10 insertions, 8 deletions
diff --git a/docs/pages/bootloader.adoc b/docs/pages/bootloader.adoc
index b0f0331aa..c010b0622 100644
--- a/docs/pages/bootloader.adoc
+++ b/docs/pages/bootloader.adoc
@@ -43,14 +43,14 @@ Partition Size~dfu~= Partition Size~active~+ Page Size~active~
43+ 43+
44All values are specified in bytes. 44All values are specified in bytes.
45 45
46* BOOTLOADER STATE - Where the bootloader stores the current state describing if the active and dfu partitions need to be swapped. When the new firmware has been written to the DFU partition, a magic field is written to instruct the bootloader that the partitions should be swapped. This partition must be able to store a magic field as well as the partition swap progress. The partition size given by: 46* BOOTLOADER STATE - Where the bootloader stores the current state describing if the active and dfu partitions need to be swapped. When the new firmware has been written to the DFU partition, a magic field is written to instruct the bootloader that the partitions should be swapped. This partition must be able to store a magic field as well as the partition swap progress. The partition size is given by:
47+ 47+
48Partition Size~state~ = Write Size~state~ + (2 × Partition Size~active~ / Page Size~active~) 48Partition Size~state~ = (2 × Write Size~state~) + (4 × Write Size~state~ × Partition Size~active~ / Page Size~active~)
49+ 49+
50All values are specified in bytes. 50All values are specified in bytes.
51 51
52The partitions for ACTIVE (+BOOTLOADER), DFU and BOOTLOADER_STATE may be placed in separate flash. The page size used by the bootloader is determined by the lowest common multiple of the ACTIVE and DFU page sizes. 52The partitions for ACTIVE (+BOOTLOADER), DFU and BOOTLOADER_STATE may be placed in separate flash. The page size used by the bootloader is determined by the lowest common multiple of the ACTIVE and DFU page sizes.
53The BOOTLOADER_STATE partition must be big enough to store one word per page in the ACTIVE and DFU partitions combined. 53The BOOTLOADER_STATE partition must be big enough to store two words, plus four words per page in the ACTIVE partition.
54 54
55The bootloader has a platform-agnostic part, which implements the power fail safe swapping algorithm given the boundaries set by the partitions. The platform-specific part is a minimal shim that provides additional functionality such as watchdogs or supporting the nRF52 softdevice. 55The bootloader has a platform-agnostic part, which implements the power fail safe swapping algorithm given the boundaries set by the partitions. The platform-specific part is a minimal shim that provides additional functionality such as watchdogs or supporting the nRF52 softdevice.
56 56
diff --git a/embassy-boot/src/boot_loader.rs b/embassy-boot/src/boot_loader.rs
index c38940d6e..a3a307051 100644
--- a/embassy-boot/src/boot_loader.rs
+++ b/embassy-boot/src/boot_loader.rs
@@ -135,10 +135,12 @@ pub struct BootLoader<ACTIVE: NorFlash, DFU: NorFlash, STATE: NorFlash> {
135 dfu: DFU, 135 dfu: DFU,
136 /// The state partition has the following format: 136 /// The state partition has the following format:
137 /// All ranges are in multiples of WRITE_SIZE bytes. 137 /// All ranges are in multiples of WRITE_SIZE bytes.
138 /// | Range | Description | 138 /// N = Active partition size divided by WRITE_SIZE.
139 /// | 0..1 | Magic indicating bootloader state. BOOT_MAGIC means boot, SWAP_MAGIC means swap. | 139 /// | Range | Description |
140 /// | 1..2 | Progress validity. ERASE_VALUE means valid, !ERASE_VALUE means invalid. | 140 /// | 0..1 | Magic indicating bootloader state. BOOT_MAGIC means boot, SWAP_MAGIC means swap. |
141 /// | 2..2 + N | Progress index used while swapping or reverting 141 /// | 1..2 | Progress validity. ERASE_VALUE means valid, !ERASE_VALUE means invalid. |
142 /// | 2..(2 + 2N) | Progress index used while swapping |
143 /// | (2 + 2N)..(2 + 4N) | Progress index used while reverting
142 state: STATE, 144 state: STATE,
143} 145}
144 146
@@ -429,7 +431,7 @@ fn assert_partitions<ACTIVE: NorFlash, DFU: NorFlash, STATE: NorFlash>(
429 assert_eq!(dfu.capacity() as u32 % page_size, 0); 431 assert_eq!(dfu.capacity() as u32 % page_size, 0);
430 // DFU partition has to be bigger than ACTIVE partition to handle swap algorithm 432 // DFU partition has to be bigger than ACTIVE partition to handle swap algorithm
431 assert!(dfu.capacity() as u32 - active.capacity() as u32 >= page_size); 433 assert!(dfu.capacity() as u32 - active.capacity() as u32 >= page_size);
432 assert!(2 + 2 * (active.capacity() as u32 / page_size) <= state.capacity() as u32 / STATE::WRITE_SIZE as u32); 434 assert!(2 + 4 * (active.capacity() as u32 / page_size) <= state.capacity() as u32 / STATE::WRITE_SIZE as u32);
433} 435}
434 436
435#[cfg(test)] 437#[cfg(test)]