aboutsummaryrefslogtreecommitdiff
path: root/embassy-boot/nrf
diff options
context:
space:
mode:
authorUlf Lilleengen <[email protected]>2022-04-19 14:42:38 +0200
committerUlf Lilleengen <[email protected]>2022-04-19 20:07:06 +0200
commit2afff617f652d0fdcfa9ffcfd49062e3d2c996a3 (patch)
treebc531122365086cd24a12a9331c94f9f042cad3a /embassy-boot/nrf
parente2ed41b3832db17633ae8ae1ee9391639c3a9229 (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')
-rw-r--r--embassy-boot/nrf/.cargo/config.toml1
-rw-r--r--embassy-boot/nrf/Cargo.toml2
-rw-r--r--embassy-boot/nrf/src/lib.rs6
-rw-r--r--embassy-boot/nrf/src/main.rs6
4 files changed, 10 insertions, 5 deletions
diff --git a/embassy-boot/nrf/.cargo/config.toml b/embassy-boot/nrf/.cargo/config.toml
index c3957b866..27bc9708c 100644
--- a/embassy-boot/nrf/.cargo/config.toml
+++ b/embassy-boot/nrf/.cargo/config.toml
@@ -1,5 +1,4 @@
1[unstable] 1[unstable]
2namespaced-features = true
3build-std = ["core"] 2build-std = ["core"]
4build-std-features = ["panic_immediate_abort"] 3build-std-features = ["panic_immediate_abort"]
5 4
diff --git a/embassy-boot/nrf/Cargo.toml b/embassy-boot/nrf/Cargo.toml
index 512e7d378..97207ac29 100644
--- a/embassy-boot/nrf/Cargo.toml
+++ b/embassy-boot/nrf/Cargo.toml
@@ -12,7 +12,7 @@ defmt = { version = "0.3", optional = true }
12defmt-rtt = { version = "0.3", optional = true } 12defmt-rtt = { version = "0.3", optional = true }
13 13
14embassy = { path = "../../embassy", default-features = false } 14embassy = { path = "../../embassy", default-features = false }
15embassy-nrf = { path = "../../embassy-nrf", default-features = false } 15embassy-nrf = { path = "../../embassy-nrf", default-features = false, features = ["nightly"] }
16embassy-boot = { path = "../boot", default-features = false } 16embassy-boot = { path = "../boot", default-features = false }
17cortex-m = { version = "0.7" } 17cortex-m = { version = "0.7" }
18cortex-m-rt = { version = "0.7" } 18cortex-m-rt = { version = "0.7" }
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
5mod fmt; 5mod fmt;
6 6
7pub use embassy_boot::{FirmwareUpdater, Partition, State, BOOT_MAGIC}; 7pub use embassy_boot::{
8 FirmwareUpdater, FlashProvider, Partition, SingleFlashProvider, State, BOOT_MAGIC,
9};
8use embassy_nrf::{ 10use 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