diff options
| author | Ulf Lilleengen <[email protected]> | 2022-04-28 10:38:25 +0200 |
|---|---|---|
| committer | Ulf Lilleengen <[email protected]> | 2022-04-28 10:38:25 +0200 |
| commit | bd237a1f96680f2cdf411ef2ca80beaa6b09cc6a (patch) | |
| tree | 0eb34a0258b7b99a0988b3bfa1729b1aa448396e /embassy-boot/nrf/src/lib.rs | |
| parent | ba46df6825f35e0c3beb90f28b61f3dbe46e005e (diff) | |
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
Diffstat (limited to 'embassy-boot/nrf/src/lib.rs')
| -rw-r--r-- | embassy-boot/nrf/src/lib.rs | 14 |
1 files changed, 11 insertions, 3 deletions
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 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![feature(generic_associated_types)] | 2 | #![feature(generic_associated_types)] |
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | #![allow(incomplete_features)] | ||
| 5 | #![feature(generic_const_exprs)] | ||
| 4 | 6 | ||
| 5 | mod fmt; | 7 | mod fmt; |
| 6 | 8 | ||
| 7 | pub use embassy_boot::{FirmwareUpdater, FlashProvider, Partition, SingleFlashProvider}; | 9 | pub use embassy_boot::{ |
| 10 | FirmwareUpdater, FlashConfig, FlashProvider, Partition, SingleFlashProvider, | ||
| 11 | }; | ||
| 8 | use embassy_nrf::{ | 12 | use embassy_nrf::{ |
| 9 | nvmc::{Nvmc, PAGE_SIZE}, | 13 | nvmc::{Nvmc, PAGE_SIZE}, |
| 10 | peripherals::WDT, | 14 | peripherals::WDT, |
| @@ -13,7 +17,7 @@ use embassy_nrf::{ | |||
| 13 | use embedded_storage::nor_flash::{ErrorType, NorFlash, ReadNorFlash}; | 17 | use embedded_storage::nor_flash::{ErrorType, NorFlash, ReadNorFlash}; |
| 14 | 18 | ||
| 15 | pub struct BootLoader { | 19 | pub struct BootLoader { |
| 16 | boot: embassy_boot::BootLoader<PAGE_SIZE, 4, 0xFF>, | 20 | boot: embassy_boot::BootLoader<PAGE_SIZE>, |
| 17 | } | 21 | } |
| 18 | 22 | ||
| 19 | impl BootLoader { | 23 | impl BootLoader { |
| @@ -62,7 +66,11 @@ impl BootLoader { | |||
| 62 | } | 66 | } |
| 63 | 67 | ||
| 64 | /// Boots the application without softdevice mechanisms | 68 | /// Boots the application without softdevice mechanisms |
| 65 | pub fn prepare<F: FlashProvider>(&mut self, flash: &mut F) -> usize { | 69 | pub fn prepare<F: FlashProvider>(&mut self, flash: &mut F) -> usize |
| 70 | where | ||
| 71 | [(); <<F as FlashProvider>::STATE as FlashConfig>::FLASH::WRITE_SIZE]:, | ||
| 72 | [(); <<F as FlashProvider>::ACTIVE as FlashConfig>::FLASH::ERASE_SIZE]:, | ||
| 73 | { | ||
| 66 | match self.boot.prepare_boot(flash) { | 74 | match self.boot.prepare_boot(flash) { |
| 67 | Ok(_) => self.boot.boot_address(), | 75 | Ok(_) => self.boot.boot_address(), |
| 68 | Err(_) => panic!("boot prepare error!"), | 76 | Err(_) => panic!("boot prepare error!"), |
