diff options
Diffstat (limited to 'examples/boot')
| -rw-r--r-- | examples/boot/application/nrf/Cargo.toml | 2 | ||||
| -rw-r--r-- | examples/boot/application/nrf/README.md | 10 | ||||
| -rw-r--r-- | examples/boot/application/nrf/memory-bl-nrf91.x | 19 | ||||
| -rw-r--r-- | examples/boot/application/nrf/memory-nrf91.x | 16 | ||||
| -rw-r--r-- | examples/boot/application/nrf/src/bin/a.rs | 6 | ||||
| -rw-r--r-- | examples/boot/application/nrf/src/bin/b.rs | 5 |
6 files changed, 51 insertions, 7 deletions
diff --git a/examples/boot/application/nrf/Cargo.toml b/examples/boot/application/nrf/Cargo.toml index 1e7a5a84b..9679bbc5e 100644 --- a/examples/boot/application/nrf/Cargo.toml +++ b/examples/boot/application/nrf/Cargo.toml | |||
| @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" | |||
| 8 | embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync" } | 8 | embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync" } |
| 9 | embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "integrated-timers"] } | 9 | embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "integrated-timers"] } |
| 10 | embassy-time = { version = "0.1.0", path = "../../../../embassy-time", features = ["nightly"] } | 10 | embassy-time = { version = "0.1.0", path = "../../../../embassy-time", features = ["nightly"] } |
| 11 | embassy-nrf = { version = "0.1.0", path = "../../../../embassy-nrf", features = ["time-driver-rtc1", "gpiote", "nightly", "nrf52840"] } | 11 | embassy-nrf = { version = "0.1.0", path = "../../../../embassy-nrf", features = ["time-driver-rtc1", "gpiote", "nightly"] } |
| 12 | embassy-boot-nrf = { version = "0.1.0", path = "../../../../embassy-boot/nrf" } | 12 | embassy-boot-nrf = { version = "0.1.0", path = "../../../../embassy-boot/nrf" } |
| 13 | embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } | 13 | embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } |
| 14 | 14 | ||
diff --git a/examples/boot/application/nrf/README.md b/examples/boot/application/nrf/README.md index a6719b505..5d45f6290 100644 --- a/examples/boot/application/nrf/README.md +++ b/examples/boot/application/nrf/README.md | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | # Examples using bootloader | 1 | # Examples using bootloader |
| 2 | 2 | ||
| 3 | Example for nRF52 demonstrating the bootloader. The example consists of application binaries, 'a' | 3 | Example for nRF demonstrating the bootloader. The example consists of application binaries, 'a' |
| 4 | which allows you to press a button to start the DFU process, and 'b' which is the updated | 4 | which allows you to press a button to start the DFU process, and 'b' which is the updated |
| 5 | application. | 5 | application. |
| 6 | 6 | ||
| @@ -20,19 +20,19 @@ application. | |||
| 20 | cp memory-bl.x ../../bootloader/nrf/memory.x | 20 | cp memory-bl.x ../../bootloader/nrf/memory.x |
| 21 | 21 | ||
| 22 | # Flash bootloader | 22 | # Flash bootloader |
| 23 | cargo flash --manifest-path ../../bootloader/nrf/Cargo.toml --features embassy-nrf/nrf52840 --release --chip nRF52840_xxAA | 23 | cargo 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' |
| 25 | cargo build --release --bin b | 25 | cargo build --release --bin b |
| 26 | # Generate binary for 'b' | 26 | # Generate binary for 'b' |
| 27 | cargo objcopy --release --bin b -- -O binary b.bin | 27 | cargo objcopy --release --bin b --features embassy-nrf/nrf52840 --target thumbv7em-none-eabi -- -O binary b.bin |
| 28 | ``` | 28 | ``` |
| 29 | 29 | ||
| 30 | # Flash `a` (which includes b.bin) | 30 | # Flash `a` (which includes b.bin) |
| 31 | 31 | ||
| 32 | ``` | 32 | ``` |
| 33 | cargo flash --release --bin a --chip nRF52840_xxAA | 33 | cargo flash --release --bin a --features embassy-nrf/nrf52840 --target thumbv7em-none-eabi --chip nRF52840_xxAA |
| 34 | ``` | 34 | ``` |
| 35 | 35 | ||
| 36 | You should then see a solid LED. Pressing button 1 will cause the DFU to be loaded by the bootloader. Upon | 36 | You should then see a solid LED. Pressing button 1 will cause the DFU to be loaded by the bootloader. Upon |
| 37 | successfully loading, you'll see the LED flash. After 5 seconds, because there is no petting of the watchdog, | 37 | successfully loading, you'll see the LED flash. After 5 seconds, because there is no petting of the watchdog, |
| 38 | you'll see the LED go solid again. This indicates that the bootloader has reverted the update. \ No newline at end of file | 38 | you'll see the LED go solid again. This indicates that the bootloader has reverted the update. |
diff --git a/examples/boot/application/nrf/memory-bl-nrf91.x b/examples/boot/application/nrf/memory-bl-nrf91.x new file mode 100644 index 000000000..14ceffa73 --- /dev/null +++ b/examples/boot/application/nrf/memory-bl-nrf91.x | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | MEMORY | ||
| 2 | { | ||
| 3 | /* NOTE 1 K = 1 KiBi = 1024 bytes */ | ||
| 4 | /* Assumes Secure Partition Manager (SPM) flashed at the start */ | ||
| 5 | FLASH : ORIGIN = 0x00050000, LENGTH = 24K | ||
| 6 | BOOTLOADER_STATE : ORIGIN = 0x00056000, LENGTH = 4K | ||
| 7 | ACTIVE : ORIGIN = 0x00057000, LENGTH = 64K | ||
| 8 | DFU : ORIGIN = 0x00067000, LENGTH = 68K | ||
| 9 | RAM (rwx) : ORIGIN = 0x20018000, LENGTH = 32K | ||
| 10 | } | ||
| 11 | |||
| 12 | __bootloader_state_start = ORIGIN(BOOTLOADER_STATE); | ||
| 13 | __bootloader_state_end = ORIGIN(BOOTLOADER_STATE) + LENGTH(BOOTLOADER_STATE); | ||
| 14 | |||
| 15 | __bootloader_active_start = ORIGIN(ACTIVE); | ||
| 16 | __bootloader_active_end = ORIGIN(ACTIVE) + LENGTH(ACTIVE); | ||
| 17 | |||
| 18 | __bootloader_dfu_start = ORIGIN(DFU); | ||
| 19 | __bootloader_dfu_end = ORIGIN(DFU) + LENGTH(DFU); | ||
diff --git a/examples/boot/application/nrf/memory-nrf91.x b/examples/boot/application/nrf/memory-nrf91.x new file mode 100644 index 000000000..2bc13c0d6 --- /dev/null +++ b/examples/boot/application/nrf/memory-nrf91.x | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | MEMORY | ||
| 2 | { | ||
| 3 | /* NOTE 1 K = 1 KiBi = 1024 bytes */ | ||
| 4 | /* Assumes Secure Partition Manager (SPM) flashed at the start */ | ||
| 5 | BOOTLOADER : ORIGIN = 0x00050000, LENGTH = 24K | ||
| 6 | BOOTLOADER_STATE : ORIGIN = 0x00056000, LENGTH = 4K | ||
| 7 | FLASH : ORIGIN = 0x00057000, LENGTH = 64K | ||
| 8 | DFU : ORIGIN = 0x00067000, LENGTH = 68K | ||
| 9 | RAM (rwx) : ORIGIN = 0x20018000, LENGTH = 32K | ||
| 10 | } | ||
| 11 | |||
| 12 | __bootloader_state_start = ORIGIN(BOOTLOADER_STATE); | ||
| 13 | __bootloader_state_end = ORIGIN(BOOTLOADER_STATE) + LENGTH(BOOTLOADER_STATE); | ||
| 14 | |||
| 15 | __bootloader_dfu_start = ORIGIN(DFU); | ||
| 16 | __bootloader_dfu_end = ORIGIN(DFU) + LENGTH(DFU); | ||
diff --git a/examples/boot/application/nrf/src/bin/a.rs b/examples/boot/application/nrf/src/bin/a.rs index 83191f388..090a05b23 100644 --- a/examples/boot/application/nrf/src/bin/a.rs +++ b/examples/boot/application/nrf/src/bin/a.rs | |||
| @@ -16,11 +16,17 @@ static APP_B: &[u8] = include_bytes!("../../b.bin"); | |||
| 16 | #[embassy_executor::main] | 16 | #[embassy_executor::main] |
| 17 | async fn main(_spawner: Spawner) { | 17 | async fn main(_spawner: Spawner) { |
| 18 | let p = embassy_nrf::init(Default::default()); | 18 | let p = embassy_nrf::init(Default::default()); |
| 19 | |||
| 19 | let mut button = Input::new(p.P0_11, Pull::Up); | 20 | let mut button = Input::new(p.P0_11, Pull::Up); |
| 20 | let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard); | 21 | let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard); |
| 22 | |||
| 21 | //let mut led = Output::new(p.P1_10, Level::Low, OutputDrive::Standard); | 23 | //let mut led = Output::new(p.P1_10, Level::Low, OutputDrive::Standard); |
| 22 | //let mut button = Input::new(p.P1_02, Pull::Up); | 24 | //let mut button = Input::new(p.P1_02, Pull::Up); |
| 23 | 25 | ||
| 26 | // nRF91 DK | ||
| 27 | // let mut led = Output::new(p.P0_02, Level::Low, OutputDrive::Standard); | ||
| 28 | // let mut button = Input::new(p.P0_06, Pull::Up); | ||
| 29 | |||
| 24 | // The following code block illustrates how to obtain a watchdog that is configured | 30 | // The following code block illustrates how to obtain a watchdog that is configured |
| 25 | // as per the existing watchdog. Ordinarily, we'd use the handle returned to "pet" the | 31 | // as per the existing watchdog. Ordinarily, we'd use the handle returned to "pet" the |
| 26 | // watchdog periodically. If we don't, and we're not going to for this example, then | 32 | // watchdog periodically. If we don't, and we're not going to for this example, then |
diff --git a/examples/boot/application/nrf/src/bin/b.rs b/examples/boot/application/nrf/src/bin/b.rs index 1373f277d..15ebce5fa 100644 --- a/examples/boot/application/nrf/src/bin/b.rs +++ b/examples/boot/application/nrf/src/bin/b.rs | |||
| @@ -12,7 +12,10 @@ use panic_reset as _; | |||
| 12 | async fn main(_spawner: Spawner) { | 12 | async fn main(_spawner: Spawner) { |
| 13 | let p = embassy_nrf::init(Default::default()); | 13 | let p = embassy_nrf::init(Default::default()); |
| 14 | 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); |
| 15 | //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); |
| 16 | |||
| 17 | // nRF91 DK | ||
| 18 | // let mut led = Output::new(p.P0_02, Level::Low, OutputDrive::Standard); | ||
| 16 | 19 | ||
| 17 | loop { | 20 | loop { |
| 18 | led.set_high(); | 21 | led.set_high(); |
