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.
20 lines
742 B
Rust
20 lines
742 B
Rust
use std::{env, fs::File, io::Write, path::PathBuf};
|
|
|
|
fn main() {
|
|
let out = PathBuf::from(env::var_os("OUT_DIR").unwrap());
|
|
File::create(out.join("memory.x"))
|
|
.unwrap()
|
|
.write_all(include_bytes!("memory.x"))
|
|
.unwrap();
|
|
println!("cargo:rustc-link-search={}", out.display());
|
|
println!("cargo:rerun-if-changed=memory.x");
|
|
println!("cargo:rerun-if-changed=build.rs");
|
|
|
|
// defmt ships its own linker script (`defmt.x`) that defines the
|
|
// `_defmt_*` interner sections. Only link it when the feature is on —
|
|
// otherwise the symbols don't exist and `ld` will refuse the build.
|
|
if env::var_os("CARGO_FEATURE_DEFMT").is_some() {
|
|
println!("cargo:rustc-link-arg=-Tdefmt.x");
|
|
}
|
|
}
|