crosspad_trace
Trace STM32 firmware variables in real time via SWD polling: start, stop, add or remove signals, read samples, and export data to CSV for debugging and analysis.
Instructions
[STM HW] Real-time SWD tracer for the STM32G0B1 firmware (ST-Link). Non-halting RAM polling of firmware variables resolved from the Debug ELF (like ST-Studio/CubeMonitor). Pick an action:
• doctor → environment precheck → issues[] (run this FIRST; resolve issues, then config_set).
• config_set → persist a resolved path/serial to ~/.config/crosspad-mcp/config.json (key,value).
• symbols → list/search traceable variables from the ELF (query optional).
• start → begin a background trace (signals[], rate_hz).
• stop → end the active trace.
• add/remove → mutate the live poll set of the active trace (signals[]); returns the current signal set.
• status → device_state (running/stop_suspected/exited), sample_count, actual_fs, signals.
• read → recent samples downsampled + per-signal stats (cheap; safe for the LLM).
• save → export the in-memory buffer to CSV (returns file_path).
• device_state → deep low-power/STOP register dump.
• ui → returns the localhost dashboard URL.
Signal names accept array indexing, e.g. 's_inputs[0]', 's_adc_raw[3]'.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| key | No | config_set: one of stm_elf_path|pyocd_python|probe_serial|trace_dir|ui_open|stm_programmer_cli. stm_programmer_cli = path to STM32_Programmer_CLI for crosspad_flash target=stm. ui_open ∈ vscode(default: reply with the link → user clicks → opens in the VS Code Simple Browser; system-browser fallback after 30s if unopened)|browser(open system browser immediately)|none(never auto-open). | |
| swo | No | start (EXPERIMENTAL): map ITM stimulus ports to signal names, e.g. ['0:phase','1:isr_us']. Requires firmware that emits ITM on the SWO pin (NOT present in current CrossPad firmware — UNTESTED against real ITM). Omit for plain RAM polling. Fails soft: if SWV init fails, polling continues normally. | |
| args | No | call: up to 4 integer args → r0-r3. | |
| func | No | call: firmware function symbol to invoke (AAPCS). | |
| query | No | symbols: case-insensitive substring filter. | |
| value | No | config_set: the value to persist. | |
| action | Yes | Required params per action — doctor/stop/status/device_state/ui: (none); config_set: key,value; symbols: query?; start: signals[],rate_hz?; add/remove: signals[]; read: window_from?,window_to?,max_points?; save: format?; write: writes[]; call: func,args?,confirm,ret_type?,timeout?. | |
| format | No | save: export format (csv). | |
| writes | No | write: list of 'target=value' specs. target = @0xADDR[:type] (u8|u16|u32|i8|i16|i32|f32, default u32) or a DWARF symbol; value = hex 0x.. or decimal (float for f32). e.g. ['@0x50000414:u16=0xFFFF','s_vbat_mv=4200']. Allowlist: SRAM/peripheral/PPB only — Code/flash region is blocked. | |
| confirm | No | call: must be true — acknowledges the core is halted for the call. | |
| rate_hz | No | start: target sample rate (0 = as fast as the probe allows). Actual Fs is reported. | |
| signals | No | start: variable names from `symbols` (e.g. ['s_vbat_mv','s_inputs[0]']). Also accepts raw @address specs that bypass DWARF — '@0x40021000' (u32), '@0x40021000:u16' (u8|u16|u32|i8|i16|i32|f32), '@0x20000000:u8[16]' (16-element block) — for peripheral registers / arbitrary RAM. | |
| timeout | No | call: max seconds to wait for the function to return (default 2). | |
| ret_type | No | call: decode r0 as this type (default u32; raw r0 always returned). | |
| window_to | No | read: end time (s) of the window. | |
| max_points | No | read: max points per signal (default 200). | |
| window_from | No | read: start time (s) of the window. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ok | No | ||
| key | No | ||
| error | No | ||
| stats | No | ||
| action | No | ||
| issues | No | ||
| series | No | ||
| ui_url | No | ||
| signals | No | ||
| success | Yes | ||
| symbols | No | ||
| actual_fs | No | ||
| file_path | No | ||
| stderr_tail | No | ||
| device_state | No | ||
| sample_count | No |