diff options
Diffstat (limited to 'examples/boot/application/nrf/src/bin/a.rs')
| -rw-r--r-- | examples/boot/application/nrf/src/bin/a.rs | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/examples/boot/application/nrf/src/bin/a.rs b/examples/boot/application/nrf/src/bin/a.rs index 2c1d1a7bb..035ffe214 100644 --- a/examples/boot/application/nrf/src/bin/a.rs +++ b/examples/boot/application/nrf/src/bin/a.rs | |||
| @@ -23,10 +23,21 @@ static APP_B: &[u8] = include_bytes!("../../b.bin"); | |||
| 23 | async fn main(_spawner: Spawner) { | 23 | async fn main(_spawner: Spawner) { |
| 24 | let p = embassy_nrf::init(Default::default()); | 24 | let p = embassy_nrf::init(Default::default()); |
| 25 | 25 | ||
| 26 | #[cfg(not(feature = "nrf54"))] | ||
| 26 | let mut button = Input::new(p.P0_11, Pull::Up); | 27 | let mut button = Input::new(p.P0_11, Pull::Up); |
| 28 | #[cfg(not(feature = "nrf54"))] | ||
| 27 | let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard); | 29 | let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard); |
| 30 | #[cfg(not(feature = "nrf54"))] | ||
| 28 | let mut led_reverted = Output::new(p.P0_14, Level::High, OutputDrive::Standard); | 31 | let mut led_reverted = Output::new(p.P0_14, Level::High, OutputDrive::Standard); |
| 29 | 32 | ||
| 33 | // nRF54 DK | ||
| 34 | #[cfg(feature = "nrf54")] | ||
| 35 | let mut button = Input::new(p.P1_13, Pull::Up); | ||
| 36 | #[cfg(feature = "nrf54")] | ||
| 37 | let mut led = Output::new(p.P1_14, Level::Low, OutputDrive::Standard); | ||
| 38 | #[cfg(feature = "nrf54")] | ||
| 39 | let mut led_reverted = Output::new(p.P2_09, Level::High, OutputDrive::Standard); | ||
| 40 | |||
| 30 | //let mut led = Output::new(p.P1_10, Level::Low, OutputDrive::Standard); | 41 | //let mut led = Output::new(p.P1_10, Level::Low, OutputDrive::Standard); |
| 31 | //let mut button = Input::new(p.P1_02, Pull::Up); | 42 | //let mut button = Input::new(p.P1_02, Pull::Up); |
| 32 | 43 | ||
| @@ -40,8 +51,12 @@ async fn main(_spawner: Spawner) { | |||
| 40 | // the watchdog will cause the device to reset as per its configured timeout in the bootloader. | 51 | // the watchdog will cause the device to reset as per its configured timeout in the bootloader. |
| 41 | // This helps is avoid a situation where new firmware might be bad and block our executor. | 52 | // This helps is avoid a situation where new firmware might be bad and block our executor. |
| 42 | // If firmware is bad in this way then the bootloader will revert to any previous version. | 53 | // If firmware is bad in this way then the bootloader will revert to any previous version. |
| 43 | let wdt_config = wdt::Config::try_new(&p.WDT).unwrap(); | 54 | #[cfg(feature = "nrf54")] |
| 44 | let (_wdt, [_wdt_handle]) = match Watchdog::try_new(p.WDT, wdt_config) { | 55 | let wdt = p.WDT0; |
| 56 | #[cfg(not(feature = "nrf54"))] | ||
| 57 | let wdt = p.WDT; | ||
| 58 | let wdt_config = wdt::Config::try_new(&wdt).unwrap(); | ||
| 59 | let (_wdt, [_wdt_handle]) = match Watchdog::try_new(wdt, wdt_config) { | ||
| 45 | Ok(x) => x, | 60 | Ok(x) => x, |
| 46 | Err(_) => { | 61 | Err(_) => { |
| 47 | // Watchdog already active with the wrong number of handles, waiting for it to timeout... | 62 | // Watchdog already active with the wrong number of handles, waiting for it to timeout... |
| @@ -51,11 +66,15 @@ async fn main(_spawner: Spawner) { | |||
| 51 | } | 66 | } |
| 52 | }; | 67 | }; |
| 53 | 68 | ||
| 69 | // RRAMC for nRF54 | ||
| 70 | #[cfg(feature = "nrf54")] | ||
| 71 | let nvmc = Nvmc::new(p.RRAMC); | ||
| 72 | #[cfg(not(feature = "nrf54"))] | ||
| 54 | let nvmc = Nvmc::new(p.NVMC); | 73 | let nvmc = Nvmc::new(p.NVMC); |
| 55 | let nvmc = Mutex::new(BlockingAsync::new(nvmc)); | 74 | let nvmc = Mutex::new(BlockingAsync::new(nvmc)); |
| 56 | 75 | ||
| 57 | let config = FirmwareUpdaterConfig::from_linkerfile(&nvmc, &nvmc); | 76 | let config = FirmwareUpdaterConfig::from_linkerfile(&nvmc, &nvmc); |
| 58 | let mut magic = [0; 4]; | 77 | let mut magic = [0; 16]; |
| 59 | let mut updater = FirmwareUpdater::new(config, &mut magic); | 78 | let mut updater = FirmwareUpdater::new(config, &mut magic); |
| 60 | let state = updater.get_state().await.unwrap(); | 79 | let state = updater.get_state().await.unwrap(); |
| 61 | if state == State::Revert { | 80 | if state == State::Revert { |
