ESP8266: build your projects with CLion IDE

Boris HUISGEN
Boris HUISGEN
|

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

Build 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

Build 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

Terminal configuration

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
Boris HUISGEN
Boris HUISGEN
Blog owner
  • #esp8266
  • #clion
  • #cmake