Skip to content
| Marketplace
Sign in
Visual Studio Code>Debuggers>XFlashGate MCU DebugNew to Visual Studio Code? Get it now.
XFlashGate MCU Debug

XFlashGate MCU Debug

X-Cheng

|
25 installs
| (0) | Free
MCU debugging with XFlashGate: GDB/J-Link, flash algorithms, RTT, Live Watch, FreeRTOS, and crash analysis.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

XFlashGate MCU Debug

English / 中文 illustrated guides are included in the extension. Run XFlashGate: User Guide to open the guide offline in your VS Code display language.

New in 0.5.4

Cooperative RTT now completes its data and stop confirmation before a direct VS Code disconnect ends GDB. New input is blocked during disconnect. Compatible downloader firmware can also prove that the original private session has closed; failed or missing proof remains visible. MCP identifies stopped RTT caches by their original source/session and keeps them historical when a new debug session starts.

The experimental CH569 running RTT path requires explicitly cooperating target code, a matching ELF and initialization breakpoint, and the downloader's declared protocol. It does not provide arbitrary background SRAM access for ordinary firmware. System VS Code checks cover preemptive FreeRTOS, bidirectional input, direct disconnect and the next session; real AI checks cover task/stack sources, empty and nonempty RTT increments, and the closed-session cache. See the test scope and remaining limits.

TCP keepalive tolerance and GDB trace redaction are companion firmware changes. They are not installed by a VSIX update. Their development branch retains separate production resource gates; the temporary test downloader was restored to its original firmware. ISP remains deferred.

Run XFlashGate: Offline Download Status from the sidebar or Command Palette to inspect the downloader's current directory, saved variant, execution errors and recovery state. Traditional firmware.json directories and firmware .flpkg / .fgpkg files are shown separately. Read-only MCP get_offline_download_status provides the same information. Select and program in the downloader UI or existing management client; algorithm adaptation packages are distinct from firmware packages. Device success is not independent full physical readback, and idle does not prove the previous operation succeeded.

When the downloader declares the independent algorithm compatibility policy, a firmware release increment does not require replacing or re-signing an existing algorithm package. The extension checks declared container, manifest and algorithm ABI support; device API, preparation, signature, target and parameter checks remain mandatory when loading. Exact package identities stay pinned. Missing or unknown policy declarations do not enable this behavior. Selection and verified loading do not establish successful physical programming.

TF algorithm selection displays transfer progress and supports cancellation. Its total limit is 60 seconds plus the declared file size at 8 KiB/s, capped at 15 minutes; 30 seconds without data also stops the read. A canceled or timed-out read preserves the previous selection and does not load an algorithm or operate the target. Check Wi-Fi and TF read speed before trying again.

Use XFlashGate: Target / Cores to select a project debug configuration, configure device-declared cores, or attach through an external Xtensa GDB server. CMake owns compilation and ELF outputs; each debug configuration selects its ELF, GDB and core. Chip-specific register models and shared-resource checks belong to registered target adapters. No chip-specific entries are permanently added to the sidebar. See the English/中文 configuration guide and validation limits.

The buildable RT685 M33 + HiFi4 RAM example supplies two matching ELFs, independent heartbeat loops and explicit backup/restoration instructions. Independent concurrent sessions require the downloader's explicit shared-core contract; otherwise use supported single-core sessions. Loading this sample is a deliberate test operation, not part of Attach. The target-picker refactor does not establish new hardware acceptance results.

Debug MCU source code through an ESP-DAP device in Visual Studio Code. Version 0.4.5 adds RTT down-channel preparation while the MCU keeps running in eligible direct-GDB running-attach sessions. Running attach, compact RTT controls, host receive timestamps, color rules, incremental RTT access through AI/MCP, verified Flash programming, backed-up RAM launch and built-in analysis views remain available.

The interface follows VS Code's display language: Chinese for Chinese locales, English otherwise. Commands, settings, panels and analysis reports use the same language. MCU logs, variable values, source code and user input retain their original content.

New in 0.5.0

