Configure CLion to use ESP-IDF

hema20
Posts: 5
Joined: Sun Mar 22, 2020 2:18 pm

Configure CLion to use ESP-IDF

Postby hema20 » Mon Mar 23, 2020 10:25 am

Hello,

I am trying to use the ESP-IDF with CLion, but I have some problems with the configuration. Has anybody some advice to make it running and can explain which settings in the Preferences menu are necessary? I installed everything as written in the ESP-IDF documentation on macOS and it works running the terminal.

I added the IDF_PATH/ PATH in the environment table + CMake options and I linked the toolchain as you can see on the attachments.
When loading the hello_world project into CLion I am getting the message:

-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- The ASM compiler identification is unknown
-- Found assembler: xtensa-esp32-elf-gcc

and a CMake Error for each compiler like this one:

The CMAKE_CXX_COMPILER:

xtensa-esp32-elf-g++

is not a full path and was not found in the PATH.

Tell CMake where to find the compiler by setting either the environment
variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
to the compiler, or to the compiler name if it is in the PATH.

It is probably easy to fix, but I'm stuck at the moment and can't find a solution.

Thanks for your help
Attachments
Toolchain.png
Toolchain.png (72.85 KiB) Viewed 14497 times
CMake.png
CMake.png (101.94 KiB) Viewed 14497 times

ESP_igrr
Posts: 2071
Joined: Tue Dec 01, 2015 8:37 am

Re: Configure CLion to use ESP-IDF

Postby ESP_igrr » Mon Mar 23, 2020 11:28 am

I think it is possible to use CLion with IDF v4.0 and later. Starting from IDF 4.0 we have fixed some bugs in our builds of xtensa-esp32-elf-gcc toolchain, which prevented it from being correctly detected by CMake. Looking at the screenshot it seems you are using IDF v3.2 with the older version of the toolchain (based on GCC 5.2).

hema20
Posts: 5
Joined: Sun Mar 22, 2020 2:18 pm

Re: Configure CLion to use ESP-IDF

Postby hema20 » Tue Mar 24, 2020 10:25 am

Thank you for your input. I think the error was caused by installing the newest IDF (4.2) with an older version (3.2.2) of the toolchain. I deleted all the files and started from scratch again. I want to mention that it is necessary to create the ~/esp folder first when using the standard toolchain, because otherwise all the commands from the documentation don't work. The xtensa-files are then installed in this directory: /Users/<username>/.espressif/tools/xtensa-esp32-elf/esp-2019r2-8.2.0/xtensa-esp32-elf/bin.

Unfortunately it is still not working in CLion, even though I have installed Git 2.26 and set the path to the git executable (/usr/bin/git) I get this message:

-- Could NOT find Git (missing: GIT_EXECUTABLE)
CMake Warning at /Users/<username>/esp/esp-idf/tools/cmake/git_submodules.cmake:4 (message):
Git executable was not found. Git submodule checks will not be executed.
If you have any build issues at all, start by adding git executable to the
PATH and rerun cmake to not see this warning again.


In addition there are some issues with the CMAKE_MAKE_PROGRAM and IDF variables:

CMake Error: Error required internal CMake variable not set, cmake may not be built correctly.
Missing variable is:
CMAKE_MAKE_PROGRAM
-- Generating done
CMake Warning:
Manually-specified variables were not used by the project:
IDF

hema20
Posts: 5
Joined: Sun Mar 22, 2020 2:18 pm

Re: Configure CLion to use ESP-IDF

Postby hema20 » Thu Mar 26, 2020 9:03 am

hema20 wrote:
Tue Mar 24, 2020 10:25 am
Thank you for your input. I think the error was caused by installing the newest IDF (4.2) with an older version (3.2.2) of the toolchain. I deleted all the files and started from scratch again. I want to mention that it is necessary to create the ~/esp folder first when using the standard toolchain, because otherwise all the commands from the documentation don't work. The xtensa-files are then installed in this directory: /Users/<username>/.espressif/tools/xtensa-esp32-elf/esp-2019r2-8.2.0/xtensa-esp32-elf/bin.

Unfortunately it is still not working in CLion, even though I have installed Git 2.26 and set the path to the git executable (/usr/bin/git) I get this message:

-- Could NOT find Git (missing: GIT_EXECUTABLE)
CMake Warning at /Users/<username>/esp/esp-idf/tools/cmake/git_submodules.cmake:4 (message):
Git executable was not found. Git submodule checks will not be executed.
If you have any build issues at all, start by adding git executable to the
PATH and rerun cmake to not see this warning again.


In addition there are some issues with the CMAKE_MAKE_PROGRAM and IDF variables:

CMake Error: Error required internal CMake variable not set, cmake may not be built correctly.
Missing variable is:
CMAKE_MAKE_PROGRAM
-- Generating done
CMake Warning:
Manually-specified variables were not used by the project:
IDF
I couldn't solve these errors, but just in case anyone has the same problem, using the ESP32 Plugin in CLion with the following steps works:

1) Preferences->Build, Execution, Deployment->ESP32 config:

ESP32 Espressif SDK path: path to esp-idf folder (/Users/<username>/esp/esp-idf)
cross compile path: path to xtensa bin folder (/Users/<username>/.espressif/tools/xtensa-esp32-elf/esp-2019r2-8.2.0/xtensa-esp32-elf/bin)
Default seriell port: esp32 connected to serial port (check path in terminal with ls /dev/cu.*)

2) Preferences->Build, Execution, Deployment->Toolchain:

Should be detected automatically by CLion, if not use Bundled CMake, let it detect the make file and set the path to C Compiler, C++ Compiler and Debugger:

C Compiler: /Users/<username>.espressif/tools/xtensa-esp32-elf/esp-2019r2-8.2.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-cc
C++ Compiler: /Users/<username>/.espressif/tools/xtensa-esp32-elf/esp-2019r2-8.2.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-c++
Debugger: /Users/<username>/.espressif/tools/xtensa-esp32-elf/esp-2019r2-8.2.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-gdb

3) Preferences->Build, Execution, Deployment->CMake:

CMake options: -DCMAKE_TOOLCHAIN_FILE=CrossCompiler.cmake
Environment: PYTHON=/Users/<username>/.espressif/python_env/idf4.2_py3.7_env/bin/python3;PATH=/Users/<username>/esp/esp-idf/tools:/Users/<username>/.espressif/tools/xtensa-esp32-elf/esp-2019r2-8.2.0/xtensa-esp32-elf/bin:/usr/bin:/sbin:/bin:/opt/bin

4) Preferences->Build, Execution, Deployment->Python Interpreter:

Select Python from the Espressif installation folder: /Users/<username>/.espressif/python_env/idf4.2_py3.7_env/bin/python3

5) Edit .zshrc

This makes it faster to flash ESP32, so you only have to run the terminal with "idf.py flash" inside CLion:

export IDF_PATH=~/esp/esp-idf
. $HOME/esp/esp-idf/export.sh

Who is online

Users browsing this forum: No registered users and 4 guests