configuration and setup clion with esp-idf
- Create directory esp
mkdir -p ~/esp
cd ~/esp
git clone --recursive https://github.com/espressif/esp-idf.git
- change directory to esp-idf
cd ~/esp/esp-idf
- run script install.sh
./install.sh
-
Open clion IDE and make new project
-
Setup clion toolchain and cmake configuration Build, Execution, Deployment
Select Toolchains and change C Compiler and C++ Compiler with esp-idf compiler
Example :
C Compiler = /Users/your_user/.espressif/tools/xtensa-esp32-elf/esp-2021r1-8.4.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc
C++ Compiler = /Users/your_user/.espressif/tools/xtensa-esp32-elf/esp-2021r1-8.4.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-g++
1. Add IDF_PATH and PYTHON in CMake options **Example : **
-DIDF_PATH = /Users/your_user/esp/esp-idf
-DPYTHON = /Users/your_user/.espressif/python_env/idf4.4_py3.9_env/bin/python3.92. Add IDF_PATH and PYTHON on Environment **Example : **
IDF_PATH=/Users/ludinnento/esp/esp-idf
PYTHON=/Users/ludinnento/.espressif/python_env/idf4.4_py3.9_env/bin/python3.91. Select Python Interpreter 2. Add 3. Select System Interpreter 4. Search and choose python binary in .espressif/python_env/idf4.4_py3.9_env/bin/python3.9
-
Create directory main
In this directory contain main.cpp or main.c of your esp program
after create main.c/main.cpp, add another CMakeList.txt in this directory
set(SOURCES "main.cpp") idf_component_register(SRCS ${SOURCES} INCLUDE_DIRS "")
-
Add CMakeList.txt inside application project
cmake_minimum_required(VERSION 3.5) include($ENV{IDF_PATH}/tools/cmake/project.cmake) #set(CMAKE_FIND_ROOT_PATH /Users/your_user/.espressif/tools/xtensa-esp32-elf/esp-2021r1-8.4.0/xtensa-esp32-elf) set(CMAKE_C_COMPILER /Users/your_user/.espressif/tools/xtensa-esp32-elf/esp-2021r1-8.4.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc) set(CMAKE_ASM_COMPILER /Users/your_user/.espressif/tools/xtensa-esp32-elf/esp-2021r1-8.4.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-g++) set(CMAKE_C_COMPILER /Users/your_user/.espressif/tools/xtensa-esp32-elf/esp-2021r1-8.4.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc) project(esp32t) include_directories("src")
-
Set up esp-idf environment variables Open Clion Terminal, and running
. $HOME/esp/esp-idf/export.sh
-
Set up project In CLion terminal running :
idf.py set-target esp32
and
idf.py menuconfig
menuconfig used for configuration esp-idf
-
Build esp project In CLion terminal running :
idf.py build
-
Flash
idf.py -p ESP-PORT -b 115200 flash
-
Monitor
idf.py -p ESP-PORT -b 115200 monitor