macOS Intel and Apple silicon packages join Windows x64. Tool discovery supports Homebrew and CMake.app, and connection/tool failures include the failing step and recovery instructions. Attach Running (No Reset) has its own command and F5 entry. RTT can start and prepare input automatically with debugging; routine connection details are folded away. Live Watch now negotiates running attach correctly and rebuilds its observer after the first manual pause.

System VS Code checks on Apple silicon cover PowerUnit Boot/App and FreeRTOS RAM samples on MIMXRT685 and STM32N657. Both RTOS samples expose nine tasks, source stacks/locals, up0/down1 RTT acknowledgements and offline RAM inspection. RT685 automatic reset/recovery remains limited by the tested board's ineffective nRESET path; the N6 controlled-fault run required a power cycle before recovery. See the 0.5.0 acceptance record for exact evidence and limits.

Fixed in 0.4.9

After the first manual Pause or adoption of a halted session, Continue now waits for owned RTT restoration. This avoids GDB's “Cannot execute this command while the target is running” error. Direct-GDB sessions with device live-memory support can prepare RTT input while running even after Pause/Step/Continue. The main RTT channel still follows its separate setup rules below.

PowerUnit normal-window checks cover automatic recovery, F5/Attach, source and frame variables, disconnect/reconnect, and Configure and Build both during running attach and with no debug session. New info/help replies match in the terminal and MCP, including three repeat peeks per interval. The target remains running and attached; this round performed no reset or programming. See the bounded hardware record.

Fixed in 0.4.8

Ordinary attach and F5 attach automatically reconcile an unfinished direct-GDB session. When the target is already halted, attach adopts the existing state while preserving watchdog freeze and the original recovery values; it does not require a manual recovery step or resume/reset the MCU. Identity, firmware, resource-ownership and readback failures remain visible. Download and RAM launch keep their explicit safeguards. See session lifecycle.

Host builds have their own task state: an attached debugger no longer blocks CMake configuration or builds, repeated clicks join the current build, and a failed build can be retried from the same entry. The running-attach/build combination deferred at 0.4.8 release was subsequently verified in the 0.4.9 hardware record above.

For Boot/App source debugging, load matching ELFs that contain line and variable debug information, including in Release builds. The companion PowerUnit CMake fix retains -Os and LTO while adding -g3; its loaded program bytes were verified unchanged before using the new symbols. A missing debug section cannot be reconstructed by the extension. Select a business-code frame when toolchain library sources are unavailable; optimized-out variables remain unavailable. See the 0.4.8 release record.

Fixed in 0.4.7

Selecting Attach and keep running (pause manually) no longer blocks CMake preview, synchronization, configuration or builds. Generating an alternate J-Link launch entry does not validate that entry as an active debug session. Build actions preserve your selected connection and startup mode; backend compatibility is checked when you actually start debugging. This closes the running-attach configuration case missed in 0.4.6.

New in 0.4.6

CMake preview, synchronization, configuration and build require only the compiler tools, CMake and Ninja; GDB, a connected device and an ELF are not prerequisites. Tool diagnostics check available build tools even when GDB or J-Link is missing. Actual debugging still validates its required debugger. Synchronization also handles localized Git diagnostics for projects outside a repository while retaining protection for tracked local presets.

New in 0.4.5

Select Prepare input beside the RTT input line, enter a command and press Enter. Select a separate down channel under Channel and display settings → Down-channel input (advanced). The configuration page's RTT section offers automatic RTT startup and automatic input preparation independently. Session termination cleans up RTT; reconnection prepares input again without sending commands. A visible hint explains disabled input. If stopped at main before initialization, continue first; running preparation retries at most 10 times, with manual preparation available afterwards. Direct GDB devices declaring debug.gdb_live_memory_while_running=true support running preparation in ordinary sessions and after Pause/Continue. Configured RAM must contain the initialized control block and down buffer; changing layouts are rejected. J-Link and devices without this capability require a manual pause.

For attachment without reset, use XFlashGate: Attach running (no reset) or its generated F5 (gdb) entry. It keeps running even when the workspace saves Boot-to-entry as its startup policy. Start configured debugger follows the saved policy. Pause manually once to enable full source-breakpoint debugging.

The officially installed 0.4.5 passed normal F5 running attach and RTT input preparation on PowerUnit Up0/Down0. New info and help replies reached both the terminal and MCP; three repeat peek reads per reply returned identical bytes without consumption or drops, and the terminal continued receiving the later reply. The session remained running throughout. This verifies that target/channel path; other targets, concurrent nonzero channels and long-duration operation retain their separate qualification. See the official 0.4.5 hardware record, earlier candidate record and input workflow.

Fixed in 0.4.4

RTT input preparation accepts the defined SEGGER RTT identifier and terminating NUL without requiring unused identifier-array bytes to be cleared. This applies to device input and independent J-Link input; channel counts, RAM bounds, buffer descriptors and offsets remain checked. Version 0.4.4 required a manual pause for preparation; the 0.4.5 exception is described above. If a down-channel descriptor lies beyond an older downloader's cached table, compatible downloader firmware is also required; updating the extension alone does not correct that device limit.

Failed RTT startup also reconciles monitor status when the welcome marker times out. It recognizes an already-closed monitor and only cleans a running empty monitor when no other ports exist and the range matches this attempt, allowing recovery without closing another receiver.

Hardware verification covers Up0/Down0 command replies, recovery from invalid input, out-of-range channel rejection/recovery and incremental/repeated MCP peek reads matching newly received terminal bytes. MCP reads do not consume the received cache. Positive concurrent operation on nonzero channels is not covered by this verification.

Fixed in 0.4.3

Automatic RTT setup in a normal all-stop session now waits for a real stop and rechecks session readiness before running. Boot-to-entry waits for the primary App entry, so a Boot breakpoint does not bind the wrong image's same-named RTT control block. Initial non-stop running attach retains its automatic RTT setup; the first manual Pause ends that initial permission. See the Boot/App workflow for primary App and additional Boot symbols, source/frame association and reset versus programming.

Pre-halt watchdog preparation also initializes an empty target profile through a read-only CPUID access within its own Web lease, so the first attach after the downloader restarts does not wait on an uninitialized cache. Core/AP validation and cleanup remain required; the probe does not halt or reset the MCU.

New in 0.4.2

The following describes 0.4.2 behavior and its required device capabilities. The English guide provides the steps and identifies historical screenshots. See the real Windows running-attach RTT capture and compact RTT settings, both captured in a Chinese-language host with UTC receive timestamps. Hardware verification and external MCP-client analysis remain separately scoped.

The rule-switch example uses synthetic local cached logs in the native display layer to demonstrate case, whole-word and RE2 matching; it does not involve an MCU or model response.

  • Attach and keep running (pause manually) sets esp-dap-debug.startupMode to attach-running. Choose direct GDB Server mode, the matching ELF and the detected endpoint's core/AP, save, then use Start configured debugger or its generated F5 entry. The device must advertise debug.gdb_non_stop_mode and debug.gdb_running_attach_contract = non_stop_initial_state_v1; unsupported contracts are rejected. Connection does not halt, reset or program the MCU. The existing attach default still connects and halts. The first manual Pause changes the initial non-stop observation connection into a normal controllable GDB connection within the same VS Code session. Breakpoints set before that pause are pending/unverified and apply after the change; Variables, Watch, Call Stack, stepping and breakpoint hits then use normal debugging. RTT reconnects while preserving received main-channel history; MCP clients must reconfirm the current source before continuing incremental reads, and down-channel input must be prepared again. Explicit Restart resets and halts. Running attach cannot be combined with Flash/RAM loading or arbitrary attach-command hooks.
  • RTT while running can start or change the main up channel during the initial direct-GDB attach-running phase before the first manual Pause, with the required device RTT interface. In ordinary all-stop sessions, including a running attach after that first Pause changes its connection, pause before preparing or changing the main channel. J-Link setup/channel changes also require a pause. Version 0.4.9 supports capability-checked running down-channel preparation even after Pause/Continue, as described above; this is separate from main-channel setup. Once prepared, reception/input continues while the MCU runs.
  • Log colors offers Automatic (ANSI / levels / custom), ANSI only and Off. Automatic mode recognizes common level words, short tags and EasyLogger prefixes such as I/app or W/sensor. Custom log colors accepts up to 8 ordered patterns of 1–64 characters with 16 terminal colors. Each rule has Aa (match case), ab (whole word) and .* (RE2 expression) switches, all off by default to preserve case-insensitive literal matching. Whole-word boundaries use Unicode letters, digits, combining marks and _; ERROR will not match ERROR_COUNT or ERROR2. Common RE2 syntax is supported without lookaround or backreferences, using the RE2 engine rather than JavaScript backtracking. Invalid edits show an error and preserve the effective rule. The first matching rule recolors the entire line's foreground, overriding ANSI foreground while retaining bold/background; otherwise ANSI foreground takes precedence over automatic levels. Rules and display choices survive page reload and bottom/floating-view handoff; raw exports are unchanged.
  • Compact RTT settings and system timestamps use aligned 28px controls, Apply/Project defaults icons and folded advanced input settings. System timestamp offers Off (default), Local time and UTC time for the UTF-8 display. Each line retains the host receive time of its first raw byte, not the MCU event time or page-render time; split packets and progress updates do not restamp that line. Timestamp metadata is bounded to 4096 entries per connection alongside the 64 KiB byte ring; missing timestamps remain absent. Raw Hex, exports and MCP log bytes stay unchanged.
  • AI/MCP log analysis uses the existing explicitly enabled and trusted read-only diagnostics service. read_rtt reads only the received main up-channel cache, independently of the displayed source. An external MCP client chooses its model and presents the analysis; the RTT panel has no model selector, AI buttons or automatic-analysis option.

Run XFlashGate: AI/MCP Diagnostics, enable read-only diagnostics, then start and trust the server in MCP: List Servers. In your MCP client, record sourceId and nextOffset from read_rtt, then request the same sourceId plus afterOffset = nextOffset; inspect droppedBytes and reconfirm a changed source. Reads are limited to 8 KiB and do not connect to or halt the MCU. The analyze_rtt prompt asks the external client to wait at least 15 seconds between automatic reads, skip empty batches and treat logs as untrusted data. Model choice, sending consent and analysis scheduling belong to that client; the extension does not start analysis or depend on VS Code's model API.

readPolicy: "peek" and consumesBuffer: false mean that each AI client or viewer keeps its own cursor and can reread the same cached bytes without consuming them. Incremental following polls the plugin's received cache; it neither opens another device connection nor competes for the MCU RTT read pointer. The MCP server does not push a live stream.

In running attach, configured HardFault catch is activated and read back after the first manual Pause. The initial observation phase does not provide automatic fault-stop notifications; choose the existing attach-and-halt mode when full fault debugging is required immediately.

Quick start

  1. Open your MCU project folder and run XFlashGate: Configure Debugging.
  2. Choose one GNU installation/bin directory for GCC, GDB, nm and objdump. CMake/Ninja may be detected or configured locally; J-Link and Keil directories are optional.
  3. Select the matching ELF/AXF. To build with CMake, select an existing base preset, preview synchronization and build; existing CPU/FPU/ABI, macros and linker scripts are preserved. An existing ELF can use generated F5 entries without CMake synchronization.
  4. Enter the device URL and inspect detected target/core/AP information. Check device and read algorithms; select a matching algorithm for Flash programming. Attach and RAM launch require no Flash algorithm.
  5. Choose direct GDB Server or J-Link compatible mode. Use Start configured debugger for existing firmware, Program and debug for Flash, or Load RAM and debug with direct GDB. RAM launch derives its backup range from the ELF; preview or override it in the bottom Memory panel.
  6. Use VS Code breakpoints, Call Stack, Variables, Watch, stepping and generated F5 entries. Open User Guide from the XFlashGate view or configuration form for screenshots and per-feature instructions.

Project settings save a stable algorithmId, such as file:C551-JLink.sflc, rather than a device storage path. Signed identifiers pin package version, member and index digest. Raw file names must be unique; their contents are not pinned. Legacy paths migrate after a successful catalog check. Missing, ambiguous or incomplete catalogs require correction rather than guessing.

Boot and App images

