Star 历史趋势
数据来源: GitHub API · 生成自 Stargazers.cn
README.md
espressif logo

ESP-IDF Extension for VS Code

中文

Espressif Documentation Troubleshooting Version Releases Forum

Develop, build, flash, monitor, debug and more with Espressif chips using Espressif IoT Development Framework (ESP-IDF).

Latest master installer for Visual Studio Code. You can use this VSIX to test the current github master of the extension by pressing F1 or click menu View -> Command Palette..., type Install from VSIX and then select the previously downloaded .vsix file to install the extension.

Make sure to review our Espressif documentation first to properly use the extension.

How to use

Install

  1. Download and install Visual Studio Code.

  2. Install ESP-IDF system prerequisites for your operating system:

  • Prerequisites for MacOS and Linux.
  • For Windows there is no additional prerequisites.
  1. In Visual Studio Code, Open the Extensions view by clicking on the Extension icon in the Activity Bar on the side of Visual Studio Code or the View: Show Extensions command (shortcut: ⇧ ⌘ X or Ctrl+Shift+X).

  2. Search for ESP-IDF Extension.

  3. Install the extension. After you install the extension, the Espressif icon should appear in the VS Code Activity bar (left side set of icons). When you click the Espressif icon, you can see a list of basic commands provided by this extension.

Commands list

  1. From the command list, select ESP-IDF: Open ESP-IDF Installation Manager or press F1 and type Open ESP-IDF Installation Manager. After, choose the ESP-IDF: ESP-IDF: Open ESP-IDF Installation Manager option.

    NOTE: For versions of ESP-IDF < 5.0, spaces are not supported inside configured paths.

  2. Alternatively, you can download the ESP-IDF Installation Manager from the following link ESP-IDF Installation Manager among the following options::

  • Espressif: Faster speed in China using Espressif download servers links.
  • Github: Using github releases links.
  1. Use the ESP-IDF Installation Manager to install the ESP-IDF and tools. If necessary, here is the ESP-IDF Installation Manager Documentation.

  2. In Visual Studio Code, navigate to View > Command Palette and type select current esp-idf version and select ESP-IDF: Select Current ESP-IDF Version from the list. The list of available ESP-IDF setups will be shown, select which one you want to use for the current ESP-IDF project. The selected setup will save the selected ESP-IDF path as idf.currentSetup and the extension will configure environment variables for the current project saved as workspace folder state. You can review the setup by navigating to View > Command Palette, typing doctor command, and selecting ESP-IDF: Doctor Command from the list.

  3. If everything is installed correctly, you will see a message that all settings have been configured. You can start using the extension.

Check the Troubleshooting section if you have any issues.

Using the ESP-IDF Extension for VS Code

This extension provides a list of icons in the status bar (blue bar in the bottom of VS Code window) for ESP-IDF commands. You can see the command to be executed when you hover the icon.

Status bar

