aboutsummaryrefslogtreecommitdiff
path: root/examples/boot/bootloader
diff options
context:
space:
mode:
Diffstat (limited to 'examples/boot/bootloader')
-rw-r--r--examples/boot/bootloader/nrf/Cargo.toml6
-rw-r--r--examples/boot/bootloader/nrf/src/main.rs9
-rw-r--r--examples/boot/bootloader/rp/Cargo.toml2
-rw-r--r--examples/boot/bootloader/rp/src/main.rs6
-rw-r--r--examples/boot/bootloader/stm32-dual-bank/Cargo.toml2
-rw-r--r--examples/boot/bootloader/stm32-dual-bank/src/main.rs8
-rw-r--r--examples/boot/bootloader/stm32/Cargo.toml2
-rw-r--r--examples/boot/bootloader/stm32/src/main.rs8
-rw-r--r--examples/boot/bootloader/stm32wb-dfu/Cargo.toml2
-rw-r--r--examples/boot/bootloader/stm32wb-dfu/src/main.rs12
-rw-r--r--examples/boot/bootloader/stm32wba-dfu/Cargo.toml2
-rw-r--r--examples/boot/bootloader/stm32wba-dfu/src/main.rs14
12 files changed, 39 insertions, 34 deletions
diff --git a/examples/boot/bootloader/nrf/Cargo.toml b/examples/boot/bootloader/nrf/Cargo.toml
index 72b7114d4..59fc6e4ed 100644
--- a/examples/boot/bootloader/nrf/Cargo.toml
+++ b/examples/boot/bootloader/nrf/Cargo.toml
@@ -1,5 +1,5 @@
1[package] 1[package]
2edition = "2021" 2edition = "2024"
3name = "nrf-bootloader-example" 3name = "nrf-bootloader-example"
4version = "0.1.0" 4version = "0.1.0"
5description = "Bootloader for nRF chips" 5description = "Bootloader for nRF chips"
@@ -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 b849a0df3..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);
@@ -38,8 +41,8 @@ fn main() -> ! {
38 unsafe { bl.load(active_offset) } 41 unsafe { bl.load(active_offset) }
39} 42}
40 43
41#[no_mangle] 44#[unsafe(no_mangle)]
42#[cfg_attr(target_os = "none", link_section = ".HardFault.user")] 45#[cfg_attr(target_os = "none", unsafe(link_section = ".HardFault.user"))]
43unsafe extern "C" fn HardFault() { 46unsafe extern "C" fn HardFault() {
44 cortex_m::peripheral::SCB::sys_reset(); 47 cortex_m::peripheral::SCB::sys_reset();
45} 48}
@@ -47,7 +50,7 @@ unsafe extern "C" fn HardFault() {
47#[exception] 50#[exception]
48unsafe fn DefaultHandler(_: i16) -> ! { 51unsafe fn DefaultHandler(_: i16) -> ! {
49 const SCB_ICSR: *const u32 = 0xE000_ED04 as *const u32; 52 const SCB_ICSR: *const u32 = 0xE000_ED04 as *const u32;
50 let irqn = core::ptr::read_volatile(SCB_ICSR) as u8 as i16 - 16; 53 let irqn = unsafe { core::ptr::read_volatile(SCB_ICSR) } as u8 as i16 - 16;
51 54
52 panic!("DefaultHandler #{:?}", irqn); 55 panic!("DefaultHandler #{:?}", irqn);
53} 56}
diff --git a/examples/boot/bootloader/rp/Cargo.toml b/examples/boot/bootloader/rp/Cargo.toml
index 93a1c4edf..188bcab36 100644
--- a/examples/boot/bootloader/rp/Cargo.toml
+++ b/examples/boot/bootloader/rp/Cargo.toml
@@ -1,5 +1,5 @@
1[package] 1[package]
2edition = "2021" 2edition = "2024"
3name = "rp-bootloader-example" 3name = "rp-bootloader-example"
4version = "0.1.0" 4version = "0.1.0"
5description = "Example bootloader for RP2040 chips" 5description = "Example bootloader for RP2040 chips"
diff --git a/examples/boot/bootloader/rp/src/main.rs b/examples/boot/bootloader/rp/src/main.rs
index 25b1657b8..7ebefd374 100644
--- a/examples/boot/bootloader/rp/src/main.rs
+++ b/examples/boot/bootloader/rp/src/main.rs
@@ -34,8 +34,8 @@ fn main() -> ! {
34 unsafe { bl.load(embassy_rp::flash::FLASH_BASE as u32 + active_offset) } 34 unsafe { bl.load(embassy_rp::flash::FLASH_BASE as u32 + active_offset) }
35} 35}
36 36
37#[no_mangle] 37#[unsafe(no_mangle)]
38#[cfg_attr(target_os = "none", link_section = ".HardFault.user")] 38#[cfg_attr(target_os = "none", unsafe(link_section = ".HardFault.user"))]
39unsafe extern "C" fn HardFault() { 39unsafe extern "C" fn HardFault() {
40 cortex_m::peripheral::SCB::sys_reset(); 40 cortex_m::peripheral::SCB::sys_reset();
41} 41}
@@ -43,7 +43,7 @@ unsafe extern "C" fn HardFault() {
43#[exception] 43#[exception]
44unsafe fn DefaultHandler(_: i16) -> ! { 44unsafe fn DefaultHandler(_: i16) -> ! {
45 const SCB_ICSR: *const u32 = 0xE000_ED04 as *const u32; 45 const SCB_ICSR: *const u32 = 0xE000_ED04 as *const u32;
46 let irqn = core::ptr::read_volatile(SCB_ICSR) as u8 as i16 - 16; 46 let irqn = unsafe { core::ptr::read_volatile(SCB_ICSR) } as u8 as i16 - 16;
47 47
48 panic!("DefaultHandler #{:?}", irqn); 48 panic!("DefaultHandler #{:?}", irqn);
49} 49}
diff --git a/examples/boot/bootloader/stm32-dual-bank/Cargo.toml b/examples/boot/bootloader/stm32-dual-bank/Cargo.toml
index 95ca20a59..cf68921dc 100644
--- a/examples/boot/bootloader/stm32-dual-bank/Cargo.toml
+++ b/examples/boot/bootloader/stm32-dual-bank/Cargo.toml
@@ -1,5 +1,5 @@
1[package] 1[package]
2edition = "2021" 2edition = "2024"
3name = "stm32-bootloader-dual-bank-flash-example" 3name = "stm32-bootloader-dual-bank-flash-example"
4version = "0.1.0" 4version = "0.1.0"
5description = "Example bootloader for dual-bank flash STM32 chips" 5description = "Example bootloader for dual-bank flash STM32 chips"
diff --git a/examples/boot/bootloader/stm32-dual-bank/src/main.rs b/examples/boot/bootloader/stm32-dual-bank/src/main.rs
index 4d2e82d26..f0063fb5c 100644
--- a/examples/boot/bootloader/stm32-dual-bank/src/main.rs
+++ b/examples/boot/bootloader/stm32-dual-bank/src/main.rs
@@ -7,7 +7,7 @@ use cortex_m_rt::{entry, exception};
7#[cfg(feature = "defmt")] 7#[cfg(feature = "defmt")]
8use defmt_rtt as _; 8use defmt_rtt as _;
9use embassy_boot_stm32::*; 9use embassy_boot_stm32::*;
10use embassy_stm32::flash::{Flash, BANK1_REGION}; 10use embassy_stm32::flash::{BANK1_REGION, Flash};
11use embassy_sync::blocking_mutex::Mutex; 11use embassy_sync::blocking_mutex::Mutex;
12 12
13#[entry] 13#[entry]
@@ -33,8 +33,8 @@ fn main() -> ! {
33 unsafe { bl.load(BANK1_REGION.base + active_offset) } 33 unsafe { bl.load(BANK1_REGION.base + active_offset) }
34} 34}
35 35
36#[no_mangle] 36#[unsafe(no_mangle)]
37#[cfg_attr(target_os = "none", link_section = ".HardFault.user")] 37#[cfg_attr(target_os = "none", unsafe(link_section = ".HardFault.user"))]
38unsafe extern "C" fn HardFault() { 38unsafe extern "C" fn HardFault() {
39 cortex_m::peripheral::SCB::sys_reset(); 39 cortex_m::peripheral::SCB::sys_reset();
40} 40}
@@ -42,7 +42,7 @@ unsafe extern "C" fn HardFault() {
42#[exception] 42#[exception]
43unsafe fn DefaultHandler(_: i16) -> ! { 43unsafe fn DefaultHandler(_: i16) -> ! {
44 const SCB_ICSR: *const u32 = 0xE000_ED04 as *const u32; 44 const SCB_ICSR: *const u32 = 0xE000_ED04 as *const u32;
45 let irqn = core::ptr::read_volatile(SCB_ICSR) as u8 as i16 - 16; 45 let irqn = unsafe { core::ptr::read_volatile(SCB_ICSR) } as u8 as i16 - 16;
46 46
47 panic!("DefaultHandler #{:?}", irqn); 47 panic!("DefaultHandler #{:?}", irqn);
48} 48}
diff --git a/examples/boot/bootloader/stm32/Cargo.toml b/examples/boot/bootloader/stm32/Cargo.toml
index 526637f37..e457310b9 100644
--- a/examples/boot/bootloader/stm32/Cargo.toml
+++ b/examples/boot/bootloader/stm32/Cargo.toml
@@ -1,5 +1,5 @@
1[package] 1[package]
2edition = "2021" 2edition = "2024"
3name = "stm32-bootloader-example" 3name = "stm32-bootloader-example"
4version = "0.1.0" 4version = "0.1.0"
5description = "Example bootloader for STM32 chips" 5description = "Example bootloader for STM32 chips"
diff --git a/examples/boot/bootloader/stm32/src/main.rs b/examples/boot/bootloader/stm32/src/main.rs
index 99a7a6a6b..383ad912d 100644
--- a/examples/boot/bootloader/stm32/src/main.rs
+++ b/examples/boot/bootloader/stm32/src/main.rs
@@ -7,7 +7,7 @@ use cortex_m_rt::{entry, exception};
7#[cfg(feature = "defmt")] 7#[cfg(feature = "defmt")]
8use defmt_rtt as _; 8use defmt_rtt as _;
9use embassy_boot_stm32::*; 9use embassy_boot_stm32::*;
10use embassy_stm32::flash::{Flash, BANK1_REGION}; 10use embassy_stm32::flash::{BANK1_REGION, Flash};
11use embassy_sync::blocking_mutex::Mutex; 11use embassy_sync::blocking_mutex::Mutex;
12 12
13#[entry] 13#[entry]
@@ -32,8 +32,8 @@ fn main() -> ! {
32 unsafe { bl.load(BANK1_REGION.base + active_offset) } 32 unsafe { bl.load(BANK1_REGION.base + active_offset) }
33} 33}
34 34
35#[no_mangle] 35#[unsafe(no_mangle)]
36#[cfg_attr(target_os = "none", link_section = ".HardFault.user")] 36#[cfg_attr(target_os = "none", unsafe(link_section = ".HardFault.user"))]
37unsafe extern "C" fn HardFault() { 37unsafe extern "C" fn HardFault() {
38 cortex_m::peripheral::SCB::sys_reset(); 38 cortex_m::peripheral::SCB::sys_reset();
39} 39}
@@ -41,7 +41,7 @@ unsafe extern "C" fn HardFault() {
41#[exception] 41#[exception]
42unsafe fn DefaultHandler(_: i16) -> ! { 42unsafe fn DefaultHandler(_: i16) -> ! {
43 const SCB_ICSR: *const u32 = 0xE000_ED04 as *const u32; 43 const SCB_ICSR: *const u32 = 0xE000_ED04 as *const u32;
44 let irqn = core::ptr::read_volatile(SCB_ICSR) as u8 as i16 - 16; 44 let irqn = unsafe { core::ptr::read_volatile(SCB_ICSR) } as u8 as i16 - 16;
45 45
46 panic!("DefaultHandler #{:?}", irqn); 46 panic!("DefaultHandler #{:?}", irqn);
47} 47}
diff --git a/examples/boot/bootloader/stm32wb-dfu/Cargo.toml b/examples/boot/bootloader/stm32wb-dfu/Cargo.toml
index ef10aeabf..75b7081df 100644
--- a/examples/boot/bootloader/stm32wb-dfu/Cargo.toml
+++ b/examples/boot/bootloader/stm32wb-dfu/Cargo.toml
@@ -1,5 +1,5 @@
1[package] 1[package]
2edition = "2021" 2edition = "2024"
3name = "stm32wb-dfu-bootloader-example" 3name = "stm32wb-dfu-bootloader-example"
4version = "0.1.0" 4version = "0.1.0"
5description = "Example USB DFUbootloader for the STM32WB series of chips" 5description = "Example USB DFUbootloader for the STM32WB series of chips"
diff --git a/examples/boot/bootloader/stm32wb-dfu/src/main.rs b/examples/boot/bootloader/stm32wb-dfu/src/main.rs
index 107f243fd..9ee82846d 100644
--- a/examples/boot/bootloader/stm32wb-dfu/src/main.rs
+++ b/examples/boot/bootloader/stm32wb-dfu/src/main.rs
@@ -7,14 +7,14 @@ use cortex_m_rt::{entry, exception};
7#[cfg(feature = "defmt")] 7#[cfg(feature = "defmt")]
8use defmt_rtt as _; 8use defmt_rtt as _;
9use embassy_boot_stm32::*; 9use embassy_boot_stm32::*;
10use embassy_stm32::flash::{Flash, BANK1_REGION, WRITE_SIZE}; 10use embassy_stm32::flash::{BANK1_REGION, Flash, WRITE_SIZE};
11use embassy_stm32::rcc::WPAN_DEFAULT; 11use embassy_stm32::rcc::WPAN_DEFAULT;
12use embassy_stm32::usb::Driver; 12use embassy_stm32::usb::Driver;
13use embassy_stm32::{bind_interrupts, peripherals, usb}; 13use embassy_stm32::{bind_interrupts, peripherals, usb};
14use embassy_sync::blocking_mutex::Mutex; 14use embassy_sync::blocking_mutex::Mutex;
15use embassy_usb::{msos, Builder}; 15use embassy_usb::{Builder, msos};
16use embassy_usb_dfu::consts::DfuAttributes; 16use embassy_usb_dfu::consts::DfuAttributes;
17use embassy_usb_dfu::{usb_dfu, Control, ResetImmediate}; 17use embassy_usb_dfu::{Control, ResetImmediate, usb_dfu};
18 18
19bind_interrupts!(struct Irqs { 19bind_interrupts!(struct Irqs {
20 USB_LP => usb::InterruptHandler<peripherals::USB>; 20 USB_LP => usb::InterruptHandler<peripherals::USB>;
@@ -109,8 +109,8 @@ fn main() -> ! {
109 unsafe { bl.load(BANK1_REGION.base + active_offset) } 109 unsafe { bl.load(BANK1_REGION.base + active_offset) }
110} 110}
111 111
112#[no_mangle] 112#[unsafe(no_mangle)]
113#[cfg_attr(target_os = "none", link_section = ".HardFault.user")] 113#[cfg_attr(target_os = "none", unsafe(link_section = ".HardFault.user"))]
114unsafe extern "C" fn HardFault() { 114unsafe extern "C" fn HardFault() {
115 cortex_m::peripheral::SCB::sys_reset(); 115 cortex_m::peripheral::SCB::sys_reset();
116} 116}
@@ -118,7 +118,7 @@ unsafe extern "C" fn HardFault() {
118#[exception] 118#[exception]
119unsafe fn DefaultHandler(_: i16) -> ! { 119unsafe fn DefaultHandler(_: i16) -> ! {
120 const SCB_ICSR: *const u32 = 0xE000_ED04 as *const u32; 120 const SCB_ICSR: *const u32 = 0xE000_ED04 as *const u32;
121 let irqn = core::ptr::read_volatile(SCB_ICSR) as u8 as i16 - 16; 121 let irqn = unsafe { core::ptr::read_volatile(SCB_ICSR) } as u8 as i16 - 16;
122 122
123 panic!("DefaultHandler #{:?}", irqn); 123 panic!("DefaultHandler #{:?}", irqn);
124} 124}
diff --git a/examples/boot/bootloader/stm32wba-dfu/Cargo.toml b/examples/boot/bootloader/stm32wba-dfu/Cargo.toml
index 16de7684e..eee2b2f71 100644
--- a/examples/boot/bootloader/stm32wba-dfu/Cargo.toml
+++ b/examples/boot/bootloader/stm32wba-dfu/Cargo.toml
@@ -1,5 +1,5 @@
1[package] 1[package]
2edition = "2021" 2edition = "2024"
3name = "stm32wba6-dfu-bootloader-example" 3name = "stm32wba6-dfu-bootloader-example"
4version = "0.1.0" 4version = "0.1.0"
5description = "Example USB DFUbootloader for the STM32WBA series of chips" 5description = "Example USB DFUbootloader for the STM32WBA series of chips"
diff --git a/examples/boot/bootloader/stm32wba-dfu/src/main.rs b/examples/boot/bootloader/stm32wba-dfu/src/main.rs
index 75d8d4199..b33a75d95 100644
--- a/examples/boot/bootloader/stm32wba-dfu/src/main.rs
+++ b/examples/boot/bootloader/stm32wba-dfu/src/main.rs
@@ -7,13 +7,13 @@ use cortex_m_rt::{entry, exception};
7#[cfg(feature = "defmt")] 7#[cfg(feature = "defmt")]
8use defmt_rtt as _; 8use defmt_rtt as _;
9use embassy_boot_stm32::*; 9use embassy_boot_stm32::*;
10use embassy_stm32::flash::{Flash, BANK1_REGION, WRITE_SIZE}; 10use embassy_stm32::flash::{BANK1_REGION, Flash, WRITE_SIZE};
11use embassy_stm32::usb::Driver; 11use embassy_stm32::usb::Driver;
12use embassy_stm32::{bind_interrupts, peripherals, usb, Config}; 12use embassy_stm32::{Config, bind_interrupts, peripherals, usb};
13use embassy_sync::blocking_mutex::Mutex; 13use embassy_sync::blocking_mutex::Mutex;
14use embassy_usb::{msos, Builder}; 14use embassy_usb::{Builder, msos};
15use embassy_usb_dfu::consts::DfuAttributes; 15use embassy_usb_dfu::consts::DfuAttributes;
16use embassy_usb_dfu::{usb_dfu, Control, ResetImmediate}; 16use embassy_usb_dfu::{Control, ResetImmediate, usb_dfu};
17 17
18bind_interrupts!(struct Irqs { 18bind_interrupts!(struct Irqs {
19 USB_OTG_HS => usb::InterruptHandler<peripherals::USB_OTG_HS>; 19 USB_OTG_HS => usb::InterruptHandler<peripherals::USB_OTG_HS>;
@@ -138,8 +138,8 @@ fn main() -> ! {
138 unsafe { bl.load(BANK1_REGION.base + active_offset) } 138 unsafe { bl.load(BANK1_REGION.base + active_offset) }
139} 139}
140 140
141#[no_mangle] 141#[unsafe(no_mangle)]
142#[cfg_attr(target_os = "none", link_section = ".HardFault.user")] 142#[cfg_attr(target_os = "none", unsafe(link_section = ".HardFault.user"))]
143unsafe extern "C" fn HardFault() { 143unsafe extern "C" fn HardFault() {
144 cortex_m::peripheral::SCB::sys_reset(); 144 cortex_m::peripheral::SCB::sys_reset();
145} 145}
@@ -147,7 +147,7 @@ unsafe extern "C" fn HardFault() {
147#[exception] 147#[exception]
148unsafe fn DefaultHandler(_: i16) -> ! { 148unsafe fn DefaultHandler(_: i16) -> ! {
149 const SCB_ICSR: *const u32 = 0xE000_ED04 as *const u32; 149 const SCB_ICSR: *const u32 = 0xE000_ED04 as *const u32;
150 let irqn = core::ptr::read_volatile(SCB_ICSR) as u8 as i16 - 16; 150 let irqn = unsafe { core::ptr::read_volatile(SCB_ICSR) } as u8 as i16 - 16;
151 151
152 panic!("DefaultHandler #{:?}", irqn); 152 panic!("DefaultHandler #{:?}", irqn);
153} 153}