aboutsummaryrefslogtreecommitdiff
path: root/examples/boot/bootloader/nrf/src
diff options
context:
space:
mode:
authorQuentin Smith <[email protected]>2023-07-17 21:31:43 -0400
committerQuentin Smith <[email protected]>2023-07-17 21:31:43 -0400
commit6f02403184eb7fb7990fb88fc9df9c4328a690a3 (patch)
tree748f510e190bb2724750507a6e69ed1a8e08cb20 /examples/boot/bootloader/nrf/src
parentd896f80405aa8963877049ed999e4aba25d6e2bb (diff)
parent6b5df4523aa1c4902f02e803450ae4b418e0e3ca (diff)
Merge remote-tracking branch 'origin/main' into nrf-pdm
Diffstat (limited to 'examples/boot/bootloader/nrf/src')
-rw-r--r--examples/boot/bootloader/nrf/src/main.rs26
1 files changed, 19 insertions, 7 deletions
diff --git a/examples/boot/bootloader/nrf/src/main.rs b/examples/boot/bootloader/nrf/src/main.rs
index bc7e0755f..72c95c02a 100644
--- a/examples/boot/bootloader/nrf/src/main.rs
+++ b/examples/boot/bootloader/nrf/src/main.rs
@@ -1,11 +1,15 @@
1#![no_std] 1#![no_std]
2#![no_main] 2#![no_main]
3 3
4use core::cell::RefCell;
5
4use cortex_m_rt::{entry, exception}; 6use cortex_m_rt::{entry, exception};
5#[cfg(feature = "defmt")] 7#[cfg(feature = "defmt")]
6use defmt_rtt as _; 8use defmt_rtt as _;
7use embassy_boot_nrf::*; 9use embassy_boot_nrf::*;
8use embassy_nrf::nvmc::Nvmc; 10use embassy_nrf::nvmc::Nvmc;
11use embassy_nrf::wdt;
12use embassy_sync::blocking_mutex::Mutex;
9 13
10#[entry] 14#[entry]
11fn main() -> ! { 15fn main() -> ! {
@@ -19,13 +23,21 @@ fn main() -> ! {
19 } 23 }
20 */ 24 */
21 25
22 let mut bl = BootLoader::default(); 26 let mut wdt_config = wdt::Config::default();
23 let start = bl.prepare(&mut SingleFlashProvider::new(&mut WatchdogFlash::start( 27 wdt_config.timeout_ticks = 32768 * 5; // timeout seconds
24 Nvmc::new(p.NVMC), 28 wdt_config.run_during_sleep = true;
25 p.WDT, 29 wdt_config.run_during_debug_halt = false;
26 5, 30
27 ))); 31 let flash = WatchdogFlash::start(Nvmc::new(p.NVMC), p.WDT, wdt_config);
28 unsafe { bl.load(start) } 32 let flash = Mutex::new(RefCell::new(flash));
33
34 let config = BootLoaderConfig::from_linkerfile_blocking(&flash);
35 let active_offset = config.active.offset();
36 let mut bl: BootLoader<_, _, _> = BootLoader::new(config);
37
38 bl.prepare();
39
40 unsafe { bl.load(active_offset) }
29} 41}
30 42
31#[no_mangle] 43#[no_mangle]