diff options
| author | Ulf Lilleengen <[email protected]> | 2022-04-19 14:42:38 +0200 |
|---|---|---|
| committer | Ulf Lilleengen <[email protected]> | 2022-04-19 20:07:06 +0200 |
| commit | 2afff617f652d0fdcfa9ffcfd49062e3d2c996a3 (patch) | |
| tree | bc531122365086cd24a12a9331c94f9f042cad3a /embassy-boot/nrf/src | |
| parent | e2ed41b3832db17633ae8ae1ee9391639c3a9229 (diff) | |
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.
Diffstat (limited to 'embassy-boot/nrf/src')
| -rw-r--r-- | embassy-boot/nrf/src/lib.rs | 6 | ||||
| -rw-r--r-- | embassy-boot/nrf/src/main.rs | 6 |
2 files changed, 9 insertions, 3 deletions
diff --git a/embassy-boot/nrf/src/lib.rs b/embassy-boot/nrf/src/lib.rs index 32250b2db..785cb67e8 100644 --- a/embassy-boot/nrf/src/lib.rs +++ b/embassy-boot/nrf/src/lib.rs | |||
| @@ -4,7 +4,9 @@ | |||
| 4 | 4 | ||
| 5 | mod fmt; | 5 | mod fmt; |
| 6 | 6 | ||
| 7 | pub use embassy_boot::{FirmwareUpdater, Partition, State, BOOT_MAGIC}; | 7 | pub use embassy_boot::{ |
| 8 | FirmwareUpdater, FlashProvider, Partition, SingleFlashProvider, State, BOOT_MAGIC, | ||
| 9 | }; | ||
| 8 | use embassy_nrf::{ | 10 | use embassy_nrf::{ |
| 9 | nvmc::{Nvmc, PAGE_SIZE}, | 11 | nvmc::{Nvmc, PAGE_SIZE}, |
| 10 | peripherals::WDT, | 12 | peripherals::WDT, |
| @@ -62,7 +64,7 @@ impl BootLoader { | |||
| 62 | } | 64 | } |
| 63 | 65 | ||
| 64 | /// Boots the application without softdevice mechanisms | 66 | /// Boots the application without softdevice mechanisms |
| 65 | pub fn prepare<F: NorFlash + ReadNorFlash>(&mut self, flash: &mut F) -> usize { | 67 | pub fn prepare<F: FlashProvider>(&mut self, flash: &mut F) -> usize { |
| 66 | match self.boot.prepare_boot(flash) { | 68 | match self.boot.prepare_boot(flash) { |
| 67 | Ok(_) => self.boot.boot_address(), | 69 | Ok(_) => self.boot.boot_address(), |
| 68 | Err(_) => panic!("boot prepare error!"), | 70 | Err(_) => panic!("boot prepare error!"), |
diff --git a/embassy-boot/nrf/src/main.rs b/embassy-boot/nrf/src/main.rs index cd264d4c2..63de7c869 100644 --- a/embassy-boot/nrf/src/main.rs +++ b/embassy-boot/nrf/src/main.rs | |||
| @@ -22,7 +22,11 @@ fn main() -> ! { | |||
| 22 | */ | 22 | */ |
| 23 | 23 | ||
| 24 | let mut bl = BootLoader::default(); | 24 | let mut bl = BootLoader::default(); |
| 25 | let start = bl.prepare(&mut WatchdogFlash::start(Nvmc::new(p.NVMC), p.WDT, 5)); | 25 | let start = bl.prepare(&mut SingleFlashProvider::new(&mut WatchdogFlash::start( |
| 26 | Nvmc::new(p.NVMC), | ||
| 27 | p.WDT, | ||
| 28 | 5, | ||
| 29 | ))); | ||
| 26 | unsafe { bl.load(start) } | 30 | unsafe { bl.load(start) } |
| 27 | } | 31 | } |
| 28 | 32 | ||
