Resources

https://github.com/espressif/vscode-esp-idf-extension/blob/master/docs/tutorial/basic_use.md

NOTE: The esp-idf build system does not support spaces in paths to projects

Create an example project in Visual Studio Code

Menu > View > Command Palette (CTRL+SHIFT+P) > Type: ESP-IDF: Show Examples Projects

(If it doesn’t come up, make sure VS Code isn’t in restricted safe mode)
Choose “Use current ESP-IDF (\path\to\esp-idf)”.
All of the example projects will be shown. Select the project you want and press the “Create project using example” button.
In the Select Folder ensure your path for the project DOES NOT HAVE SPACES in it.

If you don’t want an example project

Its still a good idea to start with a sample such as “blink” as above, so ESP-IDF sets it up with all the latest standard setup. Once created you can do the following:

Close VS Code
Rename the folder to the name you want to use for your project

Delete these unnecessary files:

\####.py

\README.md

Delete these files that you will replace with your own code files:

\main\###_example_main.c
\main\CMakeLists.txt

Copy in all your project source code and make files.

If you have your own standard VS Code config files for a project then replace these files with them:

\.vscode\launch.json

Update project() with a new project name in \CMakeLists.txt (in projects root folder)

Setup the project

Select a target device

Menu > View > Command Palette (CTRL+SHIFT+P > Type: ESP-IDF: Set Espressif device target
Once prompted, select the device
Once prompted, select the board

Configure the project

Menu > View > Command Palette > Type: ESP-IDF: SDK Configuration editor
Wait for it to load
Modify the ESP-IDF project settings as requried. After all changes are made, click save then close the window.

Configure the ESP32

See the Project & ESP32 settings page here

Setup c_cpp_properties.json

Configure the .vscode/c_cpp_properties.json as explained here: https://github.com/espressif/vscode-esp-idf-extension/blob/master/docs/C_CPP_CONFIGURATION.md

If your project doesn’t have a “.vscode” folder, add it using:
Menu > View > Command Palette > Type: ESP-IDF: Add vscode configuration folder

Open “c_cpp_properties.json”
Use the default configuration from the link above (or your own)

Building the project

Build

Press CTRL+E then B   (or enter command “ESP-IDF: Build your project”)

Check the “TERMINAL” window for any issues

Viewing project memory sizes etc

Menu > View > Command Palette > Type: ESP-IDF: Size analysis of the binaries

Programming the device

Menu > View > Command Palette > Type: ESP-IDF: Select port to use
Select the UART or JTAG port you want to use to program the device

Menu > View > Command Palette > Type (or press F1): ESP-IDF: Flash your project
Also available:
ESP-IDF: Flash (UART) your project
ESP-IDF: Flash (with JTag)
ESP-IDF: Select Flash Method and Flash

Debugging

https://github.com/espressif/vscode-esp-idf-extension/blob/master/docs/tutorial/debugging.md

Set your device

Menu > View > Command Palette > Type (or press F1): ESP-IDF: Set Espressif device target

Menu > View > Command Palette > Type (or press F1): ESP-IDF: Select OpenOCD Board Configuration
or
Menu > View > Command Palette > Type (or press F1): ESP-IDF: Device configuration

Debug

Build the project

Press ‘F5’ to start OpenOCD. You’ll see its status appear in the “OUTPUT” window.


USEFUL?
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.

Comments

Your email address will not be published. Required fields are marked *