aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlf Lilleengen <[email protected]>2023-12-13 09:50:42 +0000
committerGitHub <[email protected]>2023-12-13 09:50:42 +0000
commit915423fc63f209059a2242fbc3ad3b88d796514f (patch)
tree3291830aa827b4458a53c1ce9eb7733879ed8c61
parent14f41a71b6ea9dedb4ee5b9c741fe10575772c7d (diff)
parent6782fb1efa1bd4c5372220bb38539ea1e7ef6ffa (diff)
Merge pull request #2280 from plaes/embassy-boot-partition-docs
embassy-boot: Add explanation to dfu vs active size assertion
-rw-r--r--embassy-boot/boot/src/boot_loader.rs2
1 files changed, 2 insertions, 0 deletions
diff --git a/embassy-boot/boot/src/boot_loader.rs b/embassy-boot/boot/src/boot_loader.rs
index a8c19197b..1663f4f2c 100644
--- a/embassy-boot/boot/src/boot_loader.rs
+++ b/embassy-boot/boot/src/boot_loader.rs
@@ -224,6 +224,7 @@ impl<ACTIVE: NorFlash, DFU: NorFlash, STATE: NorFlash> BootLoader<ACTIVE, DFU, S
224 assert_eq!(0, aligned_buf.len() % ACTIVE::WRITE_SIZE); 224 assert_eq!(0, aligned_buf.len() % ACTIVE::WRITE_SIZE);
225 assert_eq!(0, aligned_buf.len() % DFU::WRITE_SIZE); 225 assert_eq!(0, aligned_buf.len() % DFU::WRITE_SIZE);
226 226
227 // Ensure our partitions are able to handle boot operations
227 assert_partitions(&self.active, &self.dfu, &self.state, Self::PAGE_SIZE); 228 assert_partitions(&self.active, &self.dfu, &self.state, Self::PAGE_SIZE);
228 229
229 // Copy contents from partition N to active 230 // Copy contents from partition N to active
@@ -398,6 +399,7 @@ fn assert_partitions<ACTIVE: NorFlash, DFU: NorFlash, STATE: NorFlash>(
398) { 399) {
399 assert_eq!(active.capacity() as u32 % page_size, 0); 400 assert_eq!(active.capacity() as u32 % page_size, 0);
400 assert_eq!(dfu.capacity() as u32 % page_size, 0); 401 assert_eq!(dfu.capacity() as u32 % page_size, 0);
402 // DFU partition has to be bigger than ACTIVE partition to handle swap algorithm
401 assert!(dfu.capacity() as u32 - active.capacity() as u32 >= page_size); 403 assert!(dfu.capacity() as u32 - active.capacity() as u32 >= page_size);
402 assert!(2 + 2 * (active.capacity() as u32 / page_size) <= state.capacity() as u32 / STATE::WRITE_SIZE as u32); 404 assert!(2 + 2 * (active.capacity() as u32 / page_size) <= state.capacity() as u32 / STATE::WRITE_SIZE as u32);
403} 405}