Developing for ESP32 With CLion on Windows
While browsing Twitch on a slow Saturday night, I came across someone who was using CLion for embedded development for an ESP32 board. One thing that instantly caught my attention was that they used CLion merely as an editor and compiled and flashed the chip on a separate terminal. I asked why they were doing it that way, and they said that setting up a CLion project for the esp-idf development framework was a bumpy road, especially on Windows. Since I never use Windows for development and I’ve never worked with esp-idf, it was a challenge I was willing to take.
This tutorial shows how to set up a project in CLion for ESP32 development on Windows, covering all the necessary steps in great detail. Starting from downloading and installing the esp-idf development framework, we’ll take a closer look at how esp-idf uses specific environment variables and a dedicated Python environment to compile programs.
We’ll create a new CLion project from one of the esp-idf examples and adjust the project settings so that CLion knows about all of the underlying esp-idf dependencies. With the correct project settings, we will close the tutorial by demonstrating some of CLion’s code-insight features and show how to compile, flash, and monitor programs for your ESP32 board directly from within the IDE.
The most important part is to set the ESP_IDF_PATH variable correctly and adjust the PATH variable to include all entries pointing to the .espressif folder. All the necessary settings can be discovered when taking a closer look at what is done by the export.bat script of esp-idf. The second important aspect is that CMake warning messages are meant to be read because they often point directly to missing pieces. We saw that in the video when we needed to set the ESPPORT variable to monitor the ESP32 on the correct port.
Additional Information: