-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setup instructions for VSCode (GIT8266O-605) #1028
Comments
I'm also searching for a well written instruction to configure a sophisticated setup to use VSCode. However, in the meantime I have a solution for me that is quite sufficient in some/many cases. Perhaps this could also help you for the meantime. However there are still some issues left.
Preconditions to use
My setup is: c_cpp_properties.json{ // https://code.visualstudio.com/docs/cpp/c-cpp-properties-schema-reference
"configurations": [
{
"name": "ESP-Win",
// Folder with header to be included -> For intellisens engine
// GoTo-Reference-List and tag database ("browse") relies on same paths if not specified
"includePath": [
"${workspaceRoot}/main/**",
"${workspaceRoot}/components/**", // comes in handy when first components are created
"${env:IDF_PATH}/components/**",
//"${workspaceRoot}/build/include" // After first build, this contains configured defines.
],
"defines": [
"NDEBUG", "__BSD_VISIBLE",
"__XSI_VISIBLE=500",
"LOG_LOCAL_LEVEL=ESP_LOG_VERBOSE",
"CONFIG_LOG_TIMESTAMP_SOURCE_RTOS",
"CONFIG_FREERTOS_HZ=100"
],
// Path to compiler perhaps has to be adjusted
"compilerPath": "C:/espressif/tools/xtensa-lx106-elf/esp-2020r3-49-gd5524c1-8.4.0/xtensa-lx106-elf/bin/xtensa-lx106-elf-g++.exe",
//"browse": { // Tag-Parser for Go-To-Definition-Function or tag-database. This is same as "includePath" if omitted
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
} tasks.json{
"options": {
"env": {}
},
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{ // Init by MenuConfig
"label": "Menuconfig",
"type": "shell",
"command": "idf.py",
"args": [
"menuconfig"
],
"presentation": {
"reveal": "always",
},
"problemMatcher": []
},
{ // Build Environment
"label": "Build Project",
"group": {
"kind": "build",
"isDefault": true
},
"type": "shell",
"command": "idf.py",
"args": [
"build"
],
"presentation": {
"reveal": "always",
"echo": true
},
"options": {
"shell": {}
},
// "problemMatcher": ["$gcc"] // Gcc matcher does't work here
"problemMatcher": {
"owner": "cpp",
"fileLocation": "absolute",
"pattern": {
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
},
{ // Flash Environment and Monitor
"label": "Flash & Monitor",
"group": {
"kind": "test",
"isDefault": true
},
"command": "idf.py",
"type": "shell",
"args": [
"-p",
"COM${input:ComPortNum}",
"flash",
"monitor"
],
"presentation": {
"reveal": "always",
},
// "problemMatcher": ["$gcc"] // Gcc matcher does't work here
"problemMatcher": {
"owner": "cpp",
"fileLocation": "absolute",
"pattern": {
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
},
{ // Clean Project
"label": "Clean Project",
"command": "idf.py",
"type": "shell",
"args": [
"clean"
],
"problemMatcher": []
},
{ // Full-Clean Project
"label": "Full-Clean Project",
"command": "idf.py",
"type": "shell",
"args": [
"fullclean"
],
"problemMatcher": []
}
],
"inputs": [
{
"id": "ComPortNum",
"type": "promptString",
"description": "Type the number of used COM port" // this runs obviously only on a windows machine
}
]
} If you are working on a windows machine you can also add a setup script that executes the export.sh script for you: # Generate Environment variable to IDF
export IDF_PATH="<parentPath2Idf>/ESP8266_RTOS_SDK"
# Exectues export.sh in IDF-Path
cd $IDF_PATH
. export.sh
### Note that you must run install.sh first
# Sets Startup initial working directory
cd <parentPath2EspProjects>/Projects
# Adds Compiler to path-variable ## Note: you certainly have to adopt it
PATH=$PATH':/c/espressif/tools/xtensa-lx106-elf/esp-2020r3-49-gd5524c1-8.4.0/xtensa-lx106-elf/bin'
# Adds Editor to path-variable ## Note: you certainly have to adopt it
PATH=$PATH':/c/Users/Jakob/AppData/Local/Programs/Microsoft VS Code' |
I will also share my current version which seems to work fine, I'm using MacOS
{
"configurations": [
{
"name": "ESP8266",
"includePath": [
"${workspaceFolder}/**",
"${workspaceFolder}/build/include/*",
"${IDF_PATH}/components/**",
"${IDF_PATH}/components/freertos/port/esp8266/include" // for some reason its required
],
"browse": {
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
},
"defines": [
"__ESP_FILE__"
],
"compilerPath": "/usr/bin/gcc",
"intelliSenseMode": "${default}"
}
],
"version": 4
}
{
"files.associations": {
"freertos.h": "c"
},
} and .zshrc export PATH=$PATH:$HOME/esp/xtensa-lx106-elf/bin
export IDF_PATH=$HOME/esp/ESP8266_RTOS_SDK
alias get_lx106="export PATH=$PATH:$HOME/esp/xtensa-lx106-elf/bin" |
The line
This way includes like |
😄 Actually I'm not really sure why this works because
should also match this
|
I recommend the use of CMake. This is well supported by VS Code. The extensions "ms-vscode.cpptools" and "ms-vscode.cmake-tools" must be installed. c_cpp_properties.json
The file "compile_commands.json" is created by CMake. cmake-kits.json
When opening the project for the first time, you should be asked for a toolchain. Select Xtensa when doing so. If not, use command "CMake: Select a Kit". |
This my minimal {
"configurations": [
{
"name": "Linux",
"includePath": [
// "${workspaceRoot}/include",
"${workspaceRoot}/build/config",
"${env:IDF_PATH}/components/esp_common/include",
"${env:IDF_PATH}/components/spi_flash/include",
"${env:IDF_PATH}/components/heap/include",
"${env:IDF_PATH}/components/heap/port/esp8266/include",
"${env:IDF_PATH}/components/esp8266/include",
"${env:IDF_PATH}/components/freertos/include",
"${env:IDF_PATH}/components/freertos/include/freertos/private",
"${env:IDF_PATH}/components/freertos/port/esp8266/include",
"${env:IDF_PATH}/components/freertos/port/esp8266/include/freertos"
],
"defines": [
"__ESP_FILE__=\"${workspaceRoot}/main/main.c\""
],
"compilerPath": "${env:HOME}/app/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc",
"cStandard": "gnu17",
"cppStandard": "gnu++14",
"intelliSenseMode": "linux-gcc-x86"
}
],
"version": 4
} |
Here is how I made my setup for windows, hope it is not outdated yet: |
I get weird errors Command "C:/msys32/mingw32/bin/python.exe -m pip install --ignore-installed --no-user --prefix c:\users\denis\appdata\local\temp\pip-build-env-zvvmci --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- "setuptools >= 46.4.0"" failed with error code 1 in None |
For anyone wondering about this in 2025, the setup for Linux that seems to work perfectly is quite simple: {
"name": "Linux",
"includePath": [
"${workspaceFolder}/**", // some configuration files are written to build directory
"${env:IDF_PATH}/components/**" // SDK libraries
],
"defines": [
"__ESP_FILE__" // variable parsing doesn't work in defines section, so using ${file} here won't work
],
"compilerPath": "${env:HOME}/esp/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc", // if you set the compiler path right, then it takes care of include ambiguities
"cStandard": "c17",
"cppStandard": "gnu++17",
"intelliSenseMode": "linux-gcc-x86" // the xtensa compiler is a variant of gcc, however there is no perfect match for the architecture, but x86 should be good enough, since ESPs use 32-bit architecture
} |
Im struggling with a lot of problems with making VSCode usable for ESP8266-RTOS-SDK, it would be nice if there would be some setup instructions for VSCode.
The text was updated successfully, but these errors were encountered: