Skip to content

VS Code Setup

Configure Visual Studio Code for ESP-IDF development. This guide covers the ESP-IDF extension, C/C++ IntelliSense, and recommended settings for a smooth development experience.


Step 1 — Install VS Code

Download from code.visualstudio.com and install.

  1. Download the User Installer (.exe)
  2. Run the installer — check "Add to PATH"
  3. Launch VS Code
  1. Download the .zip archive
  2. Extract and drag Visual Studio Code.app to Applications
  3. Open from Launchpad or Applications
# Ubuntu/Debian — via .deb package
sudo apt-get install -y code

# Or via snap
sudo snap install code --classic

# Or download from https://code.visualstudio.com/

Step 2 — Install Required Extensions

Open VS Code and install these extensions:

Essential

Extension ID Purpose
ESP-IDF espressif.esp-idf-extension Build, flash, monitor, menuconfig — all from VS Code
C/C++ ms-vscode.cpptools IntelliSense, debugging, code navigation
Extension ID Purpose
CMake Tools ms-vscode.cmake-tools CMake configuration and build
Cortex-Debug marus25.cortex-debug ARM/RISC-V JTAG debugging
Serial Monitor ms-vscode.vscode-serial-monitor Serial port monitoring inside VS Code
Error Lens usernamehw.errorlens Inline error/warning display
GitLens eamodio.gitlens Git integration and blame

Install from the command line:

code --install-extension espressif.esp-idf-extension
code --install-extension ms-vscode.cpptools
code --install-extension ms-vscode.cmake-tools
code --install-extension marus25.cortex-debug
code --install-extension ms-vscode.vscode-serial-monitor

Step 3 — Configure the ESP-IDF Extension

  1. Open VS Code
  2. Press Ctrl+Shift+P (macOS: Cmd+Shift+P) → type ESP-IDF: Configure ESP-IDF Extension
  3. Select USE EXISTING SETUP
  4. Enter the path to your ESP-IDF directory:
  5. Docker path: The extension will use the Docker container's ESP-IDF installation
  6. Set the target to esp32s3
  7. Set the serial port for your board

Docker integration

The ESP-IDF extension can detect and use ESP-IDF inside a Docker container. When you run build/flash/monitor commands from the extension, it executes them inside the container.

  1. Open VS Code
  2. Press Ctrl+Shift+P (macOS: Cmd+Shift+P) → type ESP-IDF: Configure ESP-IDF Extension
  3. Select EXPRESS (fast setup) or ADVANCED (custom paths)
  4. Enter the paths:
  5. ESP-IDF path: ~/esp/esp-idf (or %USERPROFILE%\esp\esp-idf on Windows)
  6. Tools path: ~/.espressif (default)
  7. Set the target to esp32s3
  8. Set the serial port for your board

Step 4 — Workspace Settings

Create a .vscode/settings.json in your project for optimal ESP-IDF development:

.vscode/settings.json
{
    "C_Cpp.default.compilerPath": "${env:IDF_TOOLS_PATH}/tools/xtensa-esp-elf/esp-14.2.0_20241119/xtensa-esp-elf/bin/xtensa-esp32s3-elf-gcc",
    "C_Cpp.default.intelliSenseMode": "gcc-x64",
    "C_Cpp.default.defines": [
        "ESP32S3",
        "__GNUC__",
        "CONFIG_IDF_TARGET_ESP32S3"
    ],
    "C_Cpp.default.includePath": [
        "${workspaceFolder}/**",
        "${env:IDF_PATH}/components/**"
    ],
    "files.associations": {
        "*.h": "c",
        "*.c": "c"
    },
    "editor.formatOnSave": true,
    "editor.tabSize": 4,
    "editor.insertSpaces": true,
    "files.trimTrailingWhitespace": true,
    "search.exclude": {
        "build/**": true
    }
}

IntelliSense configuration

The ESP-IDF extension auto-generates `c_cpp_properties.json` when you build the project. If IntelliSense isn't working, run a build first — the extension will create the correct configuration.

Step 5 — Useful Keyboard Shortcuts

Action Windows/Linux macOS
Command Palette Ctrl+Shift+P Cmd+Shift+P
Build project Ctrl+E B Cmd+E B
Flash project Ctrl+E D Cmd+E D
Open serial monitor Ctrl+E M Cmd+E M
Open menuconfig Ctrl+E G Cmd+E G
Quick open (files) Ctrl+P Cmd+P
Go to definition F12 F12
Find all references Shift+F12 Shift+F12
Toggle terminal Ctrl+ |Cmd+

Step 6 — Debugging (Advanced)

If you have a JTAG debug probe, you can debug ESP-IDF firmware directly in VS Code.

Launch Configuration

Create .vscode/launch.json:

.vscode/launch.json
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "ESP-IDF Debug",
            "type": "cortex-debug",
            "request": "launch",
            "cwd": "${workspaceFolder}",
            "executable": "${workspaceFolder}/build/projectname.elf",
            "servertype": "espidf",
            "device": "esp32s3",
            "configFiles": [
                "interface/ftdi/esp32_devkitj_v1.cfg",
                "target/esp32s3.cfg"
            ]
        }
    ]
}

JTAG required

Debugging requires a JTAG probe connected to the ESP32-S3's JTAG pins. The XIAO ESP32-S3 does not have a built-in JTAG interface — you'd need an external probe like ESP-Prog. This is not required for the workshop.


Troubleshooting

IntelliSense not working

  1. Build the project at least once (idf.py build)
  2. The ESP-IDF extension generates c_cpp_properties.json automatically
  3. If still broken: Ctrl+Shift+PC/C++: Reset IntelliSense Database

ESP-IDF extension commands not appearing

  1. Ensure the extension is installed and enabled
  2. Reload VS Code window: Ctrl+Shift+PDeveloper: Reload Window
  3. Check the extension's output panel for errors

Serial port not found

  1. Connect the XIAO ESP32-S3 via USB-C
  2. Install USB drivers if needed — see Prerequisites
  3. Check the port: ls /dev/tty* (macOS/Linux) or Device Manager (Windows)

Build fails from VS Code but works in terminal

The ESP-IDF extension may not have the environment variables loaded. Run:

  • Ctrl+Shift+PESP-IDF: Configure ESP-IDF Extension → re-select your setup

Next Steps

  • Docker SetupDocker Setup — Install Docker and Docker Compose
  • Hardware KitHardware Kit — Reference for all workshop hardware