These icons will be used in the steps below showing common ESP-IDF use cases:

  1. Press F1 and type ESP-IDF: New Project to create a new project from ESP-IDF examples. Select ESP-IDF and choose an example to create a new project from.

  2. Once the project is created and opened in VS Code, set the serial port of your device by clicking status bar icon serial port. Alternatively, press F1, type ESP-IDF: Select Port to Use, and choose the serial port to which your device is connected.

  3. Select an Espressif target (esp32, esp32s2, etc.) by clicking status bar icon IDF Target. Alternatively, press F1 and type ESP-IDF: Set Espressif Device Target command.

  4. Next, configure your ESP-IDF project by clicking status bar icon sdkconfig editor or press F1 and typing ESP-IDF: SDK Configuration Editor command (CTRL E G keyboard shortcut) where you can modify the ESP-IDF project settings. After all changes are made, click Save and close this window. You can see the output in the menu View -> Output and choose ESP-IDF from the dropdown list.

  5. (OPTIONAL) Run ESP-IDF: Run idf.py reconfigure Task to generate the compile_commands.json file so language support works. Additionally you can configure the .vscode/c_cpp_properties.json as explained in C/C++ Configuration documentation.

  6. At this point, you can modify the code. When the project is completed, build your project by clicking status bar icon build or pressing F1 and typing ESP-IDF: Build your Project.

  7. Flash to your device by clicking status bar icon flash, or pressing F1 and typing ESP-IDF: Flash Your Project. From there, select UART, DFU or JTAG depending on your serial connection, and start flashing the application to your device.

  8. Change the flash method by clicking status bar icon flash method, or pressing F1 and typing ESP-IDF: Select Flash Method to select from UART, DFU or JTAG. You can alternatively use one of the commands ESP-IDF: Flash (UART) Your Project, ESP-IDF: Flash (with JTAG) or ESP-IDF: Flash (DFU) Your Project.

  9. Start a monitor by clicking status bar icon monitor, or pressing F1 and typing ESP-IDF: Monitor Device, which will log the device activity in a Visual Studio Code terminal.

  10. Make sure to configure your drivers as mentioned in ESP-IDF Configure JTAG Interface documentation.

  11. Before debugging your device, if you are using a connected ESP-IDF development board, the OpenOCD configuration will be automatically selected based on your connected board, including the USB location if available (requires OpenOCD version v0.12.0-esp32-20240821 or higher). Otherwise, you can manually select the device OpenOCD board configuration files by pressing F1 and typing ESP-IDF: Select OpenOCD Board Configuration. You can test the connection by clicking status bar icon openocd or pressing F1 and typing ESP-IDF: OpenOCD Manager. The output is shown in the menu View -> Output and choose ESP-IDF from the dropdown list.

    NOTE: You can start or stop the OpenOCD in Visual Studio Code using the ESP-IDF: OpenOCD Manager command or by clicking the OpenOCD Server (Running | Stopped) button in the status bar.

  12. If you want to start a debug session, just press F5 (ensure the project is built, flashed, and OpenOCD is properly connected for the debugger to function correctly). The debug session output can be seen in the menu View -> Debug Console.

Check the Troubleshooting section if you have any issues.

Further reading

Check the ESP-IDF Extension for VS Code Documentation for tutorials, commands and features provided.

All Available Commands

Press F1 or click menu View -> Command Palette... to show Visual Studio code commands, then type ESP-IDF to see all available extension commands.

CategoryCommandDescriptionKeyboard Shortcuts (Mac)Keyboard Shortcuts (Windows/Linux)
SettingsAdd Docker Container ConfigurationAdd the .devcontainer files to the currently opened project directory, necessary to use a ESP-IDF project in a Docker container with Visual Studio Code Dev Containers extension.
Add VS Code Configuration FolderAdd .vscode files to the currently opened project directory. This includes launch.json (for debugging), settings.json and c_cpp_properties.json (for syntax highlight).
Open ESP-IDF Installation ManagerOpen ESP-IDF Installation Manager (EIM) to install ESP-IDF, IDF Tools and Python virtual environment.
Select Output and Notification ModeThis extension shows many notifications and output in the Output window ESP-IDF. This command allows you to set if to show notifications only, output only, both notifications and output, or neither.
Select Where to Save Configuration SettingsIn Visual Studio Code, settings can be saved in 3 places: User Settings (global settings), workspace ( .code-workspace file) or workspace folder (.vscode/settings.json). More information in working with multiple projects.
Pick a Workspace FolderWhen using a Visual Studio Code workspace with multiple folders, this command allows you to choose which workspace folder to apply this extension's commands to. More information in working with multiple projects.
BasicSet Espressif Device TargetThis will set the target for the current project (IDF_TARGET). Similar to idf.py set-target. For example, if you want to use ESP32 or ESP32-C3, you need to execute this command.
SDK Configuration EditorLaunch a UI to configure your ESP-IDF project settings. This is equivalent to idf.py menuconfig.⌘ I GCtrl E G
Build Your ProjectBuild your project using `CMake` and `Ninja-build` as explained in ESP-IDF Build System Using Cmake Directly. You could modify the behavior of the build task with idf.cmakeCompilerArgs for Cmake configure step and idf.ninjaArgs for Ninja step. For example, using [-j N] where N is the number of jobs run in parallel.⌘ I BCtrl E B
Size Analysis of the BinariesLaunch UI with the ESP-IDF project binaries size information.⌘ I SCtrl E S
Select Port to UseSelect which serial port to use for ESP-IDF tasks, such as flashing or monitoring your device.⌘ I PCtrl E P
Flash Your ProjectWrite binary data to the ESP's flash chip from your current ESP-IDF project. This command will use either UART, DFU or JTAG based on idf.flashType.⌘ I FCtrl E F
Monitor DeviceThis command will execute idf.py monitor to start serial communication with Espressif device. Please take a look at the IDF Monitor.⌘ I MCtrl E M
Open ESP-IDF TerminalLaunch a terminal window configured with extension ESP-IDF settings. Similar to export.sh script from ESP-IDF CLI.⌘ I TCtrl E T
Select OpenOCD Board ConfigurationSelect the OpenOCD configuration files that match your Espressif device target, such as DevKitC or ESP-Wrover-Kit. This is necessary for flashing with JTAG or debugging your device.
Build, Flash and Start a Monitor on Your DeviceBuild the project, write binaries program to device and start a monitor terminal with a single command. Similar to idf.py build flash monitor.⌘ I DCtrl E D
Project creationCreate New ESP-IDF ComponentCreate a new component in the current directory based on ESP-IDF component template.
Create New Empty ProjectAsk for the new project name, choose the directory to create the project, and show a notification to open the newly created project.
Import ESP-IDF ProjectImport an existing ESP-IDF project, add .vscode and .devcontainer files to a new location, and optionally rename the project.
New ProjectLaunch UI with a ESP-IDF project creation wizard using example templates from ESP-IDF and additional frameworks configured in the extension.⌘ I NCtrl E N
FlashingSelect Flash MethodSelect which flash method to use for Flash Your Project command. It can be DFU, JTAG or UART.
Flash Your ProjectWrite binary data to the ESP's flash chip from your current ESP-IDF project. This command will use either UART, DFU or JTAG based on idf.flashType⌘ I FCtrl E F
Flash (DFU) Your ProjectWrite binary data to the ESP's flash chip from your current ESP-IDF project using DFU. Only for ESP32-S2 and ESP32-S3.
Flash (UART) Your ProjectWrite binary data to the ESP's flash chip from your current ESP-IDF project using esptool.py.
Flash (with JTAG)Write binary data to the ESP's flash chip from your current ESP-IDF project using OpenOCD JTAG.
Encrypt and Flash Your ProjectExecute flashing the project program to device while adding --encrypt for partitions to be encrypted.
Erase Flash Memory from DeviceExecute esptool.py erase_flash command to erase flash chip (set to 0xFF bytes).⌘ I RCtrl E R
Code coverageAdd Editor CoverageParse your project GCOV code coverage files to add color lines representing code coverage on currently opened source code file.
Configure Project SDKConfig for CoverageSet required values in your project SDKConfig to enable code coverage analysis.
Get HTML Coverage Report for ProjectParse your project GCOV code coverage files to generate a HTML coverage report.
Remove Editor CoverageRemove editor colored lines from Add Editor Coverage command
Additional frameworksInstall ESP-ADFClone ESP-ADF inside the selected directory and set ADF_PATH in idf.customExtraVars configuration setting.
Add Arduino ESP32 as ESP-IDF ComponentAdd Arduino-ESP32 as a ESP-IDF component in your current directory (${CURRENT_DIRECTORY}/components/arduino).
eFuseGet eFuse SummaryRetrieve a list of eFuses and their corresponding values from the chip currently connected to the serial port and display in the ESP Explorer EFUSEEXPLORER.
Clear eFuse SummaryClear the eFuse Summary tree from ESP Explorer EFUSEEXPLORER.
QEMULaunch QEMU ServerAs described in QEMU documentation, this command will execute ESP32 QEMU from the project Dockerfile with the current project binaries.
Launch QEMU Debug SessionAs described in QEMU documentation, this command will start a debug session to ESP32 QEMU from the project Dockerfile with the current project binaries.
Monitor QEMU DeviceAs described in QEMU documentation, this command will start a terminal to monitor the ESP32 QEMU from the project Dockerfile with the current project binaries.
MonitoringMonitor DeviceThis command will execute idf.py monitor to start serial communication with Espressif device. Please take a look at the IDF Monitor Documentation.⌘ I MCtrl E M
Launch IDF Monitor for Core Dump Mode/GDB Stub ModeLaunch ESP-IDF Monitor with WebSocket capabilities. If you has configured the panic handler to gdbstub or core dump, the monitor will launch a post-mortem debug session of the chip.
Monitor QEMU DeviceAs described in QEMU documentation, this command will start a terminal to monitor the ESP32 QEMU from the project Dockerfile with the current project binaries.
EditorsNVS Partition EditorLaunch UI to create a CSV file for ESP-IDF Non-Volatile Storage Library.
Partition Table EditorLaunch UI to manage custom partition table as described in ESP-IDF Partition Tables.
SDK Configuration EditorLaunch a UI to configure your ESP-IDF project settings. This is equivalent to idf.py menuconfig.⌘ I GCtrl E G
Unit Testing"Unit Test: Build Unit Test App"Copy the unit test app in the current project, build the current project. More information in Unit testing documentation.
Unit Test: Flash Unit Test AppFlash the unit test application to the connected device. More information in Unit testing documentation.
Unit Test: Build and Flash Unit Test App for TestingCopy the unit test app in the current project, build the current project and flash the unit test application to the connected device. More information in Unit testing documentation.
Scripts and ToolsRun idf.py reconfigure TaskThis command will execute idf.py reconfigure (CMake configure task), which is useful for generating compile_commands.json for the C/C++ language support.
Erase Flash Memory from DeviceExecute esptool.py erase_flash command to erase flash chip (set to 0xFF bytes).⌘ I RCtrl E R
Dispose of Current SDK Configuration Editor Server ProcessIf you already executed the SDK Configuration Editor, a cache process will remain in the background for faster reopening. This command will dispose of such cache process.
Doctor CommandRun a diagnostic of the extension setup settings and extension logs to provide a troubleshooting report.
Troubleshoot FormLaunch UI for user to send a troubleshoot report with steps to reproduce. Run a diagnostic of the extension setup settings and extension logs to send to telemetry backend.
Run ESP-IDF-SBOM Vulnerability CheckCreates Software bill of materials (SBOM) files in the Software Package Data Exchange (SPDX) format for applications generated by the Espressif IoT Development Framework (ESP-IDF).
Save Default SDKCONFIG File (save-defconfig)Generate sdkconfig.defaults files using the project current sdkconfig file.
Show Ninja Build SummaryExecute the Chromium ninja-build-summary.py.
Search in documentation...Select some text from your source code file and search in ESP-IDF documentation with results right in the VS Code ESP-IDF Explorer tab.⌘ I QCtrl E Q
Search Error HintType some text to find a matching error from ESP-IDF hints dictionary.
Load Image from LVGL C FileLoad and display an image from a LVGL C file containing lv_image_dsc_t structure. This command allows you to view LVGL images without requiring a debug session.
Open Image ViewerOpen the Image Viewer panel to display images from debug variables or LVGL C files. This panel provides tools for viewing and analyzing image data in various formats.
CleanupClear ESP-IDF Search ResultsClear results from ESP Explorer Documentation Search Results.

