aboutsummaryrefslogtreecommitdiff
path: root/examples/boot/bootloader/nrf/src/main.rs
diff options
context:
space:
mode:
authorRasmus Melchior Jacobsen <[email protected]>2023-05-30 14:03:31 +0200
committerRasmus Melchior Jacobsen <[email protected]>2023-05-30 14:03:31 +0200
commit36e00caf4dc70905b735531c0d5634addd026954 (patch)
tree01d3bbb3b7f1ab522f9a1fc651f48197ce355927 /examples/boot/bootloader/nrf/src/main.rs
parentc2aca45b8d3785007da20ce007d6a6e352fac1a0 (diff)
Align examples
Diffstat (limited to 'examples/boot/bootloader/nrf/src/main.rs')
-rw-r--r--examples/boot/bootloader/nrf/src/main.rs21
1 files changed, 13 insertions, 8 deletions
diff --git a/examples/boot/bootloader/nrf/src/main.rs b/examples/boot/bootloader/nrf/src/main.rs
index 8818a23b8..72c95c02a 100644
--- a/examples/boot/bootloader/nrf/src/main.rs
+++ b/examples/boot/bootloader/nrf/src/main.rs
@@ -1,12 +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;
9use embassy_nrf::wdt; 11use embassy_nrf::wdt;
12use embassy_sync::blocking_mutex::Mutex;
10 13
11#[entry] 14#[entry]
12fn main() -> ! { 15fn main() -> ! {
@@ -20,19 +23,21 @@ fn main() -> ! {
20 } 23 }
21 */ 24 */
22 25
23 let mut bl = BootLoader::default();
24
25 let mut wdt_config = wdt::Config::default(); 26 let mut wdt_config = wdt::Config::default();
26 wdt_config.timeout_ticks = 32768 * 5; // timeout seconds 27 wdt_config.timeout_ticks = 32768 * 5; // timeout seconds
27 wdt_config.run_during_sleep = true; 28 wdt_config.run_during_sleep = true;
28 wdt_config.run_during_debug_halt = false; 29 wdt_config.run_during_debug_halt = false;
29 30
30 let start = bl.prepare(&mut SingleFlashConfig::new(&mut BootFlash::new(WatchdogFlash::start( 31 let flash = WatchdogFlash::start(Nvmc::new(p.NVMC), p.WDT, wdt_config);
31 Nvmc::new(p.NVMC), 32 let flash = Mutex::new(RefCell::new(flash));
32 p.WDT, 33
33 wdt_config, 34 let config = BootLoaderConfig::from_linkerfile_blocking(&flash);
34 )))); 35 let active_offset = config.active.offset();
35 unsafe { bl.load(start) } 36 let mut bl: BootLoader<_, _, _> = BootLoader::new(config);
37
38 bl.prepare();
39
40 unsafe { bl.load(active_offset) }
36} 41}
37 42
38#[no_mangle] 43#[no_mangle]