Xtensa IoT framework.
- Download and install VSC
- Install VSC Extensions
- Setup Toolchain
- Setup and verify environment variables
- Create project
- Configure ESP32
Below link will point to the latest version of the Microsoft code editor which is free and open source.
Go ahead and download the latest release.
Visual Studio Code
After the installation open editor and go to 'Extensions' section to browse all available vsc extensions.
You need the following:
- C++
- Native Debug
- Code Outline or AL Outline (to display and navigate properties)
Next you need tools for compilation and linking your projects Go to below link and follow instructions https://docs.espressif.com/projects/esp-idf/en/feature-cmake/get-started/index.html#setup-toolchain
You need to download all-in-one esp-idf tools installer https://dl.espressif.com/dl/esp-idf-tools-setup-1.1.exe and get the latest ESP-IDF framework
Make sure all path and idf variables are present and pointing to right locations.
IDF_PATH is cruicial.
You can use run-command way to set them up with setx IDF_PATH "...your path to esp-idf folder"
Example setup:
Note:
If you want to quickly install whole environment with esp-idf framework - I created a batch file that will pull esp-idf from github repository, download it to user profile location (C:\Users\NAME\ESP32) and set the IDF_PATH automatically.
IMPORTANT: Please run this file as administrator!!
esp32setenv.bat
Make sure you install Git for Windows
Git Client download page
To create project that can properly compile you need the following:
keybindings.json is located in C:\Users....your profile name.... \AppData\Roaming\Code\User This file will allow to run compilation etc with just pressing keyshortcut
alternatively and what I recommend - use the command line from terminal to compile,monitor and run your app
idf.py -p COM3 flash
-- wil compile and flash the board on port COM3idf.py -p COM3 monitor
-- will display live serial monitor in console
if you want to flash and immefiately monitor use
idf.py -p COM3 flash monitor
build
will build project with changes
fullclean
will erase old files and refresh the whole build for new compilation
Typical project file structure:
To open your project you must choose 'Open Folder' option
Before compiling your project run the command to set up all necessary settings that IDF will use for your ESP32 chip.
In Integrated Terminal window run idf.py menuconfig
If you are not in Powershell but in cmd.exe - you can run powershell idf.py menuconfig
Example:
Hit ESC until menuconfig asks about saving the configuration.
Confirm save.
To use CMake environment your project must have CMakeLists.txt (just like Make files) in project directory
It usually contains f.ex. below lines
set(MAIN_SRCS
main/spi_master_example_main.c
main/pretty_effect.c
main/decode_image.c)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(spi_master)
You can change them to the project files you have. Follow the examples provided in examples folder together with idf framework that you downloaded There are CMakeList.txt files in different folders that will help you how to add directories and component references
I will post more later on CMake... ;)