/debug. In VS Code, Debug mode also adds a Debug Output tab to the Embedder Monitor.
Prepare
- Build the firmware artifact with debug symbols: an ELF for J-Link or OpenOCD, the CCS debug artifact for TI, or a
.xeapplication for XMOS. - Connect and power the target and probe, or choose the simulator explicitly.
- Run
/debugand ask Embedder to check debugger readiness. - Name the exact MCU, probe, and artifact when the project has several. If the project has more than one platform, Embedder asks which one to debug.
Two other probe guides cover work that isn’t interactive debugging: SEGGER J-Trace for Arm ETM instruction trace and coverage, and probe-rs for programming a board on a remote bridge.
How Embedder picks a debugger
Unless you ask for a specific debugger, Embedder chooses in this order:- The
Debug Interfacevalue in EMBEDDER.md:jlinkselects J-Link, when the SEGGER software is installed.st-linkorcmsis-dapselects OpenOCD with that adapter.xgdbselects XMOS xgdb. An XMOS platform or a.embedder/xmos.jsonfile selects it too.xds110,xds100,xds100v1,xds100v2,xds100v3, orccsselects TI CCS.
- A connected J-Link probe, when the J-Link software is installed.
- OpenOCD. If no OpenOCD is installed, Embedder downloads its own copy on supported hosts.
Choose programming or attachment
Embedder asks you to approve before it starts a debug server or runs a debugging script, unless your approval settings already allow it. Check the request before you approve: approving is what lets Embedder program or halt the target. Say which behavior you want. The options also appear as arguments in hardware scripts:
XMOS behaves differently: no-halt continues execution after connecting, which can resume a halted fault. See XMOS xTAG and xgdb.
Program a fresh debug run
main within about 5 seconds, Embedder halts it where it is. Check the reported stop location before you rely on the result.
Attach to a running target
Use attach-only with no-halt to look at firmware that’s already running, such as a board that just faulted. These options control what Embedder requests. They don’t guarantee that every probe and target configuration leaves execution untouched during startup. Before connecting to a live fault:- Check the setup guide for your probe, and reuse an existing debugger session where possible.
- State whether a reset or halt is acceptable.
- Expect to halt the target to read state. Registers, memory, and the stack are read from a halted target, so a running target has to be interrupted first.
Inspect a fault
For a Cortex-M target with aHardFault_Handler symbol:
- Breakpoints by function, file and line, or address.
- Continue, interrupt, step, step over, and step out.
- Stack frames and local variables.
- Register and memory reads, and expression evaluation.
- Thread or RTOS task information, when available.
gdb.breakpoint() in a hardware script. Embedder doesn’t add a debugger to VS Code’s Run and Debug view, and it doesn’t use breakpoints you set in the editor gutter.
A task view depends on the debugger and firmware providing enough information. Variables that are optimized out may need a debug build. TI CCS sessions have no thread or task view, and whether they show the call stack depends on the probe and CCS version; see Supported probes.
Verify peripheral state
Script helpers
For a repeatable check, a hardware script opens the connection withgdb.jlink_connect(), gdb.openocd_connect(), gdb.ccs_connect(), or gdb.xmos_connect(). Each probe’s guide lists the connection options. These helpers then control and inspect the target:
gdb.jlink_connect(), gdb.openocd_connect(), or gdb.ccs_connect(), these helpers are available too. Other debuggers report them as unsupported.
Breakpoints belong to the script that set them. Embedder removes them when the script exits, including after a failure. J-Link exposes the
"default" reset. OpenOCD exposes "halt" and "init", and resets all configured targets. On J-Link and OpenOCD, a reset leaves the target halted, so call gdb.resume() to run. CCS lists the resets its runtime offers.
Finish cleanly
Tell Embedder whether to leave the firmware running or halted, then ask it to disconnect. Other probe operations take over the probe:- Flashing closes an open debugger session first.
- A J-Trace capture closes open debugger and RTT sessions before it starts.
Troubleshoot
- No debug server found: install the J-Link software, or let Embedder download OpenOCD on a supported host. If that download fails or your host isn’t supported, install OpenOCD yourself. See the guide for your probe.
- Target not found: check power, probe wiring, device spelling, and the selected interface.
- OpenOCD can’t match the MCU: use the exact target configuration. Don’t substitute a nearby family.
- Several platforms: name the MCU you want to debug.
- Probe busy: close competing debug applications, stop the active hardware task, or run
/hardware-queueto check other chats. - Target is running: ask Embedder to interrupt it before reading registers, memory, or the stack.
- Wrong symbols: use the debug artifact from the firmware build that’s on the board.
- Variable unavailable: check debug information and optimization settings.