table of Contents
1. Tool download and installation
2. Project configuration and compilation
1. Installation steps
1. Tool download and installation
Use the ESP-IDF tool installer to complete the download and installation of various tools (compilers, governors, Python packages, etc.) used by ESD-IDF with one click. After the installation is complete, you can directly open ESP-IDF in "Start"
Chip, module, development board reference materials
2. Obtain ESP-IDF
During the tool download and installation in the first step, the local copy of ESP-IDF can also be downloaded at the same time, so there is no need to download it manually. If necessary, you can clone the desired ESP-IDF version from github.
git clone -b release/v4.0 --recursive https://github.com/espressif/esp-idf.git
3. Setting tools
The tool download and installation in the first step has been completed, the compilation tool will be silently installed in %USERPROFILE%\.espressif
4. Set environment variables
The tools installed through the above steps have not been added to the PATH environment variable, and these tools cannot be used through the "Command Window". Therefore, some environment variables must be set. This can be done through another script (%userprofile%\esp\esp-idf\export.bat) provided by ESP-IDF. The installer ( ESP-IDF tool installer ) can create a shortcut of "ESP-IDF Command Prompt" in the "Start" menu. This shortcut can open a command prompt window and set all environment variables, so there is no need to execute this script
2. Project configuration and compilation
1. Create a project
You can start from the get-started/hello_world project in the examples directory of ESP-IDF . Copy get-started/hello_world to the local ~/esp directory:
cd %userprofile%\esp
xcopy /e /i %IDF_PATH%\examples\get-started\hello_world hello_world
Or use the project in the example directory directly without copying
2. Connect the device
Connect the ESP32 development board to the PC and view the serial port used by the development board (COM1 under Windows, etc.)
3. Configuration
1. Set the target chip (no need, the default will be esp32)
ESP-IDF supports a variety of chips, which are distinguished by using different "target" names in the software. The specific corresponding relationships are as follows:
- esp32 — applicable to ESP32-D0WD, ESP32-D2WD, ESP32-S0WD (ESP-SOLO), ESP32-U4WDH, ESP32-PICO-D4
- esp32s2—for ESP32-S2
So before building the project, you need to set the target chip. Reference link
idf.py set-target {IDF_TARGET} 例如:idf.py set-target esp32
2. Configuration engineering
The first step: Enter the example directory to be compiled, enter "hello_world"
第二步:输入 idf.py menuconfig
4. Compile the project
输入 idf.py build
5. Burn to the device
(1) Enter idf.py -p PORT [-b BAUD] PORT and replace it with the serial port name of the ESP32 development board. or
(2) Input idf.py -p PORT [-b BAUD] flash PORT Replace serial name ESP32 development board, to complete the project to compile and burn, will not need to perform idf.py build up
6. Add a monitor
Enter the idf.py -p PORT monitor command to monitor the operation of "hello_world", and use the shortcut key Ctrl+] to exit the IDF monitor. You can also run the following commands to execute the build, burn and monitor processes at once:
idf.py -p PORT flash monitor