Skip to content

Commit 3f9f501

Browse files
committed
Route sources of panics to the crate's fmt macros
1 parent 65a9027 commit 3f9f501

File tree

4 files changed

+22
-4
lines changed

4 files changed

+22
-4
lines changed

embassy-boot-nrf/src/lib.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@ impl<const BUFFER_SIZE: usize> BootLoader<BUFFER_SIZE> {
2020
pub fn prepare<ACTIVE: NorFlash, DFU: NorFlash, STATE: NorFlash>(
2121
config: BootLoaderConfig<ACTIVE, DFU, STATE>,
2222
) -> Self {
23-
Self::try_prepare::<ACTIVE, DFU, STATE>(config).expect("Boot prepare error")
23+
if let Ok(loader) = Self::try_prepare::<ACTIVE, DFU, STATE>(config) {
24+
loader
25+
} else {
26+
// Use explicit panic instead of .expect() to ensure this gets routed via defmt/etc.
27+
// properly
28+
panic!("Boot prepare error")
29+
}
2430
}
2531

2632
/// Inspect the bootloader state and perform actions required before booting, such as swapping firmware

embassy-boot-rp/src/lib.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@ impl<const BUFFER_SIZE: usize> BootLoader<BUFFER_SIZE> {
2121
pub fn prepare<ACTIVE: NorFlash, DFU: NorFlash, STATE: NorFlash>(
2222
config: BootLoaderConfig<ACTIVE, DFU, STATE>,
2323
) -> Self {
24-
Self::try_prepare::<ACTIVE, DFU, STATE>(config).expect("Boot prepare error")
24+
if let Ok(loader) = Self::try_prepare::<ACTIVE, DFU, STATE>(config) {
25+
loader
26+
} else {
27+
// Use explicit panic instead of .expect() to ensure this gets routed via defmt/etc.
28+
// properly
29+
panic!("Boot prepare error")
30+
}
2531
}
2632

2733
/// Inspect the bootloader state and perform actions required before booting, such as swapping firmware

embassy-boot-stm32/src/lib.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@ impl BootLoader {
2020
pub fn prepare<ACTIVE: NorFlash, DFU: NorFlash, STATE: NorFlash, const BUFFER_SIZE: usize>(
2121
config: BootLoaderConfig<ACTIVE, DFU, STATE>,
2222
) -> Self {
23-
Self::try_prepare::<ACTIVE, DFU, STATE, BUFFER_SIZE>(config).expect("Boot prepare error")
23+
if let Ok(loader) = Self::try_prepare::<ACTIVE, DFU, STATE, BUFFER_SIZE>(config) {
24+
loader
25+
} else {
26+
// Use explicit panic instead of .expect() to ensure this gets routed via defmt/etc.
27+
// properly
28+
panic!("Boot prepare error")
29+
}
2430
}
2531

2632
/// Inspect the bootloader state and perform actions required before booting, such as swapping firmware

embassy-boot/src/test_flash/asynch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ where
4343
}
4444

4545
fn create_partition<T: NorFlash>(mutex: &Mutex<NoopRawMutex, T>) -> Partition<NoopRawMutex, T> {
46-
Partition::new(mutex, 0, mutex.try_lock().unwrap().capacity() as u32)
46+
Partition::new(mutex, 0, unwrap!(mutex.try_lock()).capacity() as u32)
4747
}
4848
}
4949

0 commit comments

Comments
 (0)