PlatformIO is an open-source ecosystem for embedded development. It allows working with various MCUs (such as ARM Cortex, AVR, MSP430), development boards, frameworks, and environments (Arduino, ESP-IDF, and many others).
CLion's integration with PlatformIO is provided by the PlatformIO for CLion plugin, created in collaboration with the PlatformIO team.
Install the PlatformIO plugin
Creating a project
Call PlatformIO in the left-hand pane.from the main menu and select
Set the project name, choose a board or framework, and click Create.
CLion will generate a PlatformIO CMake-base project, calling the proper PlatformIO command in the background:
For Arduino-based boards, CLion generates main.cpp instead of main.c and fills it with Arduino-specific stub code:
CLion automatically creates CMake profiles for the corresponding
CMAKE_CONFIGURATION_TYPES entries. To configure the profiles, go to :
Notice that Build type corresponds to the PlatformIO environment in use.
The directory specified in Build directory is used for storing CMake build artifacts (in our example, it is called cmake-build-eval_l073z). This directory is excluded from project indexing and is highlighted accordingly in the project tree:
When you create or open a PlatformIO project, configurations for upload and debug are created automatically:
Add PlatformIO configurations
Select Edit Configurations in the switcher or call from the main menu.
In the left-hand pane, click and select the PlatformIO node. Choose among the configuration types:
Configuration Description Debug
Starts a debug session with PIO Unified Debugger by calling
Program Uploads the firmware using a programmer. Test Runs the project's unit tests by calling platformio test. Upload Uploads the firmware by calling
platformio run -t upload.
Upload fs Uploads the firmware to file system SPIFFS by calling
platformio run -t uploadfs.
Set the configuration name and click Apply.
Note that all PlatformIO configurations include Build as a pre-launch step. If you need to build the project separately, select a configuration in the Edit Configurations dialog and remove () the Build step in the Before launch area.
Besides the run/debug configurations, a few PlatformIO commands are also available as IDE actions. Use on the main menu or right-click platformio.ini in the Project tree and select the PlatformIO node:
Build Production - calls
platformio runto build the project in release configuration.
Build - calls
platformio run --target debugto build the project with debug information and all optimizations turned off.
Clean - calls
platformio run --target clean.
Check - calls platformio check for static code analysis.
Re-Init - calls
platformio init. Use this action to update your project following the changes in platformio.ini.
Update All - calls platformio update.
Monitor - calls platformio device moitor.
Home - calls
platformio homeand opens PlatformIO Home in your browser.
Code assistance in platformio.ini
The Ini plugin, which comes in pair with the PlatformIO plugin, provides syntax highlighting, code formatting, and structure view for .ini files.
To open the structure view for platformio.ini, open it in the editor and then select from the main menu or press Ctrl+F12.
You can navigate to a property via Go to Symbol (Ctrl+Alt+Shift+N or on the main menu).
Also, the Ini plugin provides inspections for detecting duplicate properties and sections. You can change the severity of these inspections and turn them on/off in .