diff options
| author | Dario Nieuwenhuis <[email protected]> | 2023-05-30 20:08:01 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-05-30 20:08:01 +0000 |
| commit | f5d0d28ac3cfcb74eaa59bbe984b7969a0743724 (patch) | |
| tree | 9b156e69b39cd79f4b977dbd59f6ae1d5cbfc902 /examples/boot/bootloader/nrf/src | |
| parent | 05688934a131b023e147e7c4c24afd1d7b01582a (diff) | |
| parent | c22d2b5b5bbc5e3c7d3a039e90b50d39809a10f2 (diff) | |
Merge pull request #1498 from rmja/remove-bootloader-partitions
Remove bootloader partitions
Diffstat (limited to 'examples/boot/bootloader/nrf/src')
| -rw-r--r-- | examples/boot/bootloader/nrf/src/main.rs | 21 |
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 | ||
| 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; |
| 9 | use embassy_nrf::wdt; | 11 | use embassy_nrf::wdt; |
| 12 | use embassy_sync::blocking_mutex::Mutex; | ||
| 10 | 13 | ||
| 11 | #[entry] | 14 | #[entry] |
| 12 | fn main() -> ! { | 15 | fn 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] |
