Allow different erase sizes for active and dfu

This commit is contained in:
Rasmus Melchior Jacobsen
2023-04-04 21:30:49 +02:00
parent 6c93309df4
commit 53efb02900
3 changed files with 9 additions and 79 deletions

View File

@@ -56,9 +56,9 @@ trait FlashConfigEx {
}
impl<T: FlashConfig> FlashConfigEx for T {
/// Get the page size which is the "unit of operation" within the bootloader.
fn page_size() -> usize {
assert_eq!(T::ACTIVE::ERASE_SIZE, T::DFU::ERASE_SIZE);
T::ACTIVE::ERASE_SIZE
core::cmp::max(T::ACTIVE::ERASE_SIZE, T::DFU::ERASE_SIZE)
}
}
@@ -182,6 +182,8 @@ impl BootLoader {
assert_eq!(0, P::page_size() % aligned_buf.len());
assert_eq!(0, P::page_size() % P::ACTIVE::WRITE_SIZE);
assert_eq!(0, P::page_size() % P::DFU::WRITE_SIZE);
assert_eq!(0, P::page_size() % P::ACTIVE::ERASE_SIZE);
assert_eq!(0, P::page_size() % P::DFU::ERASE_SIZE);
assert!(aligned_buf.len() >= P::STATE::WRITE_SIZE);
assert_partitions(self.active, self.dfu, self.state, P::page_size(), P::STATE::WRITE_SIZE);