From eba55543beb05e0630a535bdf0948d0f3c9f3bdd Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Wed, 11 Oct 2023 23:21:28 +0200 Subject: [PATCH] f0 blinky in 3084 bytes --- examples/stm32f0/.cargo/config.toml | 15 +++++++++++++++ examples/stm32f0/Cargo.toml | 14 +++++++------- examples/stm32f0/build.rs | 1 - examples/stm32f0/src/bin/blinky.rs | 7 +------ 4 files changed, 23 insertions(+), 14 deletions(-) diff --git a/examples/stm32f0/.cargo/config.toml b/examples/stm32f0/.cargo/config.toml index def4c8c9..1d43a4e0 100644 --- a/examples/stm32f0/.cargo/config.toml +++ b/examples/stm32f0/.cargo/config.toml @@ -1,3 +1,18 @@ +[unstable] +# enabling these breaks the float tests during linking, with intrinsics +# duplicated between embassy-rp and compilter_builtins +build-std = ["core"] +build-std-features = ["panic_immediate_abort"] + +[target.'cfg(all(target_arch = "arm", target_os = "none"))'] +runner = "teleprobe client run" +#runner = "teleprobe local run --chip RP2040 --elf" + +rustflags = [ + # Code-size optimizations. + "-Z", "trap-unreachable=no", +] + [target.thumbv6m-none-eabi] runner = 'probe-rs run --chip STM32F091RCTX' diff --git a/examples/stm32f0/Cargo.toml b/examples/stm32f0/Cargo.toml index db9a24d7..3b3ed02c 100644 --- a/examples/stm32f0/Cargo.toml +++ b/examples/stm32f0/Cargo.toml @@ -8,16 +8,16 @@ license = "MIT OR Apache-2.0" [dependencies] # Change stm32f091rc to your chip name, if necessary. -embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "memory-x", "stm32f091rc", "time-driver-any", "exti", "unstable-pac"] } +embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "memory-x", "stm32f091rc", "time-driver-any", "unstable-pac"] } cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } cortex-m-rt = "0.7.0" -defmt = "0.3" -defmt-rtt = "0.4" -panic-probe = "0.3" -embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] } -embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } -embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } +embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = [] } +embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "integrated-timers"] } +embassy-time = { version = "0.1.3", path = "../../embassy-time", features = [ "tick-hz-32_768"] } static_cell = { version = "1.1", features = ["nightly"]} +panic-halt = "0.2.0" [profile.release] debug = 2 +opt-level = 's' +lto = 'fat' \ No newline at end of file diff --git a/examples/stm32f0/build.rs b/examples/stm32f0/build.rs index 8cd32d7e..d5dbd879 100644 --- a/examples/stm32f0/build.rs +++ b/examples/stm32f0/build.rs @@ -1,5 +1,4 @@ fn main() { println!("cargo:rustc-link-arg-bins=--nmagic"); println!("cargo:rustc-link-arg-bins=-Tlink.x"); - println!("cargo:rustc-link-arg-bins=-Tdefmt.x"); } diff --git a/examples/stm32f0/src/bin/blinky.rs b/examples/stm32f0/src/bin/blinky.rs index 9f923399..7cd32b83 100644 --- a/examples/stm32f0/src/bin/blinky.rs +++ b/examples/stm32f0/src/bin/blinky.rs @@ -2,26 +2,21 @@ #![no_main] #![feature(type_alias_impl_trait)] -use defmt::*; use embassy_executor::Spawner; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_time::{Duration, Timer}; -use {defmt_rtt as _, panic_probe as _}; +use panic_halt as _; // main is itself an async function. #[embassy_executor::main] async fn main(_spawner: Spawner) { let p = embassy_stm32::init(Default::default()); - info!("Hello World!"); //PA5 is the onboard LED on the Nucleo F091RC let mut led = Output::new(p.PA5, Level::High, Speed::Low); loop { - info!("high"); led.set_high(); Timer::after(Duration::from_millis(300)).await; - - info!("low"); led.set_low(); Timer::after(Duration::from_millis(300)).await; }