Merge pull request #2280 from plaes/embassy-boot-partition-docs

embassy-boot: Add explanation to dfu vs active size assertion
This commit is contained in:
Ulf Lilleengen 2023-12-13 09:50:42 +00:00 committed by GitHub
commit 915423fc63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -224,6 +224,7 @@ impl<ACTIVE: NorFlash, DFU: NorFlash, STATE: NorFlash> BootLoader<ACTIVE, DFU, S
assert_eq!(0, aligned_buf.len() % ACTIVE::WRITE_SIZE); assert_eq!(0, aligned_buf.len() % ACTIVE::WRITE_SIZE);
assert_eq!(0, aligned_buf.len() % DFU::WRITE_SIZE); assert_eq!(0, aligned_buf.len() % DFU::WRITE_SIZE);
// Ensure our partitions are able to handle boot operations
assert_partitions(&self.active, &self.dfu, &self.state, Self::PAGE_SIZE); assert_partitions(&self.active, &self.dfu, &self.state, Self::PAGE_SIZE);
// Copy contents from partition N to active // Copy contents from partition N to active
@ -398,6 +399,7 @@ fn assert_partitions<ACTIVE: NorFlash, DFU: NorFlash, STATE: NorFlash>(
) { ) {
assert_eq!(active.capacity() as u32 % page_size, 0); assert_eq!(active.capacity() as u32 % page_size, 0);
assert_eq!(dfu.capacity() as u32 % page_size, 0); assert_eq!(dfu.capacity() as u32 % page_size, 0);
// DFU partition has to be bigger than ACTIVE partition to handle swap algorithm
assert!(dfu.capacity() as u32 - active.capacity() as u32 >= page_size); assert!(dfu.capacity() as u32 - active.capacity() as u32 >= page_size);
assert!(2 + 2 * (active.capacity() as u32 / page_size) <= state.capacity() as u32 / STATE::WRITE_SIZE as u32); assert!(2 + 2 * (active.capacity() as u32 / page_size) <= state.capacity() as u32 / STATE::WRITE_SIZE as u32);
} }