Select the App ELF/AXF as the primary symbol file and add the matching Boot ELF under Additional symbols (up to eight workspace-relative paths). Both symbol sets stay in one debug session: source navigation and frame variables follow the current PC or selected stack frame and its DWARF information, without manually switching ELFs. Matching source files must remain accessible; moved source trees require a source-path mapping. The session freezes and hashes the complete set for debugging, Live Watch, RTOS readers and saved crash/RAM analysis. Additional symbols supply no implicit download action.

Startup mode defaults to Attach and halt (preserve current context). With the Start configured debugger entry, Boot to primary ELF entry (boot-to-entry) resets the MCU, follows the existing Boot chain and stops at a primary App function such as main, without programming firmware. The entry is resolved from the primary ELF, so a Boot ELF's own main cannot choose the App stop location. Existing firmware must provide the actual Boot-to-App transition. Reset and halt inspects the reset context; Attach and keep running (pause manually) requires an eligible direct-GDB session and neither resets nor runs automatically to an entry.

Runtime addresses must match the ELFs' fixed linked addresses (VMAs); dynamic relocation, overlays and overlapping code regions are not switched automatically. Duplicate non-static globals in Watch or Global scope still follow GDB lookup rules and are not separated into Boot/App namespaces. The two symbol sets are not memory snapshots: when Boot and App reuse RAM, current RAM values do not preserve earlier Boot variables.

With Program and debug, an empty Download images (advanced) list downloads only the primary ELF. A nonempty list explicitly replaces that default and can include matching Boot, App and tail-data ELFs. Keep this list separate from additional symbols, and check the complete firmware layout before downloading. Saved additional ELF digests prove which files were retained; target-machine-code comparison still reports its verified scope separately.

Included views

Feature Usage
Memory Bottom panel beside Terminal; one read-only address region, paging, 8/16/32-bit grouping, ASCII and changes; RAM launch range preview and settings.
RTOS Compact task/object tables, saved context, per-task stacks and Default/Hex variables; FreeRTOS plus experimental ThreadX, CMSIS-RTX5 and Zephyr readers for verified ports.
RAM snapshots Save bounded paused RAM and matching symbols, then inspect tasks, stacks, variables and Memory after resuming or disconnecting.
Variables / Watch VS Code's native views evaluate the selected halted frame.
Live Watch Enable before the session; observe supported stable-address variables while running.
RTT Bottom panel beside Terminal; compact settings, ANSI/automatic/custom colors, host timestamps, search, follow, export, floating/docked view and separate down-channel input.
Peripheral registers Built-in CMSIS-SVD / Keil SFD text view; manual reads while halted, fields/enums and side-effect confirmation.
HardFault / Backtrace Save registers, configured RAM, fault state, stacks and frame variable values; inspect or replay offline with matching symbols.
AI / MCP Read-only diagnostics by default, including incremental RTT analysis. A separate workspace permission enables explicit target power writes.
Target power Manual J15 3.3 V / USB-A 5 V On, Off or Cycle on supported devices; requires idle targets, impact confirmation and fresh identification afterward.

AI / MCP permissions and tools

Enable XFlashGate: AI/MCP Diagnostics for a trusted local project and connect through MCP: List Servers or the copied connection configuration. The provider is named XFlashGate AI/MCP; each connection identifies whether target power write permission is enabled. Diagnostics remain read-only. esp-dap-debug.mcpPowerControlEnabled is separately disabled by default and must be enabled in workspace/folder settings; a global user setting does not grant power permission.

Tools Behavior
get_debug_status Cached session, device and permission state; does not reconnect to the MCU.
get_threads, get_stack, read_value, read_memory Existing session diagnostics within the tool's pause, expression and RAM bounds.
read_rtt, get_crash_report, get_peripherals Received RTT, saved reports and manually collected peripheral caches.
get_target_power_status Live power capabilities and debugger identity, without changing power; available with read-only MCP.
set_target_power Published only with separate power write permission. Requires explicit rail, action, confirm: true and expectedFactoryMac from the live status.

Power Off/Cycle loses target RAM and execution state; On can start the target and its peripherals. External power can prevent a reset. Off keeps power off; Cycle restores it on a fixed schedule. Active debugging, RTT and locally saved recovery sessions are rejected, never automatically stopped. If firmware explicitly permits the current download recovery session, only explicit On/Off is available and the recovery warning remains. Check each rail's allowedActions; successful power control does not establish target recovery. Unknown outcomes are not automatically retried. Permission changes invalidate existing MCP connections; reconnect to obtain the new tool list. Each power action requires user authorization. See the power control contract and test scope.

