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:
@@ -7,6 +7,7 @@ firmware := "jiggly"
|
||||
target := "thumbv6m-none-eabi"
|
||||
base_addr := "0x10000000"
|
||||
family_id := "0xE48BFF56"
|
||||
chip := "RP2040"
|
||||
|
||||
out_release := "target" / target / "release" / firmware
|
||||
out_bin := "target" / target / "release" / firmware + ".bin"
|
||||
@@ -99,6 +100,31 @@ flash: uf2
|
||||
echo "Timed out waiting for XIAO UF2 volume. Copy {{ out_uf2 }} manually." >&2
|
||||
exit 1
|
||||
|
||||
# Build the firmware with defmt-over-RTT enabled. Mutually exclusive with
|
||||
# the default `panic-reset` feature, so we drop default features.
|
||||
# DEFMT_LOG=trace overrides the `off` default in mise.toml so the macros
|
||||
# actually emit. Built in release mode because thumbv6m debug builds plus
|
||||
# defmt-rtt + panic-probe overflow flash quickly.
|
||||
build-debug:
|
||||
DEFMT_LOG=trace cargo build --release --no-default-features --features embassy,defmt
|
||||
|
||||
# Flash the defmt firmware via the attached SWD probe and tail RTT logs.
|
||||
# Plug the probe into the four SWD pads on the back of the Xiao
|
||||
# (SWCLK + SWDIO + GND — leave 3V3 disconnected so USB-C powers the board).
|
||||
# The Xiao's own USB-C can stay plugged into a separate host the whole time;
|
||||
# the SWD path and the USB path are independent.
|
||||
debug: build-debug
|
||||
probe-rs run --chip {{ chip }} {{ out_release }}
|
||||
|
||||
# Just tail RTT from a board that's already running the defmt firmware
|
||||
# (no flash). Useful for rejoining a session after Ctrl-C without a reset.
|
||||
attach:
|
||||
probe-rs attach --chip {{ chip }} {{ out_release }}
|
||||
|
||||
# List attached debug probes — sanity check that the DAPLink shows up.
|
||||
probes:
|
||||
probe-rs list
|
||||
|
||||
# Install the toolchain and cargo helpers declared in mise.toml.
|
||||
bootstrap:
|
||||
mise install
|
||||
|
||||
Reference in New Issue
Block a user