aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlf Lilleengen <[email protected]>2025-12-08 11:21:55 +0000
committerGitHub <[email protected]>2025-12-08 11:21:55 +0000
commit2a738c147111569e4f0968020eec6fb5d5d4e754 (patch)
treedd7ac06e9b35d0b16da5b8fc0998d9ad66c5ed8f
parentb9e467bdfe44e51a8b633040d9fe9cd43c581d36 (diff)
parent427c6a495d5d3a9b76da7f1673a85f45ad6e1227 (diff)
Merge pull request #5005 from embassy-rs/nrf54-bootloader
Add nrf54 embassy boot example
-rwxr-xr-x.github/ci/build-nightly.sh2
-rwxr-xr-x.github/ci/build-xtensa.sh2
-rwxr-xr-x.github/ci/build.sh2
-rwxr-xr-x.github/ci/doc.sh2
-rwxr-xr-x.github/ci/janitor.sh2
-rw-r--r--examples/boot/application/nrf/Cargo.toml14
-rw-r--r--examples/boot/application/nrf/README.md2
-rw-r--r--examples/boot/application/nrf/src/bin/a.rs25
-rw-r--r--examples/boot/application/nrf/src/bin/b.rs4
-rw-r--r--examples/boot/bootloader/nrf/Cargo.toml4
-rw-r--r--examples/boot/bootloader/nrf/src/main.rs3
11 files changed, 46 insertions, 16 deletions
diff --git a/.github/ci/build-nightly.sh b/.github/ci/build-nightly.sh
index 82e9436f3..04fbd2353 100755
--- a/.github/ci/build-nightly.sh
+++ b/.github/ci/build-nightly.sh
@@ -23,7 +23,7 @@ fi
23hashtime restore /ci/cache/filetime.json || true 23hashtime restore /ci/cache/filetime.json || true
24hashtime save /ci/cache/filetime.json 24hashtime save /ci/cache/filetime.json
25 25
26cargo install --git https://github.com/embassy-rs/cargo-embassy-devtool --locked --rev d015fd5e972a3e550ebef0da6748099b88a93ba6 26cargo install --git https://github.com/embassy-rs/cargo-embassy-devtool --locked --rev c60400e213f7eb0296581183140ec147dd7a848b
27 27
28./ci-nightly.sh 28./ci-nightly.sh
29 29
diff --git a/.github/ci/build-xtensa.sh b/.github/ci/build-xtensa.sh
index 3f74b4a5a..f07816861 100755
--- a/.github/ci/build-xtensa.sh
+++ b/.github/ci/build-xtensa.sh
@@ -25,7 +25,7 @@ fi
25hashtime restore /ci/cache/filetime.json || true 25hashtime restore /ci/cache/filetime.json || true
26hashtime save /ci/cache/filetime.json 26hashtime save /ci/cache/filetime.json
27 27
28cargo install --git https://github.com/embassy-rs/cargo-embassy-devtool --locked --rev d015fd5e972a3e550ebef0da6748099b88a93ba6 28cargo install --git https://github.com/embassy-rs/cargo-embassy-devtool --locked --rev c60400e213f7eb0296581183140ec147dd7a848b
29 29
30./ci-xtensa.sh 30./ci-xtensa.sh
31 31
diff --git a/.github/ci/build.sh b/.github/ci/build.sh
index 3c196f72b..cd3006c49 100755
--- a/.github/ci/build.sh
+++ b/.github/ci/build.sh
@@ -28,7 +28,7 @@ fi
28hashtime restore /ci/cache/filetime.json || true 28hashtime restore /ci/cache/filetime.json || true
29hashtime save /ci/cache/filetime.json 29hashtime save /ci/cache/filetime.json
30 30
31cargo install --git https://github.com/embassy-rs/cargo-embassy-devtool --locked --rev d015fd5e972a3e550ebef0da6748099b88a93ba6 31cargo install --git https://github.com/embassy-rs/cargo-embassy-devtool --locked --rev c60400e213f7eb0296581183140ec147dd7a848b
32 32
33./ci.sh 33./ci.sh
34 34
diff --git a/.github/ci/doc.sh b/.github/ci/doc.sh
index 535fc5262..5a0032d9d 100755
--- a/.github/ci/doc.sh
+++ b/.github/ci/doc.sh
@@ -12,7 +12,7 @@ export CARGO_TARGET_DIR=/ci/cache/target
12export PATH=$CARGO_HOME/bin:$PATH 12export PATH=$CARGO_HOME/bin:$PATH
13mv rust-toolchain-nightly.toml rust-toolchain.toml 13mv rust-toolchain-nightly.toml rust-toolchain.toml
14 14
15cargo install --git https://github.com/embassy-rs/cargo-embassy-devtool --locked --rev d015fd5e972a3e550ebef0da6748099b88a93ba6 15cargo install --git https://github.com/embassy-rs/cargo-embassy-devtool --locked --rev c60400e213f7eb0296581183140ec147dd7a848b
16 16
17cargo embassy-devtool doc -o webroot 17cargo embassy-devtool doc -o webroot
18 18
diff --git a/.github/ci/janitor.sh b/.github/ci/janitor.sh
index bc43075bd..9679308f2 100755
--- a/.github/ci/janitor.sh
+++ b/.github/ci/janitor.sh
@@ -9,7 +9,7 @@ export CARGO_HOME=/ci/cache/cargo
9export CARGO_TARGET_DIR=/ci/cache/target 9export CARGO_TARGET_DIR=/ci/cache/target
10export PATH=$CARGO_HOME/bin:$PATH 10export PATH=$CARGO_HOME/bin:$PATH
11 11
12cargo install --git https://github.com/embassy-rs/cargo-embassy-devtool --locked --rev d015fd5e972a3e550ebef0da6748099b88a93ba6 12cargo install --git https://github.com/embassy-rs/cargo-embassy-devtool --locked --rev c60400e213f7eb0296581183140ec147dd7a848b
13 13
14cargo embassy-devtool check-crlf 14cargo embassy-devtool check-crlf
15cargo embassy-devtool check-manifest 15cargo embassy-devtool check-manifest
diff --git a/examples/boot/application/nrf/Cargo.toml b/examples/boot/application/nrf/Cargo.toml
index 55053bc33..79286e295 100644
--- a/examples/boot/application/nrf/Cargo.toml
+++ b/examples/boot/application/nrf/Cargo.toml
@@ -9,7 +9,7 @@ publish = false
9embassy-sync = { version = "0.7.2", path = "../../../../embassy-sync" } 9embassy-sync = { version = "0.7.2", path = "../../../../embassy-sync" }
10embassy-executor = { version = "0.9.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "arch-cortex-m", "executor-thread"] } 10embassy-executor = { version = "0.9.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "arch-cortex-m", "executor-thread"] }
11embassy-time = { version = "0.5.0", path = "../../../../embassy-time", features = [] } 11embassy-time = { version = "0.5.0", path = "../../../../embassy-time", features = [] }
12embassy-nrf = { version = "0.8.0", path = "../../../../embassy-nrf", features = ["time-driver-rtc1", "gpiote", ] } 12embassy-nrf = { version = "0.8.0", path = "../../../../embassy-nrf", features = ["gpiote", ] }
13embassy-boot = { version = "0.6.1", path = "../../../../embassy-boot", features = [] } 13embassy-boot = { version = "0.6.1", path = "../../../../embassy-boot", features = [] }
14embassy-boot-nrf = { version = "0.9.0", path = "../../../../embassy-boot-nrf", features = [] } 14embassy-boot-nrf = { version = "0.9.0", path = "../../../../embassy-boot-nrf", features = [] }
15embassy-embedded-hal = { version = "0.5.0", path = "../../../../embassy-embedded-hal" } 15embassy-embedded-hal = { version = "0.5.0", path = "../../../../embassy-embedded-hal" }
@@ -33,12 +33,14 @@ defmt = [
33 "embassy-boot-nrf/defmt", 33 "embassy-boot-nrf/defmt",
34 "embassy-sync/defmt", 34 "embassy-sync/defmt",
35] 35]
36nrf54 = ["embassy-nrf/time-driver-grtc"]
36 37
37[package.metadata.embassy] 38[package.metadata.embassy]
38build = [ 39build = [
39 { target = "thumbv7em-none-eabi", features = ["embassy-nrf/nrf52840", "skip-include"], artifact-dir = "out/examples/boot/nrf52840" }, 40 { target = "thumbv7em-none-eabi", features = ["embassy-nrf/nrf52840", "embassy-nrf/time-driver-rtc1", "skip-include"], artifact-dir = "out/examples/boot/nrf52840" },
40 { target = "thumbv8m.main-none-eabihf", features = ["embassy-nrf/nrf9160-ns", "skip-include"], artifact-dir = "out/examples/boot/nrf9160" }, 41 { target = "thumbv8m.main-none-eabihf", features = ["embassy-nrf/nrf9160-ns", "embassy-nrf/time-driver-rtc1", "skip-include"], artifact-dir = "out/examples/boot/nrf9160" },
41 { target = "thumbv8m.main-none-eabihf", features = ["embassy-nrf/nrf9120-ns", "skip-include"], artifact-dir = "out/examples/boot/nrf9120" }, 42 { target = "thumbv8m.main-none-eabihf", features = ["embassy-nrf/nrf9120-ns", "embassy-nrf/time-driver-rtc1", "skip-include"], artifact-dir = "out/examples/boot/nrf9120" },
42 { target = "thumbv8m.main-none-eabihf", features = ["embassy-nrf/nrf9151-ns", "skip-include"], artifact-dir = "out/examples/boot/nrf9151" }, 43 { target = "thumbv8m.main-none-eabihf", features = ["embassy-nrf/nrf9151-ns", "embassy-nrf/time-driver-rtc1", "skip-include"], artifact-dir = "out/examples/boot/nrf9151" },
43 { target = "thumbv8m.main-none-eabihf", features = ["embassy-nrf/nrf9161-ns", "skip-include"], artifact-dir = "out/examples/boot/nrf9161" } 44 { target = "thumbv8m.main-none-eabihf", features = ["embassy-nrf/nrf9161-ns", "embassy-nrf/time-driver-rtc1", "skip-include"], artifact-dir = "out/examples/boot/nrf9161" },
45 { target = "thumbv8m.main-none-eabihf", features = ["embassy-nrf/nrf54l15-app-s", "nrf54", "skip-include"], artifact-dir = "out/examples/boot/nrf54l15" }
44] 46]
diff --git a/examples/boot/application/nrf/README.md b/examples/boot/application/nrf/README.md
index 9d6d20336..c92ccb358 100644
--- a/examples/boot/application/nrf/README.md
+++ b/examples/boot/application/nrf/README.md
@@ -22,7 +22,7 @@ cp memory-bl.x ../../bootloader/nrf/memory.x
22# Flash bootloader 22# Flash bootloader
23cargo flash --manifest-path ../../bootloader/nrf/Cargo.toml --features embassy-nrf/nrf52840 --target thumbv7em-none-eabi --release --chip nRF52840_xxAA 23cargo flash --manifest-path ../../bootloader/nrf/Cargo.toml --features embassy-nrf/nrf52840 --target thumbv7em-none-eabi --release --chip nRF52840_xxAA
24# Build 'b' 24# Build 'b'
25cargo build --release --bin b --features embassy-nrf/nrf52840 25cargo build --release --bin b --features embassy-nrf/nrf52840,time-driver-rtc1
26# Generate binary for 'b' 26# Generate binary for 'b'
27cargo objcopy --release --bin b --features embassy-nrf/nrf52840 --target thumbv7em-none-eabi -- -O binary b.bin 27cargo objcopy --release --bin b --features embassy-nrf/nrf52840 --target thumbv7em-none-eabi -- -O binary b.bin
28``` 28```
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");
23async fn main(_spawner: Spawner) { 23async 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 {
diff --git a/examples/boot/application/nrf/src/bin/b.rs b/examples/boot/application/nrf/src/bin/b.rs
index de97b6a22..6718df5a1 100644
--- a/examples/boot/application/nrf/src/bin/b.rs
+++ b/examples/boot/application/nrf/src/bin/b.rs
@@ -10,11 +10,15 @@ use panic_reset as _;
10#[embassy_executor::main] 10#[embassy_executor::main]
11async fn main(_spawner: Spawner) { 11async fn main(_spawner: Spawner) {
12 let p = embassy_nrf::init(Default::default()); 12 let p = embassy_nrf::init(Default::default());
13 #[cfg(not(feature = "nrf54"))]
13 let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard); 14 let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard);
14 // let mut led = Output::new(p.P1_10, Level::Low, OutputDrive::Standard); 15 // let mut led = Output::new(p.P1_10, Level::Low, OutputDrive::Standard);
15 16
16 // nRF91 DK 17 // nRF91 DK
17 // let mut led = Output::new(p.P0_02, Level::Low, OutputDrive::Standard); 18 // let mut led = Output::new(p.P0_02, Level::Low, OutputDrive::Standard);
19 // nrf54l15 dk
20 #[cfg(feature = "nrf54")]
21 let mut led = Output::new(p.P1_10, Level::Low, OutputDrive::Standard);
18 22
19 loop { 23 loop {
20 led.set_high(); 24 led.set_high();
diff --git a/examples/boot/bootloader/nrf/Cargo.toml b/examples/boot/bootloader/nrf/Cargo.toml
index 1fea2b7d7..59fc6e4ed 100644
--- a/examples/boot/bootloader/nrf/Cargo.toml
+++ b/examples/boot/bootloader/nrf/Cargo.toml
@@ -27,6 +27,7 @@ defmt = [
27softdevice = [ 27softdevice = [
28 "embassy-boot-nrf/softdevice", 28 "embassy-boot-nrf/softdevice",
29] 29]
30nrf54 = []
30 31
31[profile.dev] 32[profile.dev]
32debug = 2 33debug = 2
@@ -65,5 +66,6 @@ build = [
65 { target = "thumbv8m.main-none-eabihf", features = ["embassy-nrf/nrf9160-ns"] }, 66 { target = "thumbv8m.main-none-eabihf", features = ["embassy-nrf/nrf9160-ns"] },
66 { target = "thumbv8m.main-none-eabihf", features = ["embassy-nrf/nrf9120-ns"] }, 67 { target = "thumbv8m.main-none-eabihf", features = ["embassy-nrf/nrf9120-ns"] },
67 { target = "thumbv8m.main-none-eabihf", features = ["embassy-nrf/nrf9151-ns"] }, 68 { target = "thumbv8m.main-none-eabihf", features = ["embassy-nrf/nrf9151-ns"] },
68 { target = "thumbv8m.main-none-eabihf", features = ["embassy-nrf/nrf9161-ns"] } 69 { target = "thumbv8m.main-none-eabihf", features = ["embassy-nrf/nrf9161-ns"] },
70 { target = "thumbv8m.main-none-eabihf", features = ["embassy-nrf/nrf54l15-app-s", "nrf54"] }
69] 71]
diff --git a/examples/boot/bootloader/nrf/src/main.rs b/examples/boot/bootloader/nrf/src/main.rs
index 76c4c1048..9ba57e81b 100644
--- a/examples/boot/bootloader/nrf/src/main.rs
+++ b/examples/boot/bootloader/nrf/src/main.rs
@@ -28,7 +28,10 @@ fn main() -> ! {
28 wdt_config.action_during_sleep = SleepConfig::RUN; 28 wdt_config.action_during_sleep = SleepConfig::RUN;
29 wdt_config.action_during_debug_halt = HaltConfig::PAUSE; 29 wdt_config.action_during_debug_halt = HaltConfig::PAUSE;
30 30
31 #[cfg(not(feature = "nrf54"))]
31 let flash = WatchdogFlash::start(Nvmc::new(p.NVMC), p.WDT, wdt_config); 32 let flash = WatchdogFlash::start(Nvmc::new(p.NVMC), p.WDT, wdt_config);
33 #[cfg(feature = "nrf54")]
34 let flash = WatchdogFlash::start(Nvmc::new(p.RRAMC), p.WDT0, wdt_config);
32 let flash = Mutex::new(RefCell::new(flash)); 35 let flash = Mutex::new(RefCell::new(flash));
33 36
34 let config = BootLoaderConfig::from_linkerfile_blocking(&flash, &flash, &flash); 37 let config = BootLoaderConfig::from_linkerfile_blocking(&flash, &flash, &flash);