diff options
| author | Quentin Smith <[email protected]> | 2023-07-17 21:31:43 -0400 |
|---|---|---|
| committer | Quentin Smith <[email protected]> | 2023-07-17 21:31:43 -0400 |
| commit | 6f02403184eb7fb7990fb88fc9df9c4328a690a3 (patch) | |
| tree | 748f510e190bb2724750507a6e69ed1a8e08cb20 /examples/boot/bootloader/nrf | |
| parent | d896f80405aa8963877049ed999e4aba25d6e2bb (diff) | |
| parent | 6b5df4523aa1c4902f02e803450ae4b418e0e3ca (diff) | |
Merge remote-tracking branch 'origin/main' into nrf-pdm
Diffstat (limited to 'examples/boot/bootloader/nrf')
| -rw-r--r-- | examples/boot/bootloader/nrf/.cargo/config.toml | 2 | ||||
| -rw-r--r-- | examples/boot/bootloader/nrf/Cargo.toml | 10 | ||||
| -rw-r--r-- | examples/boot/bootloader/nrf/memory-bm.x | 2 | ||||
| -rw-r--r-- | examples/boot/bootloader/nrf/memory.x | 2 | ||||
| -rw-r--r-- | examples/boot/bootloader/nrf/src/main.rs | 26 |
5 files changed, 28 insertions, 14 deletions
diff --git a/examples/boot/bootloader/nrf/.cargo/config.toml b/examples/boot/bootloader/nrf/.cargo/config.toml index 1060800a3..c292846aa 100644 --- a/examples/boot/bootloader/nrf/.cargo/config.toml +++ b/examples/boot/bootloader/nrf/.cargo/config.toml | |||
| @@ -4,7 +4,7 @@ build-std-features = ["panic_immediate_abort"] | |||
| 4 | 4 | ||
| 5 | [target.'cfg(all(target_arch = "arm", target_os = "none"))'] | 5 | [target.'cfg(all(target_arch = "arm", target_os = "none"))'] |
| 6 | #runner = "./fruitrunner" | 6 | #runner = "./fruitrunner" |
| 7 | runner = "probe-run --chip nrf52840_xxAA" | 7 | runner = "probe-rs run --chip nrf52840_xxAA" |
| 8 | 8 | ||
| 9 | rustflags = [ | 9 | rustflags = [ |
| 10 | # Code-size optimizations. | 10 | # Code-size optimizations. |
diff --git a/examples/boot/bootloader/nrf/Cargo.toml b/examples/boot/bootloader/nrf/Cargo.toml index aa2a13ecb..40656f359 100644 --- a/examples/boot/bootloader/nrf/Cargo.toml +++ b/examples/boot/bootloader/nrf/Cargo.toml | |||
| @@ -3,14 +3,16 @@ edition = "2021" | |||
| 3 | name = "nrf-bootloader-example" | 3 | name = "nrf-bootloader-example" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | description = "Bootloader for nRF chips" | 5 | description = "Bootloader for nRF chips" |
| 6 | license = "MIT OR Apache-2.0" | ||
| 6 | 7 | ||
| 7 | [dependencies] | 8 | [dependencies] |
| 8 | defmt = { version = "0.3", optional = true } | 9 | defmt = { version = "0.3", optional = true } |
| 9 | defmt-rtt = { version = "0.3", optional = true } | 10 | defmt-rtt = { version = "0.4", optional = true } |
| 10 | 11 | ||
| 11 | embassy-nrf = { path = "../../../../embassy-nrf", default-features = false, features = ["nightly"] } | 12 | embassy-nrf = { path = "../../../../embassy-nrf", features = ["nightly"] } |
| 12 | embassy-boot-nrf = { path = "../../../../embassy-boot/nrf", default-features = false } | 13 | embassy-boot-nrf = { path = "../../../../embassy-boot/nrf" } |
| 13 | cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } | 14 | cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } |
| 15 | embassy-sync = { path = "../../../../embassy-sync" } | ||
| 14 | cortex-m-rt = { version = "0.7" } | 16 | cortex-m-rt = { version = "0.7" } |
| 15 | cfg-if = "1.0.0" | 17 | cfg-if = "1.0.0" |
| 16 | 18 | ||
diff --git a/examples/boot/bootloader/nrf/memory-bm.x b/examples/boot/bootloader/nrf/memory-bm.x index 8a32b905f..257d65644 100644 --- a/examples/boot/bootloader/nrf/memory-bm.x +++ b/examples/boot/bootloader/nrf/memory-bm.x | |||
| @@ -5,7 +5,7 @@ MEMORY | |||
| 5 | BOOTLOADER_STATE : ORIGIN = 0x00006000, LENGTH = 4K | 5 | BOOTLOADER_STATE : ORIGIN = 0x00006000, LENGTH = 4K |
| 6 | ACTIVE : ORIGIN = 0x00007000, LENGTH = 64K | 6 | ACTIVE : ORIGIN = 0x00007000, LENGTH = 64K |
| 7 | DFU : ORIGIN = 0x00017000, LENGTH = 68K | 7 | DFU : ORIGIN = 0x00017000, LENGTH = 68K |
| 8 | RAM (rwx) : ORIGIN = 0x20000008, LENGTH = 32K | 8 | RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 32K |
| 9 | } | 9 | } |
| 10 | 10 | ||
| 11 | __bootloader_state_start = ORIGIN(BOOTLOADER_STATE); | 11 | __bootloader_state_start = ORIGIN(BOOTLOADER_STATE); |
diff --git a/examples/boot/bootloader/nrf/memory.x b/examples/boot/bootloader/nrf/memory.x index 8a32b905f..257d65644 100644 --- a/examples/boot/bootloader/nrf/memory.x +++ b/examples/boot/bootloader/nrf/memory.x | |||
| @@ -5,7 +5,7 @@ MEMORY | |||
| 5 | BOOTLOADER_STATE : ORIGIN = 0x00006000, LENGTH = 4K | 5 | BOOTLOADER_STATE : ORIGIN = 0x00006000, LENGTH = 4K |
| 6 | ACTIVE : ORIGIN = 0x00007000, LENGTH = 64K | 6 | ACTIVE : ORIGIN = 0x00007000, LENGTH = 64K |
| 7 | DFU : ORIGIN = 0x00017000, LENGTH = 68K | 7 | DFU : ORIGIN = 0x00017000, LENGTH = 68K |
| 8 | RAM (rwx) : ORIGIN = 0x20000008, LENGTH = 32K | 8 | RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 32K |
| 9 | } | 9 | } |
| 10 | 10 | ||
| 11 | __bootloader_state_start = ORIGIN(BOOTLOADER_STATE); | 11 | __bootloader_state_start = ORIGIN(BOOTLOADER_STATE); |
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] |
