Support multiple flash instances in embassy-boot

* Add FlashProvider and FlashConfig traits to define flash
characteristics
* Use traits in bootloader to retrieve flash handles and for
copying data between flash instances
* Add convenience implementations for using a single flash instance.
This commit is contained in:
Ulf Lilleengen
2022-04-19 14:42:38 +02:00
parent e2ed41b383
commit 2afff617f6
8 changed files with 207 additions and 52 deletions

View File

@ -4,7 +4,9 @@
mod fmt;
pub use embassy_boot::{FirmwareUpdater, Partition, State, BOOT_MAGIC};
pub use embassy_boot::{
FirmwareUpdater, FlashProvider, Partition, SingleFlashProvider, State, BOOT_MAGIC,
};
use embassy_nrf::{
nvmc::{Nvmc, PAGE_SIZE},
peripherals::WDT,
@ -62,7 +64,7 @@ impl BootLoader {
}
/// Boots the application without softdevice mechanisms
pub fn prepare<F: NorFlash + ReadNorFlash>(&mut self, flash: &mut F) -> usize {
pub fn prepare<F: FlashProvider>(&mut self, flash: &mut F) -> usize {
match self.boot.prepare_boot(flash) {
Ok(_) => self.boot.boot_address(),
Err(_) => panic!("boot prepare error!"),