feat: defmt-over-RTT debug build + probe-rs flow

Add an opt-in `defmt` feature that swaps panic-reset for panic-probe,
links defmt-rtt, and enables hsmc's `trace-defmt` so chart transitions
print over RTT. Default builds are unchanged (still panic-reset, no
defmt overhead).

- Cargo.toml: `defmt` feature pulls defmt + defmt-rtt + panic-probe
  and forwards `trace-defmt` to hsmc; mirror-flag pattern matches
  the existing `embassy` feature.
- build.rs: link `defmt.x` only when the feature is on.
- src/main.rs: cfg-gate the panic handler swap, log boot, USB
  serial, kbd/mouse wake completion vs. deadline, and jiggle dx/dy.
- main.rs: watchdog.pause_on_debug(true) so probe-rs halts don't
  trip the 8 s reset.
- justfile: build-debug, debug, attach, probes recipes
  (release mode — debug builds overflow flash with defmt+panic-probe).
- mise.toml: add cargo:probe-rs-tools.
This commit is contained in:
2026-05-04 12:57:31 -06:00
parent d0d9c451aa
commit 8cb071b132
6 changed files with 197 additions and 7 deletions
Generated
+93 -2
View File
@@ -86,6 +86,12 @@ version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2d7e60934ceec538daadb9d8432424ed043a904d8e0243f3c6446bce549a46ac"
[[package]]
name = "bitflags"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "bitflags"
version = "2.11.1"
@@ -262,6 +268,57 @@ version = "0.3.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f578e8e2c440e7297e008bb5486a3a8a194775224bbc23729b0dbdfaeebf162e"
[[package]]
name = "defmt"
version = "0.3.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0963443817029b2024136fc4dd07a5107eb8f977eaf18fcd1fdeb11306b64ad"
dependencies = [
"defmt 1.0.1",
]
[[package]]
name = "defmt"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "548d977b6da32fa1d1fda2876453da1e7df63ad0304c8b3dae4dbe7b96f39b78"
dependencies = [
"bitflags 1.3.2",
"defmt-macros",
]
[[package]]
name = "defmt-macros"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d4fc12a85bcf441cfe44344c4b72d58493178ce635338a3f3b78943aceb258e"
dependencies = [
"defmt-parser",
"proc-macro-error2",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "defmt-parser"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10d60334b3b2e7c9d91ef8150abfb6fa4c1c39ebbcf4a81c2e346aad939fee3e"
dependencies = [
"thiserror",
]
[[package]]
name = "defmt-rtt"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c6eca0aae8aa2cf8333200ecbd236274697bc0a394765c858b3d9372eb1abcfa"
dependencies = [
"critical-section",
"defmt 0.3.100",
]
[[package]]
name = "digest"
version = "0.10.7"
@@ -472,7 +529,7 @@ version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a25746d8b152b72fbf2a217f489a083dbbe243f281f09184a1f2cfbe9bbb245f"
dependencies = [
"bitflags",
"bitflags 2.11.1",
"embassy-futures",
"embassy-net-driver-channel",
"embassy-sync",
@@ -722,6 +779,7 @@ version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "497ed9593e4baf6ef120b24aff80cb898f6832d32cdf01be9d90be0c06624e77"
dependencies = [
"defmt 0.3.100",
"embassy-futures",
"embassy-sync",
"embassy-time",
@@ -771,6 +829,8 @@ version = "0.2.0"
dependencies = [
"cortex-m",
"cortex-m-rt",
"defmt 0.3.100",
"defmt-rtt",
"embassy-executor",
"embassy-futures",
"embassy-rp",
@@ -779,6 +839,7 @@ dependencies = [
"embassy-usb",
"hsmc",
"libm",
"panic-probe",
"panic-reset",
"portable-atomic",
"smart-leds",
@@ -960,6 +1021,16 @@ version = "1.21.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
[[package]]
name = "panic-probe"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4047d9235d1423d66cc97da7d07eddb54d4f154d6c13805c6d0793956f4f25b0"
dependencies = [
"cortex-m",
"defmt 0.3.100",
]
[[package]]
name = "panic-reset"
version = "0.1.1"
@@ -1150,7 +1221,7 @@ version = "0.5.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d"
dependencies = [
"bitflags",
"bitflags 2.11.1",
]
[[package]]
@@ -1420,6 +1491,26 @@ dependencies = [
"winapi-util",
]
[[package]]
name = "thiserror"
version = "2.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "2.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "thread_local"
version = "1.1.9"