diff options
Diffstat (limited to 'examples/boot/bootloader/nrf/src')
| -rw-r--r-- | examples/boot/bootloader/nrf/src/main.rs | 26 |
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 | ||
| 4 | use core::cell::RefCell; | ||
| 5 | |||
| 4 | use cortex_m_rt::{entry, exception}; | 6 | use cortex_m_rt::{entry, exception}; |
| 5 | #[cfg(feature = "defmt")] | 7 | #[cfg(feature = "defmt")] |
| 6 | use defmt_rtt as _; | 8 | use defmt_rtt as _; |
| 7 | use embassy_boot_nrf::*; | 9 | use embassy_boot_nrf::*; |
| 8 | use embassy_nrf::nvmc::Nvmc; | 10 | use embassy_nrf::nvmc::Nvmc; |
| 11 | use embassy_nrf::wdt; | ||
| 12 | use embassy_sync::blocking_mutex::Mutex; | ||
| 9 | 13 | ||
| 10 | #[entry] | 14 | #[entry] |
| 11 | fn main() -> ! { | 15 | fn 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] |
