aboutsummaryrefslogtreecommitdiff
path: root/embassy-boot/nrf/src
diff options
context:
space:
mode:
authorUlf Lilleengen <[email protected]>2022-04-28 10:38:25 +0200
committerUlf Lilleengen <[email protected]>2022-04-28 10:38:25 +0200
commitbd237a1f96680f2cdf411ef2ca80beaa6b09cc6a (patch)
tree0eb34a0258b7b99a0988b3bfa1729b1aa448396e /embassy-boot/nrf/src
parentba46df6825f35e0c3beb90f28b61f3dbe46e005e (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')
-rw-r--r--embassy-boot/nrf/src/lib.rs14
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
5mod fmt; 7mod fmt;
6 8
7pub use embassy_boot::{FirmwareUpdater, FlashProvider, Partition, SingleFlashProvider}; 9pub use embassy_boot::{
10 FirmwareUpdater, FlashConfig, FlashProvider, Partition, SingleFlashProvider,
11};
8use embassy_nrf::{ 12use 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::{
13use embedded_storage::nor_flash::{ErrorType, NorFlash, ReadNorFlash}; 17use embedded_storage::nor_flash::{ErrorType, NorFlash, ReadNorFlash};
14 18
15pub struct BootLoader { 19pub struct BootLoader {
16 boot: embassy_boot::BootLoader<PAGE_SIZE, 4, 0xFF>, 20 boot: embassy_boot::BootLoader<PAGE_SIZE>,
17} 21}
18 22
19impl BootLoader { 23impl 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!"),