-
Notifications
You must be signed in to change notification settings - Fork 1
[QEMU WIN] Integrating debugging to VSCode
This tutorial shows how to integrate VSCode with GDB+QEMU on Windows.
The easiest way is using the WSL subsystem.
-
In this case, I prefer connecting VSCode to the WSL (and having the source code in the subsystem instead of accessing a /mnt/ partition in Win).
-
Install the same packages as described for Debian-based Linux
-
For .json files, follow the same setup for macOS, replacing
arm-none-eabi-gdb
forgdb-multi-arch
. -
You call
code
from the WSL bash terminal. It will dispatch the VSCode installed on your Windows:
antonio@winbox:~$ uname -a
Linux winbox 5.15.167.4-microsoft-standard-WSL2 #1 SMP Tue Nov 5 00:21:55 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
antonio@winbox:~$ which code
/mnt/c/Users/anton/AppData/Local/Programs/Microsoft VS Code/bin/code
VSCode forwarded to WSL and GDB server
To be compatible with the Makefile, these steps install a UNIX-like bash environment for Windows (MSYS2), configure it, and set MSYS2 bash as the VSCode terminal.
- Install Chocolatey
At a Win PowerShell:
Set-ExecutionPolicy Bypass -Scope Process -Force; `
[System.Net.ServicePointManager]::SecurityProtocol = `
[System.Net.ServicePointManager]::SecurityProtocol -bor 3072; `
iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
- Install toolchain and QEMU
choco install gcc-arm-embedded
choco install msys2
choco install qemu
In VS Code:
- Open Settings
- Search for:
terminal.integrated.profiles.windows
- Edit your
settings.json
:
"terminal.integrated.profiles.windows": {
"MSYS2 Bash": {
"path": "C:\\msys64\\usr\\bin\\bash.exe",
"args": ["--login", "-i"],
"env": {
"MSYSTEM": "MINGW64",
"CHERE_INVOKING": "1"
}
}
},
"terminal.integrated.defaultProfile.windows": "MSYS2 Bash"
Edit your MSYS2 ~/.bashrc
:
export PATH=$PATH:/c/ProgramData/chocolatey/bin # adjust path if needed
Then reload:
source ~/.bashrc
Install the extensions cortex-debug
and C/C++
.
Create .vscode/launch.json
:
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug RK0 (QEMU ARMv7-M)",
"type": "cortex-debug",
"request": "launch",
"servertype": "external",
"gdbPath": "arm-none-eabi-gdb",
"cwd": "${workspaceRoot}",
"executable": "${workspaceRoot}/build/armv7m/rk0_demo.elf",
"armToolchainPath": "C:/ProgramData/chocolatey/bin",
"device": "Cortex-M3"
}
]
}
{
"name": "Debug RK0 (cppdbg - ARMv7M)",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}/build/armv7m/rk0_demo.elf",
"miDebuggerPath": "arm-none-eabi-gdb",
"miDebuggerServerAddress": "localhost:1234",
"cwd": "${workspaceRoot}",
"stopAtEntry": false,
"environment": [],
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for GDB",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
- Start QEMU in Debug Mode
make qemu-debug
- Launch Debugger in VS Code
Open the Run panel and press F5
.
VS Code attached to QEMU GDB server, UART output visible.
Copyright (C) 2025 Antonio Giacomelli | www.kernel0.org