CLion 2021.1 Help

Embedded development

This page gives an overview of how you can use CLion as your embedded development IDE. For detailed feature descriptions and setup instructions, refer to the dedicated articles in this section.

Hardware types

CLion supports embedded development for any hardware compatible with GCC or IAR toolchains.

A few examples: ARM-based MCUs like STM32 series, Xtensa (ESP8266, ESP32 ), mips32 (pic32), AVR8 (Arduino ), RISC-V.

For the case of STM32 MCUs and boards, CLion integrates with STM32CubeMX. You can create and open .ioc projects, and get them automatically converted into CMake. Note that some STM32 chips are currently unsupported.

Toolchains and compilers

  • For ARM Cortex-M and Cortex-R MCUs, use the GNU ARM toolchain.

    Install the toolchain, make sure it’s presented in your system PATH, and set the tools up in Settings / Preferences | Build, Execution, Deployment | Toolchain.

    • For STM32 MCUs, STM32CubeMX project setup includes the step of GNU ARM toolchain installation, and CubeMX will generate a linker script and hardware-support libraries for you.

    • For non-STM32 ARM MCUs, you will need to provide the required libraries and the linker script (which you can obtain from your vendor or create manually using the vendor’s standard examples).

  • Non-ARM chips compatible with GCC are also supported. The toolchain setup will be similar to the case of ARM (see above).

You can use the compilers from IAR Systems. CLion's support for the IAR toolchain is available on Windows with MinGW and Linux. Note that CLion does not provide IAR licenses.

As an alternative which would cover the whole embedded environment, consider the PlatformIO ecosystem supported in CLion via the PlatformIO plugin. The plugin provides a wizard for creating CMake-based PlatformIO projects, special configurations for debug and upload, and allows running PlatformIO actions from the IDE.

Build systems

CLion fully integrates with CMake and bundles one of the latest CMake versions, so CMake can be considered as the primary build system for your embedded projects.

However, all the functionality that CLion provides for embedded development (except for STM32CubeMX and PlatformIO support) is also available in the case of Makefiles, as well as any arbitrary build system configured via custom build targets.

If you decide to convert your project into CMake, we recommend that you take our template CMakeLists.txt and adjust it for your needs: fill in the TODO sections and modify the library paths if required.

Flashing and debugging

CLion supports debugging on-chip with OpenOCD or GDB Server.

GDB Server is a more generic option. It covers various vendor-specific cases like ST-Link/V2, Segger J-Link, QEMU, standalone OpenOCD GDB server, PE-Micro, and others.

In CLion, there are special run/debug configurations for both options: OpenOCD Download & Run and Embedded GDB Server, respectively. For STM32CubeMX projects, OpenOCD configurations are created automatically.

These configurations allow switching the client debugger. You can choose between your toolchain’s GDB or CLion’s bundled GDB (for ARM devices) right in the configuration settings.

When you start a debug session, CLion connects the debugger to the MCU and uploads your binary. After that, your firmware running on-chip can be debugged using the entire set of CLion debug features, which includes memory and disassembly view, peripheral view for ARM devices, and a chip reset action.

PlatformIO projects can be debugged using the PIO Unified Debugger, with all the debug features available as well.

Debugging is not supported for the platforms that lack GDB support. Flashing the target chip in this case should be done using a specific utility (like Avrdude for AVR).

Learn more

In addition to the web help articles, you may want to take a look at these posts on embedded development from CLion blog:

Last modified: 16 April 2021