From d13d893ff2e7190ac8f9c2187e487a7abe45b43a Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Tue, 31 May 2022 23:52:27 +0200 Subject: [PATCH] boot/stm32: autodetect thumbv6, remove cargo feature. --- embassy-boot/stm32/Cargo.toml | 1 - embassy-boot/stm32/build.rs | 5 +++++ embassy-boot/stm32/src/lib.rs | 2 +- examples/boot/stm32l0/Cargo.toml | 2 +- examples/boot/stm32l0/README.md | 2 +- 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/embassy-boot/stm32/Cargo.toml b/embassy-boot/stm32/Cargo.toml index 78339b0a..a31717ff 100644 --- a/embassy-boot/stm32/Cargo.toml +++ b/embassy-boot/stm32/Cargo.toml @@ -27,7 +27,6 @@ defmt = [ "embassy-stm32/defmt", ] debug = ["defmt-rtt"] -thumbv6 = [] [profile.dev] debug = 2 diff --git a/embassy-boot/stm32/build.rs b/embassy-boot/stm32/build.rs index fd605991..3997702f 100644 --- a/embassy-boot/stm32/build.rs +++ b/embassy-boot/stm32/build.rs @@ -24,4 +24,9 @@ fn main() { if env::var("CARGO_FEATURE_DEFMT").is_ok() { println!("cargo:rustc-link-arg-bins=-Tdefmt.x"); } + + let target = env::var("TARGET").unwrap(); + if target.starts_with("thumbv6m-") { + println!("cargo:rustc-cfg=armv6m"); + } } diff --git a/embassy-boot/stm32/src/lib.rs b/embassy-boot/stm32/src/lib.rs index 48512534..8c6e6550 100644 --- a/embassy-boot/stm32/src/lib.rs +++ b/embassy-boot/stm32/src/lib.rs @@ -76,7 +76,7 @@ impl BootLoader { trace!("Loading app at 0x{:x}", start); #[allow(unused_mut)] let mut p = cortex_m::Peripherals::steal(); - #[cfg(not(feature = "thumbv6"))] + #[cfg(not(armv6m))] p.SCB.invalidate_icache(); p.SCB.vtor.write(start as u32); diff --git a/examples/boot/stm32l0/Cargo.toml b/examples/boot/stm32l0/Cargo.toml index 13ca8436..a9e03155 100644 --- a/examples/boot/stm32l0/Cargo.toml +++ b/examples/boot/stm32l0/Cargo.toml @@ -7,7 +7,7 @@ version = "0.1.0" [dependencies] embassy = { version = "0.1.0", path = "../../../embassy", features = ["nightly"] } embassy-stm32 = { version = "0.1.0", path = "../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32l072cz", "time-driver-any", "exti", "memory-x"] } -embassy-boot-stm32 = { version = "0.1.0", path = "../../../embassy-boot/stm32", features = ["thumbv6"] } +embassy-boot-stm32 = { version = "0.1.0", path = "../../../embassy-boot/stm32" } embassy-embedded-hal = { version = "0.1.0", path = "../../../embassy-embedded-hal" } defmt = { version = "0.3", optional = true } diff --git a/examples/boot/stm32l0/README.md b/examples/boot/stm32l0/README.md index b498fdc2..a0e8021f 100644 --- a/examples/boot/stm32l0/README.md +++ b/examples/boot/stm32l0/README.md @@ -15,7 +15,7 @@ application. ``` # Flash bootloader -cargo flash --manifest-path ../../../embassy-boot/stm32/Cargo.toml --release --features embassy-stm32/stm32l072cz,thumbv6 --chip STM32L072CZTx +cargo flash --manifest-path ../../../embassy-boot/stm32/Cargo.toml --release --features embassy-stm32/stm32l072cz --chip STM32L072CZTx # Build 'b' cargo build --release --bin b # Generate binary for 'b'