There is a piece of good news here. We are so happy to present the first MVP of the PlatformIO plugin for CLion. Big thanks to JetBrains CLion Team, especially to @elmot for his amazing work.
This is not the final release. We just want to get some feedback and would be thankful if you help us to build a list with the most important features.
Upgrade PlatformIO Core to the latet 4.1.0 or above via pio upgrade.
Generate PlatformIO project for CLion using docs Redirecting...
Open a project with CLion and add PlatformIO to configuration using CLion > Run > Edit Configurations… > [+] > PlatformIO > Give a name PlatformIO Debug
Select “PlatformIO Debug” configuration and press “Debug” icon
Happy debugging with PlatformIO and CLion.
Known issue
[R] icon (hot-restart) currently only resets + halts target, and does not move execution to initial breakpoint. This is will be fixed in the next version. A temporary solution is to put breakpoints in the code and press “Continue”.
For “update all” button, right click on platformio.ini file in your project, scroll down to “PlatformIO”, and you will see “update all”. (button is also present under “Tools” > “PlatformIO”)
For “upload all”, I’m not sure this is possible, because Upload/Debug profile buttons are link to one Cmake Profile, and so one board … Or maybe try create a Cmake special profile for multiple boards ? Not sure if it is possible
If you really want to, you can “trick” Clion to create a dummy target that will launch this command. To do so, you have to edit the CMakeLists.txt as below, then reload it, and a configuration will be added for your command that you can launch as a button:
Now the customisation is permanent, you will have the button with your custom command even if the project has to be reload click on the build button to the left (and not the play button) to execute the command.
No, and that could be the problem, because PIO is doing fine, but Clion is trying to compile something that he doesn’t understand.
Try to remove all the CMake Application from the list, because there are not useful for a project with PIO (except LibsUpdate of course), and keep only PIO configurations:
Be sure to remove “Z_DUMMY_TARGET” in the Executable for LibsUpdate (select nothing instead).
And be sure to launch the command from left button, not the right one, because Clion will try to compile something on its own if you use the right one:
That should remove the “false” compilation error from Clion
and what about if I add an environment to my platformio.ini
how can I reload all the available environements? it seems that clion is not updating the available environment.
This seems to be a current request feature for future versions of the plugin. For my part I always open a separate terminal to do a “pio device monitor”.
why they added some commands only and not all the commands that Visual Studio Code have?
The plugin is still new, there will be updates in the future, you can check the progress here.
and what about if I add an environment to my platformio.ini
how can I reload all the available environements? it seems that clion is not updating the available environment.
Right now, if you add an environment in your platformio.ini, you have to “re-init” PIO (Tools > PlatformIO > re-init), and then add the new environment in Cmake Build Execution Deployment Profiles list of Clion, exactly like this (press + button until all your new environments appear in the list).
should I manually delete the CMakeLists.txt?
Nop, PIO will edit it automatically while “re-init”.
it works ok for one environment and not for others
If you want to do this, you have to add a different build flag for each of your environment in your platformio.ini, like this : build_flags = -D TARGET_MYENV_ONE
And then, after re-init PIO, and adding your different environments in Clion as say above (if not already), Clion will recognize the environment you have selected (in the list next to build button), and update code features accordingly, so it will understand when you write #ifdef TARGET_MYENV_ONE or #ifdef TARGET_MYENV_TWO
but the code is not “highlited” correclty.
If you see in my screenshot the “glowwormluciferinlight” env is selected, but in the code, the TARGET_GLOWWORMLUCIFERIN is highlited, I expect to see the TARGET_GLOWWORMLUCIFERINLIGHT highlited instead.