ESP8266: build your projects with CLion IDE

Boris HUISGEN October 1, 2019

development esp8266 clion cmake

The next RTOS SDK releases (version 4+) are going to use CMake as the default build process but it is already present into the current version 3.2. For owners of CLion IDE, this post will explain how to configure your favorite IDE for that purpose.

Create your project

First copy the getting-started project template present in the exemple directory of the SDK.

Open it inside the IDE, it will be detected as a CMake project.

Configure a new toolchain

Open the IDE settings and go to Build, Execution, Deployment / Toolchains:

  • Create the toolchain xtensa-lx106-elf and specify the required paths of compiler tools gcc and g++.

Configure the CMake profile

Go to Build, Execution, Deployment / CMake:

  • Select the newly created toolchain xtensa-lx106-elf

  • Add the CMake option:

    -DIDF_PATH=/home/boris/.local/share/ESP8266_RTOS_SDK
  • Add these environment variables:
    IDF_PATH=/home/boris/.local/share/ESP8266_RTOS_SDK;PATH=/home/boris/.local/share/xtensa-lx106-elf/bin
    BATCH_BUILD=1

Configure the IDE terminal

Go to Tools / Terminal:

  • Configure the terminal environment:
    IDF_PATH=/home/boris/.local/share/ESP8266_RTOS_SDK
    PATH=/home/boris/.local/share/xtensa-lx106-elf/bin:/usr/bin:/bin:/home/boris/.local/share/ESP8266_RTOS_SDK/tools
  • Set the generation path to build/

Reload the project

Reload the CMake project by right click on the project name in the project view and check that no error is displayed. Build the project.

Flash your device

To flash the firmware into your ESP device, select the build configuration flash and execute it.

You can also open the IDE terminal to execute the same command with idf.py:

 
    $ idf.py flash monitor

See also

Python: thread-safe implementation of a singleton
Read more
Let’s Encrypt : générer un certificat wildcard
Read more
NetworkManager : configuration d’une interface dummy
Read more