From 123b96df5e1e8880f16afde0fba8dac8e1d978ae Mon Sep 17 00:00:00 2001 From: Ian Rees Date: Sun, 13 Jul 2025 18:50:31 +1200 Subject: [PATCH 1/8] bsp(metro_m4): Add defmt feature, bump versions --- boards/metro_m4/.cargo/config.toml | 8 ++++++-- boards/metro_m4/Cargo.toml | 6 ++++-- boards/metro_m4/build.rs | 4 ++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/boards/metro_m4/.cargo/config.toml b/boards/metro_m4/.cargo/config.toml index 7efea61cb91b..c39d3026f6bc 100644 --- a/boards/metro_m4/.cargo/config.toml +++ b/boards/metro_m4/.cargo/config.toml @@ -5,10 +5,14 @@ runner = 'probe-rs run --chip ATSAMD51J19A --speed 20000' [build] target = "thumbv7em-none-eabihf" rustflags = [ - # This is needed if your flash or ram addresses are not aligned to 0x10000 in memory.x # See https://github.com/rust-embedded/cortex-m-quickstart/pull/95 "-C", "link-arg=--nmagic", - "-C", "link-arg=-Tdefmt.x", # uncomment if using defmt + + # To use defmt, the linker needs to be provided with this argument. The BSP + # uses build.rs to supply it conditionally, or uncomment this line to use it + # unconditionally. + # "-C", "link-arg=-Tdefmt.x", + "-C", "link-arg=-Tlink.x", ] diff --git a/boards/metro_m4/Cargo.toml b/boards/metro_m4/Cargo.toml index 79df242185dc..0bb3fe3910e4 100644 --- a/boards/metro_m4/Cargo.toml +++ b/boards/metro_m4/Cargo.toml @@ -34,8 +34,8 @@ version = "0.7" [dev-dependencies] cortex-m = "0.7" cortex-m-semihosting = "0.3" -defmt = "0.3" -defmt-rtt = "0.4" +defmt = "1.0.1" +defmt-rtt = "1.0.0" embassy-executor = {version = "0.6.2", features = ["arch-cortex-m", "executor-thread", "task-arena-size-8192"]} embedded-hal = "1.0" embedded-hal-nb = "1.0" @@ -57,6 +57,8 @@ version = "0.3" default = ["rt", "atsamd-hal/samd51j"] # Enable async support from atsamd-hal async = ["atsamd-hal/async"] +# Use DEFMT_LOG environment variable to set logging level, defaults to `error` +defmt = ["atsamd-hal/defmt"] dma = ["atsamd-hal/dma"] max-channels = ["dma", "atsamd-hal/max-channels"] rt = ["cortex-m-rt", "atsamd-hal/samd51j-rt"] diff --git a/boards/metro_m4/build.rs b/boards/metro_m4/build.rs index 4bed4688f2c0..35a8df58c9ff 100644 --- a/boards/metro_m4/build.rs +++ b/boards/metro_m4/build.rs @@ -12,5 +12,9 @@ fn main() { println!("cargo:rustc-link-search={}", out.display()); println!("cargo:rerun-if-changed=memory.x"); } + if env::var_os("CARGO_FEATURE_DEFMT").is_some() { + println!("cargo:rustc-link-arg=-Tdefmt.x"); + } + println!("cargo:rerun-if-changed=build.rs"); } From 179eef7ae7e0b72617cd39687c0a9acd38bcb22d Mon Sep 17 00:00:00 2001 From: Ian Rees Date: Sun, 13 Jul 2025 19:02:30 +1200 Subject: [PATCH 2/8] bsp(grand_central_m4): Add defmt feature --- boards/grand_central_m4/.cargo/config.toml | 6 +++++- boards/grand_central_m4/Cargo.toml | 2 ++ boards/grand_central_m4/build.rs | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/boards/grand_central_m4/.cargo/config.toml b/boards/grand_central_m4/.cargo/config.toml index b2b4fb32f134..45ea67014e5e 100644 --- a/boards/grand_central_m4/.cargo/config.toml +++ b/boards/grand_central_m4/.cargo/config.toml @@ -6,10 +6,14 @@ runner = 'arm-none-eabi-gdb' [build] target = "thumbv7em-none-eabihf" rustflags = [ - # This is needed if your flash or ram addresses are not aligned to 0x10000 in memory.x # See https://github.com/rust-embedded/cortex-m-quickstart/pull/95 "-C", "link-arg=--nmagic", + # To use defmt, the linker needs to be provided with this argument. The BSP + # uses build.rs to supply it conditionally, or uncomment this line to use it + # unconditionally. + # "-C", "link-arg=-Tdefmt.x", + "-C", "link-arg=-Tlink.x", ] diff --git a/boards/grand_central_m4/Cargo.toml b/boards/grand_central_m4/Cargo.toml index 931b14403da5..43b87a872747 100644 --- a/boards/grand_central_m4/Cargo.toml +++ b/boards/grand_central_m4/Cargo.toml @@ -36,6 +36,8 @@ ws2812-timer-delay = "0.3" [features] default = ["rt", "atsamd-hal/samd51p"] +# Use DEFMT_LOG environment variable to set logging level, defaults to `error` +defmt = ["atsamd-hal/defmt"] dma = ["atsamd-hal/dma"] max-channels = ["dma", "atsamd-hal/max-channels"] rt = ["cortex-m-rt", "atsamd-hal/samd51p-rt"] diff --git a/boards/grand_central_m4/build.rs b/boards/grand_central_m4/build.rs index 4bed4688f2c0..6246961518c5 100644 --- a/boards/grand_central_m4/build.rs +++ b/boards/grand_central_m4/build.rs @@ -12,5 +12,8 @@ fn main() { println!("cargo:rustc-link-search={}", out.display()); println!("cargo:rerun-if-changed=memory.x"); } + if env::var_os("CARGO_FEATURE_DEFMT").is_some() { + println!("cargo:rustc-link-arg=-Tdefmt.x"); + } println!("cargo:rerun-if-changed=build.rs"); } From 9f2bc3f50db952a73d4b4df474a58d5428a7ed95 Mon Sep 17 00:00:00 2001 From: Ian Rees Date: Sun, 13 Jul 2025 19:39:45 +1200 Subject: [PATCH 3/8] bsp(metro_m0): Add defmt feature --- boards/metro_m0/.cargo/config.toml | 8 ++++++-- boards/metro_m0/Cargo.toml | 2 ++ boards/metro_m0/build.rs | 3 +++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/boards/metro_m0/.cargo/config.toml b/boards/metro_m0/.cargo/config.toml index 75cea149ac17..50929923aa79 100644 --- a/boards/metro_m0/.cargo/config.toml +++ b/boards/metro_m0/.cargo/config.toml @@ -8,10 +8,14 @@ runner = 'arm-none-eabi-gdb' #runner = 'probe-run --chip ATSAMD21G18A' rustflags = [ - # This is needed if your flash or ram addresses are not aligned to 0x10000 in memory.x # See https://github.com/rust-embedded/cortex-m-quickstart/pull/95 "-C", "link-arg=--nmagic", - + + # To use defmt, the linker needs to be provided with this argument. The BSP + # uses build.rs to supply it conditionally, or uncomment this line to use it + # unconditionally. + # "-C", "link-arg=-Tdefmt.x", + "-C", "link-arg=-Tlink.x", ] diff --git a/boards/metro_m0/Cargo.toml b/boards/metro_m0/Cargo.toml index b485c1154cae..2633f9b97f6c 100644 --- a/boards/metro_m0/Cargo.toml +++ b/boards/metro_m0/Cargo.toml @@ -45,6 +45,8 @@ usbd-serial = "0.2" [features] # ask the HAL to enable atsamd21g support default = ["rt", "atsamd-hal/samd21g"] +# Use DEFMT_LOG environment variable to set logging level, defaults to `error` +defmt = ["atsamd-hal/defmt"] dma = ["atsamd-hal/dma"] max-channels = ["dma", "atsamd-hal/max-channels"] # Enable async support from atsamd-hal diff --git a/boards/metro_m0/build.rs b/boards/metro_m0/build.rs index 4bed4688f2c0..6246961518c5 100644 --- a/boards/metro_m0/build.rs +++ b/boards/metro_m0/build.rs @@ -12,5 +12,8 @@ fn main() { println!("cargo:rustc-link-search={}", out.display()); println!("cargo:rerun-if-changed=memory.x"); } + if env::var_os("CARGO_FEATURE_DEFMT").is_some() { + println!("cargo:rustc-link-arg=-Tdefmt.x"); + } println!("cargo:rerun-if-changed=build.rs"); } From 3f21d1cfa52ebfeccf6e1ab4ba1930f4dc698374 Mon Sep 17 00:00:00 2001 From: Ian Rees Date: Sun, 13 Jul 2025 19:41:56 +1200 Subject: [PATCH 4/8] bsp(samd11_bare): Add defmt feature --- boards/samd11_bare/.cargo/config.toml | 6 +++++- boards/samd11_bare/Cargo.toml | 2 ++ boards/samd11_bare/build.rs | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/boards/samd11_bare/.cargo/config.toml b/boards/samd11_bare/.cargo/config.toml index 58d2e321b41e..ec6d8cf518b0 100644 --- a/boards/samd11_bare/.cargo/config.toml +++ b/boards/samd11_bare/.cargo/config.toml @@ -6,10 +6,14 @@ target = "thumbv6m-none-eabi" [target.thumbv6m-none-eabi] runner = 'probe-run --chip ATSAMD11C14A' rustflags = [ - # This is needed if your flash or ram addresses are not aligned to 0x10000 in memory.x # See https://github.com/rust-embedded/cortex-m-quickstart/pull/95 "-C", "link-arg=--nmagic", + # To use defmt, the linker needs to be provided with this argument. The BSP + # uses build.rs to supply it conditionally, or uncomment this line to use it + # unconditionally. + # "-C", "link-arg=-Tdefmt.x", + "-C", "link-arg=-Tlink.x", ] diff --git a/boards/samd11_bare/Cargo.toml b/boards/samd11_bare/Cargo.toml index 1d06909ef5e8..339dc38dca0f 100644 --- a/boards/samd11_bare/Cargo.toml +++ b/boards/samd11_bare/Cargo.toml @@ -42,6 +42,8 @@ rtt-target = {version = "0.3.0", features = ["cortex-m"]} [features] # ask the HAL to enable atsamd11c support default = ["rt", "atsamd-hal/samd11c"] +# Use DEFMT_LOG environment variable to set logging level, defaults to `error` +defmt = ["atsamd-hal/defmt"] dma = ["atsamd-hal/dma"] max-channels = ["dma", "atsamd-hal/max-channels"] # Enable async support from atsamd-hal diff --git a/boards/samd11_bare/build.rs b/boards/samd11_bare/build.rs index 4bed4688f2c0..6246961518c5 100644 --- a/boards/samd11_bare/build.rs +++ b/boards/samd11_bare/build.rs @@ -12,5 +12,8 @@ fn main() { println!("cargo:rustc-link-search={}", out.display()); println!("cargo:rerun-if-changed=memory.x"); } + if env::var_os("CARGO_FEATURE_DEFMT").is_some() { + println!("cargo:rustc-link-arg=-Tdefmt.x"); + } println!("cargo:rerun-if-changed=build.rs"); } From 60922602da5381645770c600a71ce954e926853e Mon Sep 17 00:00:00 2001 From: Ian Rees Date: Sun, 13 Jul 2025 19:42:37 +1200 Subject: [PATCH 5/8] bsp(feather_m0): Add defmt feature, bump versions --- boards/feather_m0/.cargo/config.toml | 6 +++++- boards/feather_m0/Cargo.toml | 8 +++++--- boards/feather_m0/build.rs | 3 +++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/boards/feather_m0/.cargo/config.toml b/boards/feather_m0/.cargo/config.toml index e209d0667d77..630952c4f626 100644 --- a/boards/feather_m0/.cargo/config.toml +++ b/boards/feather_m0/.cargo/config.toml @@ -7,7 +7,11 @@ rustflags = [ # See https://github.com/rust-embedded/cortex-m-quickstart/pull/95 "-C", "link-arg=--nmagic", "-C", "link-arg=-Tlink.x", - "-C", "link-arg=-Tdefmt.x" # uncomment if using defmt + + # To use defmt, the linker needs to be provided with this argument. The BSP + # uses build.rs to supply it conditionally, or uncomment this line to use it + # unconditionally. + # "-C", "link-arg=-Tdefmt.x", ] [target.thumbv6m-none-eabi] diff --git a/boards/feather_m0/Cargo.toml b/boards/feather_m0/Cargo.toml index 81afb47d90b0..0bb3b083a91c 100644 --- a/boards/feather_m0/Cargo.toml +++ b/boards/feather_m0/Cargo.toml @@ -44,8 +44,8 @@ version = "0.3" [dev-dependencies] cortex-m = "0.7" cortex-m-semihosting = "0.3" -defmt = "0.3" -defmt-rtt = "0.4" +defmt = "1.0.1" +defmt-rtt = "1.0.0" drogue-nom-utils = "0.1" embassy-executor = {version = "0.6.2", features = ["arch-cortex-m", "executor-thread", "task-arena-size-64"]} embedded-graphics = "0.7.1" @@ -61,6 +61,8 @@ usbd-serial = "0.2" [features] # ask the HAL to enable atsamd21g support default = ["rt", "atsamd-hal/samd21g"] +# Use DEFMT_LOG environment variable to set logging level, defaults to `error` +defmt = ["atsamd-hal/defmt"] rt = ["cortex-m-rt", "atsamd-hal/samd21g-rt"] usb = ["atsamd-hal/usb", "usb-device"] use_rtt = ["atsamd-hal/use_rtt"] @@ -113,7 +115,7 @@ required-features = ["async"] [[example]] name = "async_uart" -required-features = ["dma", "async"] +required-features = ["defmt", "dma", "async"] [[example]] name = "blinky_basic" diff --git a/boards/feather_m0/build.rs b/boards/feather_m0/build.rs index 4bed4688f2c0..6246961518c5 100644 --- a/boards/feather_m0/build.rs +++ b/boards/feather_m0/build.rs @@ -12,5 +12,8 @@ fn main() { println!("cargo:rustc-link-search={}", out.display()); println!("cargo:rerun-if-changed=memory.x"); } + if env::var_os("CARGO_FEATURE_DEFMT").is_some() { + println!("cargo:rustc-link-arg=-Tdefmt.x"); + } println!("cargo:rerun-if-changed=build.rs"); } From 0cf4941953f771e3172d7b7fe2c366781a2ecae4 Mon Sep 17 00:00:00 2001 From: Ian Rees Date: Sun, 13 Jul 2025 19:45:47 +1200 Subject: [PATCH 6/8] bsp(feather_m4): Add defmt feature --- boards/feather_m4/.cargo/config.toml | 6 +++++- boards/feather_m4/Cargo.toml | 2 ++ boards/feather_m4/build.rs | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/boards/feather_m4/.cargo/config.toml b/boards/feather_m4/.cargo/config.toml index 942f699cd70c..d64a9e55854c 100644 --- a/boards/feather_m4/.cargo/config.toml +++ b/boards/feather_m4/.cargo/config.toml @@ -6,10 +6,14 @@ runner = 'arm-none-eabi-gdb' [build] target = "thumbv7em-none-eabihf" rustflags = [ - # This is needed if your flash or ram addresses are not aligned to 0x10000 in memory.x # See https://github.com/rust-embedded/cortex-m-quickstart/pull/95 "-C", "link-arg=--nmagic", + # To use defmt, the linker needs to be provided with this argument. The BSP + # uses build.rs to supply it conditionally, or uncomment this line to use it + # unconditionally. + # "-C", "link-arg=-Tdefmt.x", + "-C", "link-arg=-Tlink.x", ] diff --git a/boards/feather_m4/Cargo.toml b/boards/feather_m4/Cargo.toml index cb9e61f21f5f..0dd467fe88d5 100644 --- a/boards/feather_m4/Cargo.toml +++ b/boards/feather_m4/Cargo.toml @@ -45,6 +45,8 @@ ws2812-timer-delay = "0.3" [features] # ask the HAL to enable atsamd51j support default = ["rt", "atsamd-hal/samd51j"] +# Use DEFMT_LOG environment variable to set logging level, defaults to `error` +defmt = ["atsamd-hal/defmt"] dma = ["atsamd-hal/dma"] max-channels = ["dma", "atsamd-hal/dma"] rt = ["cortex-m-rt", "atsamd-hal/samd51j-rt"] diff --git a/boards/feather_m4/build.rs b/boards/feather_m4/build.rs index 4bed4688f2c0..6246961518c5 100644 --- a/boards/feather_m4/build.rs +++ b/boards/feather_m4/build.rs @@ -12,5 +12,8 @@ fn main() { println!("cargo:rustc-link-search={}", out.display()); println!("cargo:rerun-if-changed=memory.x"); } + if env::var_os("CARGO_FEATURE_DEFMT").is_some() { + println!("cargo:rustc-link-arg=-Tdefmt.x"); + } println!("cargo:rerun-if-changed=build.rs"); } From c08f65a8d3258cda3d4f52803bf48dfb6357a269 Mon Sep 17 00:00:00 2001 From: Ian Rees Date: Sun, 13 Jul 2025 19:46:49 +1200 Subject: [PATCH 7/8] bsp(pygamer): Add defmt feature --- boards/pygamer/.cargo/config.toml | 6 +++++- boards/pygamer/Cargo.toml | 2 ++ boards/pygamer/build.rs | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/boards/pygamer/.cargo/config.toml b/boards/pygamer/.cargo/config.toml index 0e18fe5b3bc3..2b211887070e 100644 --- a/boards/pygamer/.cargo/config.toml +++ b/boards/pygamer/.cargo/config.toml @@ -6,10 +6,14 @@ runner = "hf2 elf" [build] target = "thumbv7em-none-eabihf" rustflags = [ - # This is needed if your flash or ram addresses are not aligned to 0x10000 in memory.x # See https://github.com/rust-embedded/cortex-m-quickstart/pull/95 "-C", "link-arg=--nmagic", + # To use defmt, the linker needs to be provided with this argument. The BSP + # uses build.rs to supply it conditionally, uncomment this line to use it + # unconditionally. + # "-C", "link-arg=-Tdefmt.x", + "-C", "link-arg=-Tlink.x", ] diff --git a/boards/pygamer/Cargo.toml b/boards/pygamer/Cargo.toml index 4044a6d164ac..7fde6d6ae761 100644 --- a/boards/pygamer/Cargo.toml +++ b/boards/pygamer/Cargo.toml @@ -52,6 +52,8 @@ usbd-serial = "0.2" [features] # ask the HAL to enable atsamd51j support default = ["rt", "atsamd-hal/samd51j"] +# Use DEFMT_LOG environment variable to set logging level, defaults to `error` +defmt = ["atsamd-hal/defmt"] dma = ["atsamd-hal/dma"] max-channels = ["dma", "atsamd-hal/max-channels"] neopixel-spi = ["dep:ws2812-spi"] diff --git a/boards/pygamer/build.rs b/boards/pygamer/build.rs index 4bed4688f2c0..6246961518c5 100644 --- a/boards/pygamer/build.rs +++ b/boards/pygamer/build.rs @@ -12,5 +12,8 @@ fn main() { println!("cargo:rustc-link-search={}", out.display()); println!("cargo:rerun-if-changed=memory.x"); } + if env::var_os("CARGO_FEATURE_DEFMT").is_some() { + println!("cargo:rustc-link-arg=-Tdefmt.x"); + } println!("cargo:rerun-if-changed=build.rs"); } From a2ee483938812923b2dbad7e29bc547c4462388b Mon Sep 17 00:00:00 2001 From: Ian Rees Date: Sun, 13 Jul 2025 19:48:20 +1200 Subject: [PATCH 8/8] bsp(atsame54_xpro): Add defmt feature --- boards/atsame54_xpro/.cargo/config.toml | 6 +++++- boards/atsame54_xpro/Cargo.toml | 2 ++ boards/atsame54_xpro/build.rs | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/boards/atsame54_xpro/.cargo/config.toml b/boards/atsame54_xpro/.cargo/config.toml index 4b9346206cf1..8b2a51e00c88 100644 --- a/boards/atsame54_xpro/.cargo/config.toml +++ b/boards/atsame54_xpro/.cargo/config.toml @@ -5,10 +5,14 @@ runner = 'arm-none-eabi-gdb' [build] target = "thumbv7em-none-eabihf" rustflags = [ - # This is needed if your flash or ram addresses are not aligned to 0x10000 in memory.x # See https://github.com/rust-embedded/cortex-m-quickstart/pull/95 "-C", "link-arg=--nmagic", + # To use defmt, the linker needs to be provided with this argument. The BSP + # uses build.rs to supply it conditionally, uncomment this line to use it + # unconditionally. + # "-C", "link-arg=-Tdefmt.x", + "-C", "link-arg=-Tlink.x", ] diff --git a/boards/atsame54_xpro/Cargo.toml b/boards/atsame54_xpro/Cargo.toml index eafd323a3089..0ee22c58f07c 100644 --- a/boards/atsame54_xpro/Cargo.toml +++ b/boards/atsame54_xpro/Cargo.toml @@ -38,6 +38,8 @@ rtt-target = {version = "0.3", features = ["cortex-m"]} [features] default = ["rt", "atsamd-hal/same54p"] +# Use DEFMT_LOG environment variable to set logging level, defaults to `error` +defmt = ["atsamd-hal/defmt"] dma = ["atsamd-hal/dma"] max-channels = ["dma", "atsamd-hal/max-channels"] # Enable async support from atsamd-hal diff --git a/boards/atsame54_xpro/build.rs b/boards/atsame54_xpro/build.rs index 4bed4688f2c0..6246961518c5 100644 --- a/boards/atsame54_xpro/build.rs +++ b/boards/atsame54_xpro/build.rs @@ -12,5 +12,8 @@ fn main() { println!("cargo:rustc-link-search={}", out.display()); println!("cargo:rerun-if-changed=memory.x"); } + if env::var_os("CARGO_FEATURE_DEFMT").is_some() { + println!("cargo:rustc-link-arg=-Tdefmt.x"); + } println!("cargo:rerun-if-changed=build.rs"); }