Commands for tasks.json and launch.json

We have implemented some utilities commands that can be used in tasks.json and launch.json like:

"miDebuggerPath": "${command:espIdf.getToolchainGdb}"
  • espIdf.getExtensionPath: Get the installed location absolute path.
  • espIdf.getOpenOcdScriptValue: Return the value of OPENOCD_SCRIPTS computed from ESP-IDF Tools path, idf.customExtraVars, or the system's OPENOCD_SCRIPTS environment variable.
  • espIdf.getOpenOcdConfigs: Return the openOCD configuration files as string. Example -f interface/ftdi/esp_ftdi.cfg -f target/esp32.cfg.
  • espIdf.getProjectName: Return the project name from current workspace folder build/project_description.json.
  • espIdf.getToolchainGcc: Return the absolute path of the toolchain GCC for the ESP-IDF target given by current IDF_TARGET in sdkconfig or idf.customExtraVars["IDF_TARGET"] configuration setting.
  • espIdf.getToolchainGdb: Return the absolute path of the toolchain gdb for the ESP-IDF target given by current IDF_TARGET in sdkconfig or idf.customExtraVars["IDF_TARGET"] configuration setting.
  • espIdf.getIDFTarget: Return the current IDF_TARGET from sdkconfig or idf.customExtraVars["IDF_TARGET"] configuration setting.

See an example in the debugging documentation.

Available Tasks in tasks.json

