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:
@ -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!"),
|
||||
|
@ -22,7 +22,11 @@ fn main() -> ! {
|
||||
*/
|
||||
|
||||
let mut bl = BootLoader::default();
|
||||
let start = bl.prepare(&mut WatchdogFlash::start(Nvmc::new(p.NVMC), p.WDT, 5));
|
||||
let start = bl.prepare(&mut SingleFlashProvider::new(&mut WatchdogFlash::start(
|
||||
Nvmc::new(p.NVMC),
|
||||
p.WDT,
|
||||
5,
|
||||
)));
|
||||
unsafe { bl.load(start) }
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user