Requirements and boundaries

Windows x64 or macOS (Intel and Apple silicon) desktop, VS Code 1.101.2 or newer, a trusted project, an ESP-DAP device with the required capabilities, and local GNU/CMake/Ninja tools. The extension includes its own GDB/MI debug adapter, Live Watch, Memory, RTOS and peripheral views; no other debugger extension is required. J-Link mode uses an optional local J-Link GDB Server. Tools and vendor algorithms are not bundled. Apple silicon macOS has been checked in the system VS Code with PowerUnit Boot/App builds and source debugging, App and tail programming, running attach, repeated pause/resume, bidirectional RTT, Memory, peripheral reads, read-only MCP and RAM capture, with independent physical readback. Intel Mac runtime and macOS J-Link remain unverified; existing Windows acceptance records retain their original scope.

For a local VSIX, use Node.js 22 or newer and run npm ci then npm run package -- artifacts from this folder. This creates one artifacts/xflashgate-mcu-debug-<version>.vsix for Windows x64, Intel Macs and Apple silicon. npm run package:macos remains an alias for the same universal package. Install it from VS Code's Install from VSIX... command or with code --install-extension <path-to-vsix>. Packaging omits --target and does not bundle native tools; install the GNU Arm toolchain on each host. A universal package does not replace platform-specific runtime and upgrade acceptance.

On macOS, GNU discovery also checks /opt/homebrew/bin and /usr/local/bin when tools are absent from the GUI host's PATH. CMake discovery includes /Applications/CMake.app/Contents/bin/cmake. Explicit tool paths take precedence; a missing explicit path reports an error.

Direct GDB uses the device RSP port; J-Link uses the native probe endpoint through the local server. These ports are different protocols. Default attach connects and halts the MCU without implicit programming, building or reset. attach-running is selected separately and requires the advertised device contract. When watchdog freezing is enabled, a target already halted or locked up is rejected before freeze changes; choose attach-and-halt or explicitly resume it first. Reset/Restart stays halted unless the session explicitly selects Boot to entry; that mode runs the existing Boot flow to the selected primary ELF address. Cleanup restores owned debug-control bits and releases session resources. RAM launch also restores its original RAM backup after disconnect; wait for the recovery progress to finish. Previous CPU/peripheral execution state is not restored.

Reset method (esp-dap-debug.resetMethod) defaults to system reset. Direct GDB also offers nRESET hardware reset for targets with a connected reset line and device support. Startup, restart and RAM recovery use the selected method; attachment still does not reset. A successful reset command does not prove the MCU reached its boot context. If its PC remains inside the RAM being restored, recovery retains the backup and stops before writing. Check the reset wiring and boot state, press the board Reset button, then use Recover Unfinished Debug Session.

Hardware samples include CH32F208/Cortex-M3, STM32C551/Cortex-M33 and NUCLEO-N657X0-Q/Cortex-M55. FreeRTOS stacks cover the verified GCC ARM_CM3 non-MPU basic frame, CM33_NTZ and CM55_NTZ basic contexts. The CH32F208 regression record describes its task stacks, variables and bidirectional RTT while running. ThreadX 6.2.1, CMSIS-RTX5 5.9.0 and Zephyr 4.3.0 use their verified basic M55 contexts in fixed N657 demos. Target identity, firmware capabilities and port layout govern support; these samples do not establish support for every MCU. Binary SFR, arbitrary RTOS ports, floating-point/cross-security context reconstruction, Remote/Web hosts and post-reset state restoration remain outside the verified scope.

Local tool paths are stored per project and OS in VS Code's local storage, outside shareable project settings. Tokens use SecretStorage. Generated tasks and launch entries resolve local tools at execution time. The extension ID xcheng.esp-dap-debug, configuration/command IDs and existing debugging entries remain compatible.

For errors, run XFlashGate: Show Diagnostics. Remove credentials and sensitive target data before sharing logs.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft