From 18c62aa5b475161c0cbd98c23c006691e084cb2b Mon Sep 17 00:00:00 2001 From: Rasmus Melchior Jacobsen Date: Mon, 22 May 2023 11:32:39 +0200 Subject: [PATCH] Protect default implementations for FirmwareUpdater and BootLoader It seems as if the arm compiler can does not care about whether the bootloader symbols are undefined if the default() function is never used. The x64 compiler does care however, so this change ensures that we can instantiate the types from tests. --- embassy-boot/boot/src/firmware_updater.rs | 1 + embassy-boot/nrf/src/lib.rs | 1 + embassy-boot/rp/src/lib.rs | 1 + embassy-boot/stm32/src/lib.rs | 1 + 4 files changed, 4 insertions(+) diff --git a/embassy-boot/boot/src/firmware_updater.rs b/embassy-boot/boot/src/firmware_updater.rs index 92987825f..aeea206f9 100644 --- a/embassy-boot/boot/src/firmware_updater.rs +++ b/embassy-boot/boot/src/firmware_updater.rs @@ -40,6 +40,7 @@ pub struct FirmwareUpdater { dfu: Partition, } +#[cfg(target_os = "none")] impl Default for FirmwareUpdater { fn default() -> Self { extern "C" { diff --git a/embassy-boot/nrf/src/lib.rs b/embassy-boot/nrf/src/lib.rs index 14bea1f79..710798bdb 100644 --- a/embassy-boot/nrf/src/lib.rs +++ b/embassy-boot/nrf/src/lib.rs @@ -15,6 +15,7 @@ pub struct BootLoader { aligned_buf: AlignedBuffer, } +#[cfg(target_os = "none")] impl Default for BootLoader { /// Create a new bootloader instance using parameters from linker script fn default() -> Self { diff --git a/embassy-boot/rp/src/lib.rs b/embassy-boot/rp/src/lib.rs index 0d577f08a..fb9bc3242 100644 --- a/embassy-boot/rp/src/lib.rs +++ b/embassy-boot/rp/src/lib.rs @@ -51,6 +51,7 @@ impl BootLoader { } } +#[cfg(target_os = "none")] impl Default for BootLoader { /// Create a new bootloader instance using parameters from linker script fn default() -> Self { diff --git a/embassy-boot/stm32/src/lib.rs b/embassy-boot/stm32/src/lib.rs index 88ce1c878..ccf136c74 100644 --- a/embassy-boot/stm32/src/lib.rs +++ b/embassy-boot/stm32/src/lib.rs @@ -46,6 +46,7 @@ impl BootLoader { } } +#[cfg(target_os = "none")] impl Default for BootLoader { /// Create a new bootloader instance using parameters from linker script fn default() -> Self {