From bd237a1f96680f2cdf411ef2ca80beaa6b09cc6a Mon Sep 17 00:00:00 2001 From: Ulf Lilleengen Date: Thu, 28 Apr 2022 10:38:25 +0200 Subject: Allow using separate page sizes for state and dfu * Less generics on bootloader. Keep PAGE_SIZE as a common multiple of DFU and ACTIVE page sizes. * Document restriction * Add unit tests for different page sizes --- embassy-boot/nrf/src/lib.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'embassy-boot/nrf/src') diff --git a/embassy-boot/nrf/src/lib.rs b/embassy-boot/nrf/src/lib.rs index c12899d77..9f891887c 100644 --- a/embassy-boot/nrf/src/lib.rs +++ b/embassy-boot/nrf/src/lib.rs @@ -1,10 +1,14 @@ #![no_std] #![feature(generic_associated_types)] #![feature(type_alias_impl_trait)] +#![allow(incomplete_features)] +#![feature(generic_const_exprs)] mod fmt; -pub use embassy_boot::{FirmwareUpdater, FlashProvider, Partition, SingleFlashProvider}; +pub use embassy_boot::{ + FirmwareUpdater, FlashConfig, FlashProvider, Partition, SingleFlashProvider, +}; use embassy_nrf::{ nvmc::{Nvmc, PAGE_SIZE}, peripherals::WDT, @@ -13,7 +17,7 @@ use embassy_nrf::{ use embedded_storage::nor_flash::{ErrorType, NorFlash, ReadNorFlash}; pub struct BootLoader { - boot: embassy_boot::BootLoader, + boot: embassy_boot::BootLoader, } impl BootLoader { @@ -62,7 +66,11 @@ impl BootLoader { } /// Boots the application without softdevice mechanisms - pub fn prepare(&mut self, flash: &mut F) -> usize { + pub fn prepare(&mut self, flash: &mut F) -> usize + where + [(); <::STATE as FlashConfig>::FLASH::WRITE_SIZE]:, + [(); <::ACTIVE as FlashConfig>::FLASH::ERASE_SIZE]:, + { match self.boot.prepare_boot(flash) { Ok(_) => self.boot.boot_address(), Err(_) => panic!("boot prepare error!"), -- cgit