A template tasks.json is included when creating a project using ESP-IDF: New Project. These tasks can be executed by pressing F1, writing Tasks: Run task and selecting one of the following:

  1. Build - Build Project
  2. Set Target to esp32
  3. Set Target to esp32s2
  4. Clean - Clean the project
  5. Flash - Flash the device
  6. Monitor - Start a monitor terminal
  7. OpenOCD - Start the OpenOCD server
  8. BuildFlash - Execute a build followed by a flash command

Note that for OpenOCD tasks, you need to define OpenOCD_SCRIPTS in your system environment variables with OpenOCD scripts folder path.

Troubleshooting

If something is not working, please check for any error on one of these:

NOTE: Set idf.OpenOCDDebugLevel configuration setting to 3 or more in your /.vscode/settings.json to show debug level logs of OpenOCD server in ESP-IDF output.

NOTE: Set verbose: true in your /.vscode/launch.json for more detailed debug adapter output.

  1. In Visual Studio Code select menu View > Output > ESP-IDF. This output information is useful to know what is happening in the extension.
  2. In Visual Studio Code select menu View > Command Palette... and type ESP-IDF: Doctor Command to generate a report of your environment configuration and it will be copied in your clipboard to paste anywhere.
  3. Check log file which can be obtained from:
  • Windows: %USERPROFILE%\.vscode\extensions\espressif.esp-idf-extension-VERSION\esp_idf_vsc_ext.log
  • Linux & MacOSX: $HOME/.vscode/extensions/espressif.esp-idf-extension-VERSION/esp_idf_vsc_ext.log
  1. In Visual Studio Code, select menu Help > Toggle Developer Tools and copy any error in the Console tab related to this extension.

  2. In Visual Studio Code select menu View > Output > Extension Host. This output information is useful to know what is happening during the extensions activation. If no extension command work, you could share the output here to see the error stack.

  3. Visual Studio Code allows you to configure settings at different levels: Global (User Settings), Workspace and Workspace Folder, so make sure your project has the right settings. The ESP-IDF: Doctor command result might give the values from user settings instead of the workspace folder settings.

    • Workspace folder configuration settings are defined in ${workspaceFolder}/.vscode/settings.json
    • Workspace configuration settings are defined in the workspace's <name>.code-workspace file
    • User settings defined in settings.json
      • Windows: %APPDATA%\Code\User\settings.json
      • MacOS: $HOME/Library/Application Support/Code/User/settings.json
      • Linux: $HOME/.config/Code/User/settings.json

This extension uses the idf.saveScope configuration setting (which can only be defined in User Settings) to specify where to save settings for features such as the Setup Wizard. You can modify this using the ESP-IDF: Select where to Save Configuration Settings command.

  1. Refer to the OpenOCD troubleshooting FAQ for help with application tracing, debugging, or other OpenOCD-related issues that may appear in the OpenOCD output.

  2. In some cases, the default shell (Powershell, zsh, sh, .etc) configured in VS Code could affect the behavior of the extension. Make sure that MSYS/MinGW is not set in the environment and the variables don't conflict with terminal behavior. The ESP-IDF: Doctor Command shows which shell is detected by the extension when running tasks like building, flashing and monitoring. More information in here.

If there is any Python package error, please try to reinstall the required Python packages with the ESP-IDF Installation Manager.

NOTE: When downloading ESP-IDF using git cloning in Windows, if you receive errors like "unable to create symlink", enabling Developer Mode while cloning ESP-IDF could help resolve the issue.

If you can't resolve the error, please search in the github repository issues for existing errors or open a new issue here.

Code of Conduct

This project and everyone participating in it is governed by the Code of Conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to vscode@espressif.com.

License

This extension is licensed under the Apache License 2.0. Please see the LICENSE file for additional copyright notices and terms.

关于 About

Visual Studio Code extension for ESP-IDF projects

语言 Languages

TypeScript85.8%
Vue13.1%
JavaScript0.3%
Python0.3%
SCSS0.2%
C0.1%
CMake0.1%
Shell0.0%
PowerShell0.0%
Dockerfile0.0%
C++0.0%

提交活跃度 Commit Activity

代码提交热力图
过去 52 周的开发活跃度
127
Total Commits
峰值: 22次/周
Less
More

核心贡献者 Contributors