Configure Your Project

Select an Espressif target (esp32, esp32s2, etc.) by selecting menu View > Command Palette and typing ESP-IDF: Set Espressif Device Target command.

Select menu View > Command Palette and type the ESP-IDF: Select OpenOCD Board Configuration to choose the openOCD configuration files for the extension openOCD server.

备注

Next configure your project. Select menu View > Command Palette and type ESP-IDF: SDK Configuration Editor command ESP-IDF project settings.

_images/gui_menuconfig.png

After all changes are made, click save and close this window.

Next step is to Build the project.

C and C++ Code navigation and syntax highlight

备注

  • C and C++ code navigation doesn’t need to be configured if you create the project as described in Configure your project as these commands will create the {PROJECT_DIRECTORY_PATH}/.vscode/c_cpp_properties.json file.

For code navigation and C/C++ syntax highlight you could use either the Microsoft C/C++ Extension, LLVM CLangd extension or any other extension you desire.

Usually C/C++ language extensions rely on a file called compile_commands.json which is located on your project build directory. You can generate this file using the ESP-IDF: Run idf.py reconfigure task.

For LLVM CLangd extension, only the compile_commands.json is needed. For Microsoft C/C++ extension, a configuration file is located in {PROJECT_DIRECTORY_PATH}/.vscode/c_cpp_properties.json and can be generated by creating a project using ESP-IDF: New Project, ESP-IDF: Show Examples Projects command or using the ESP-IDF: Add .vscode Configuration Folder command on an existing ESP-IDF projects.

The file looks like this:

{
  "configurations": [
    {
      "name": "ESP-IDF",
      "compilerPath": "/path/to/toolchain-gcc",
      "compileCommands": "${workspaceFolder}/build/compile_commands.json",
      "includePath": [
        "${config:idf.espIdfPath}/components/**",
        "${config:idf.espIdfPathWin}/components/**",
        "${workspaceFolder}/**"
      ],
      "browse": {
        "path": [
          "${config:idf.espIdfPath}/components",
          "${config:idf.espIdfPathWin}/components",
          "${workspaceFolder}"
        ]
      }
    }
  ]
}

If compile_commands.json is not defined, the Microsoft C/C++ extension will browse the provided ESP-IDF path to provide code navigation resolution.