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.
note
The plugin is being actively developed. You can monitor the progress and leave your feedback in the tickets linked to CPP-18398: Support PlatformIO.
Installation
Install PlatformIO
For more information about the installation procedure, refer to official guide.
Go to Settings | Plugins and switch to Marketplace.
Search for PlatformIO for CLion and click Install.
Click Install.
tip
CLion will also install the Ini plugin, which provides code insight for platformio.ini files.
After the installation is finished, click Restart IDE.
tip
By default, CLion takes the path to PlatformIO Core CLI from system path. You can specify a custom location in Settings | Languages & Frameworks | PlatformIO:
Create/open a PlatformIO project
Create a new project
Call File | New Project from the main menu and select PlatformIO in the left-hand pane.
Set the project name, choose a board or framework, and click Create.
CLion will generate a PlatformIO project:
For Arduino-based boards, CLion generates main.cpp instead of main.c and fills it with Arduino-specific stub code:
Open a project
Click Open on the Welcome screen or select File | Open from the main menu.
Navigate to the project folder and select the platformio.ini file.
Click Open as Project.
note
When you open a CMake-based PlatformIO project generated previously, you will be prompted to convert it into the new structure.
If conversion fails, close the project, delete the .idea folder under the project root and reopen the project again.
PlatformIO actions
Several PlatformIO commands are available as IDE actions. Use Tools | PlatformIO on the main menu or right-click platformio.ini in the Project tree and select the PlatformIO node:
Reload PlatformIO Project - calls pio project init. Use this action to update your project following the changes in platformio.ini.
Static Code Analysis - calls pio check for static code analysis.
Update Platforms, Toolchains, etc - calls pio pkg update.
PlatformIO Home - calls pio home and opens PlatformIO Home in your browser.
tip
You can also run PlatformIO commands from CLion's built-in terminal.
PlatformIO tool window
PlatformIO tool window gives quick access to the most used commands and project actions.
Hover over an action to see the corresponding command:
At the bottom, you can find the COM port switcher. Use it to configure the COM port number for upload if you don’t want to rely on automatic port detection.
Debug features
The Debug action starts a debug session with PIO Unified Debugger by calling pio debug.
If there is an .svd file for the given platform, CLion will load it automatically. You can also specify it manually:
Coding 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 View | Tool Windows | Structure from the main menu or press CtrlF12.
You can navigate to a property via Go to Symbol (CtrlAltShift0N or Navigate | Symbol 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 Settings | Editor | Inspections | Ini files.