crosspad_trace
Trace STM32G0B1 firmware variables in real time over ST-Link SWD without halting the CPU. Start a trace, add or remove signals, read recent samples, and export captures to CSV.
Instructions
[STM HW] Real-time SWD trace of STM32G0B1 firmware variables over ST-Link: non-halting RAM polling of variables resolved from the Debug ELF (like ST-Studio/CubeMonitor). Pick an action: doctor (environment precheck -> issues[]; run first, resolve them, then config_set), config_set (persist a path/serial to ~/.config/crosspad-mcp/config.json), symbols (list/search traceable variables, query optional), start (begin a background trace: signals[], rate_hz), stop, add/remove (change the live signal set of the active trace), status (device_state running/stop_suspected/exited, sample_count, actual_fs, signals), read (recent samples downsampled with per-signal stats; cheap), save (export the buffer to CSV, returns file_path), device_state (deep low-power/STOP register dump), ui (the localhost dashboard URL), plus write and call, which are danger tier and need confirmation. Signal names accept array indexing, e.g. 's_inputs[0]', 's_adc_raw[3]'.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"action": "<action>"
},
"name": "crosspad_trace"
}
}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. | |
| confirm_token | No | write/call: token from a previous confirmation_required result. Re-issue the identical call with it to proceed. Each token is good for exactly one call. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ok | No | ||
| r0 | No | call: the function's return register. | |
| key | No | ||
| docs | No | ||
| hint | No | ||
| next | No | ||
| tool | No | ||
| error | No | ||
| stats | No | ||
| action | No | ||
| issues | No | ||
| notice | No | ||
| series | No | ||
| ui_url | No | ||
| decoded | No | call: r0 decoded as ret_type, when that is not u32. | |
| outcome | No | ||
| results | No | write: one entry per target=value written. | |
| signals | No | ||
| success | Yes | ||
| symbols | No | ||
| actual_fs | No | ||
| file_path | No | ||
| elicitation | No | ||
| stderr_tail | No | ||
| confirmation | No | ||
| device_state | No | ||
| sample_count | No |