diff options
Diffstat (limited to 'examples/boot/bootloader/nrf')
| -rw-r--r-- | examples/boot/bootloader/nrf/Cargo.toml | 18 | ||||
| -rw-r--r-- | examples/boot/bootloader/nrf/src/main.rs | 12 |
2 files changed, 20 insertions, 10 deletions
diff --git a/examples/boot/bootloader/nrf/Cargo.toml b/examples/boot/bootloader/nrf/Cargo.toml index 9d5d51a13..1fea2b7d7 100644 --- a/examples/boot/bootloader/nrf/Cargo.toml +++ b/examples/boot/bootloader/nrf/Cargo.toml | |||
| @@ -1,18 +1,19 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 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 | license = "MIT OR Apache-2.0" |
| 7 | publish = false | ||
| 7 | 8 | ||
| 8 | [dependencies] | 9 | [dependencies] |
| 9 | defmt = { version = "0.3", optional = true } | 10 | defmt = { version = "1.0.1", optional = true } |
| 10 | defmt-rtt = { version = "0.4", optional = true } | 11 | defmt-rtt = { version = "1.0.0", optional = true } |
| 11 | 12 | ||
| 12 | embassy-nrf = { path = "../../../../embassy-nrf", features = [] } | 13 | embassy-nrf = { path = "../../../../embassy-nrf", features = [] } |
| 13 | embassy-boot-nrf = { path = "../../../../embassy-boot-nrf" } | 14 | embassy-boot-nrf = { path = "../../../../embassy-boot-nrf" } |
| 14 | cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } | 15 | cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } |
| 15 | embassy-sync = { version = "0.6.0", path = "../../../../embassy-sync" } | 16 | embassy-sync = { version = "0.7.2", path = "../../../../embassy-sync" } |
| 16 | cortex-m-rt = { version = "0.7" } | 17 | cortex-m-rt = { version = "0.7" } |
| 17 | cfg-if = "1.0.0" | 18 | cfg-if = "1.0.0" |
| 18 | 19 | ||
| @@ -57,3 +58,12 @@ debug = false | |||
| 57 | debug-assertions = false | 58 | debug-assertions = false |
| 58 | opt-level = 0 | 59 | opt-level = 0 |
| 59 | overflow-checks = false | 60 | overflow-checks = false |
| 61 | |||
| 62 | [package.metadata.embassy] | ||
| 63 | build = [ | ||
| 64 | { target = "thumbv7em-none-eabi", features = ["embassy-nrf/nrf52840"] }, | ||
| 65 | { 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/nrf9151-ns"] }, | ||
| 68 | { target = "thumbv8m.main-none-eabihf", features = ["embassy-nrf/nrf9161-ns"] } | ||
| 69 | ] | ||
diff --git a/examples/boot/bootloader/nrf/src/main.rs b/examples/boot/bootloader/nrf/src/main.rs index 67c700437..76c4c1048 100644 --- a/examples/boot/bootloader/nrf/src/main.rs +++ b/examples/boot/bootloader/nrf/src/main.rs | |||
| @@ -8,7 +8,7 @@ use cortex_m_rt::{entry, exception}; | |||
| 8 | use defmt_rtt as _; | 8 | use defmt_rtt as _; |
| 9 | use embassy_boot_nrf::*; | 9 | use embassy_boot_nrf::*; |
| 10 | use embassy_nrf::nvmc::Nvmc; | 10 | use embassy_nrf::nvmc::Nvmc; |
| 11 | use embassy_nrf::wdt; | 11 | use embassy_nrf::wdt::{self, HaltConfig, SleepConfig}; |
| 12 | use embassy_sync::blocking_mutex::Mutex; | 12 | use embassy_sync::blocking_mutex::Mutex; |
| 13 | 13 | ||
| 14 | #[entry] | 14 | #[entry] |
| @@ -25,8 +25,8 @@ fn main() -> ! { | |||
| 25 | 25 | ||
| 26 | let mut wdt_config = wdt::Config::default(); | 26 | let mut wdt_config = wdt::Config::default(); |
| 27 | wdt_config.timeout_ticks = 32768 * 5; // timeout seconds | 27 | wdt_config.timeout_ticks = 32768 * 5; // timeout seconds |
| 28 | wdt_config.run_during_sleep = true; | 28 | wdt_config.action_during_sleep = SleepConfig::RUN; |
| 29 | wdt_config.run_during_debug_halt = false; | 29 | wdt_config.action_during_debug_halt = HaltConfig::PAUSE; |
| 30 | 30 | ||
| 31 | let flash = WatchdogFlash::start(Nvmc::new(p.NVMC), p.WDT, wdt_config); | 31 | let flash = WatchdogFlash::start(Nvmc::new(p.NVMC), p.WDT, wdt_config); |
| 32 | let flash = Mutex::new(RefCell::new(flash)); | 32 | let flash = Mutex::new(RefCell::new(flash)); |
| @@ -38,8 +38,8 @@ fn main() -> ! { | |||
| 38 | unsafe { bl.load(active_offset) } | 38 | unsafe { bl.load(active_offset) } |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | #[no_mangle] | 41 | #[unsafe(no_mangle)] |
| 42 | #[cfg_attr(target_os = "none", link_section = ".HardFault.user")] | 42 | #[cfg_attr(target_os = "none", unsafe(link_section = ".HardFault.user"))] |
| 43 | unsafe extern "C" fn HardFault() { | 43 | unsafe extern "C" fn HardFault() { |
| 44 | cortex_m::peripheral::SCB::sys_reset(); | 44 | cortex_m::peripheral::SCB::sys_reset(); |
| 45 | } | 45 | } |
| @@ -47,7 +47,7 @@ unsafe extern "C" fn HardFault() { | |||
| 47 | #[exception] | 47 | #[exception] |
| 48 | unsafe fn DefaultHandler(_: i16) -> ! { | 48 | unsafe fn DefaultHandler(_: i16) -> ! { |
| 49 | const SCB_ICSR: *const u32 = 0xE000_ED04 as *const u32; | 49 | const SCB_ICSR: *const u32 = 0xE000_ED04 as *const u32; |
| 50 | let irqn = core::ptr::read_volatile(SCB_ICSR) as u8 as i16 - 16; | 50 | let irqn = unsafe { core::ptr::read_volatile(SCB_ICSR) } as u8 as i16 - 16; |
| 51 | 51 | ||
| 52 | panic!("DefaultHandler #{:?}", irqn); | 52 | panic!("DefaultHandler #{:?}", irqn); |
| 53 | } | 53 | } |
