Skip to content

[QEMU macOS] Integrating to VSCode

Antonio Giacomelli edited this page Jun 13, 2025 · 34 revisions

🍏 Debugging with VSCodium on macOS

This page describes how to debug RK0 using QEMU and VSCodium (or VS Code*) on macOS.


Installing Dependencies

ARM Embedded Toolchain

brew install arm-none-eabi-gcc

QEMU

brew install qemu

Building RK0

Run from the RK0 project root:

make ARCH=armv7m   

To debug:

make qemu-debug

This will start QEMU and open a GDB server on localhost:1234.


Configure VS Code / VSCodium

tasks.json

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "Build RK0 for ARMv7-M",
      "type": "shell",
      "command": "make ARCH=armv7m",
      "group": {
        "kind": "build",
        "isDefault": true
      }
    },
    {
      "label": "Start QEMU in Debug Mode",
      "type": "shell",
      "command": "make qemu-debug",
      "isBackground": true,
      "problemMatcher": {
        "pattern": {
          "regexp": "."
        },
        "background": {
          "activeOnStart": true,
          "beginsPattern": "Start GDB with:",
          "endsPattern": "localhost:1234"
        }
      }
    }
  ]
}

launch.json

PS: On macOS, the cppdbg debugger type often fails to attach to GDB/LLDB. I use the cortex-debug only. I can't say if using pure VSCode (and not VSCodium as I do) would solve the issue.

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Debug RK0 - ARMv7M",
      "cwd": "${workspaceFolder}",
      "executable": "${workspaceFolder}/build/armv7m/rk0_demo.elf",
      "request": "attach",
      "type": "cortex-debug",
      "servertype": "external",
      "gdbTarget": "localhost:1234",
      "gdbPath": "arm-none-eabi-gdb",
      "device": "Cortex-M3",
      "runToEntryPoint": "main",
      "preLaunchTask": "Start QEMU in Debug Mode"
    }
  ]
}

Running

  1. Build and start QEMU in the background using the Run Panel.
  2. Launch the Debug configuration — VSCodium will attach to GDB server.

image

Clone this wiki locally