CLion 2019.1 EAP: CLion for Embedded Development, Part III

Hi,

Here comes a new CLion 2019.1 EAP build 191.5701.24! Get it from our website, Toolbox App, or via a snap package (if you are using Ubuntu). The patch will be available shortly if you are using the previous EAP build.

When sharing our plans for 2019, we identified Embedded development support as one of the major areas of focus for the year. Ilya Motornyy, the author of the OpenOCD + STM32CubeMX plugin, joined our team in late 2018 and has already integrated the plugin into CLion. As a result, starting with this EAP, OpenOCD debugger support and integration with STM32CubeMX is available out of the box:

Embedded dev support plugin

DOWNLOAD CLION 2019.1 EAP

STM32CubeMX & OpenOCD integration

In his two guest blog posts from 2016 and 2017, Ilya shared his experience in programming for microcontrollers in CLion and explained how the flow with the CLion plugin may look like:

Below we’ll briefly summarize the setup and the steps, and we’ll highlight the changes introduced with the plugin’s integration.

Start by getting the tools ready

Currently the plugin targets STMicroelectronics boards (such as STM32 Discovery, Nucleo, or EVAL) and debugging with Open On-Chip Debugger. To start developing, you’ll need the following tools:

  • ARM toolchain. Install and check you have arm-none-eabi-gcc in the system path.
  • OpenOCD debugger.
  • STM32CubeMX, a graphical tool to configure STM32 microcontrollers.

Check the STM32CubeMX and OpenOCD were detected automatically by CLion in Settings/Preferences | Build, Execution, Deployment | Embedded Development or set the correct paths manually.

If you are on Windows, note:

  • Works fine with MinGW and MinGW-w64 environments
  • Doesn’t work currently with Cygwin (CPP-15034) or MSVC
  • As for the debugger:
    • arm-none-eabi-gdb.exe works fine, but doesn’t include correct pretty printers
    • arm-none-eabi-gdb-py.exe works fine, including the pretty printers, but requires python 2.7 (32 bit) installed and throws an error on the first launch (CPP-15502)
    • Bundled GDB works, but throws an error on the first launch (CPP-15502)

The OpenOCD + STM32CubeMX plugin is now bundled, so you don’t have to additionally install anything in CLion.

Create a new project in CLion

When you open File | New Project, the dialog now suggests an embedded project type – STM32CubeMX:
New Project for Embedded

Simply provide the location for the project and CLion will create the .ioc file for you with the default MCU STM32F030F4.
New ioc project

The project sources are not yet generated though, so you should go to STM32CubeMX and run ‘Generate Code’. STM32CubeMX can be opened right from CLion: open the .ioc file and click ‘Open with STM32CubeMX’.

Important:
The newly created project in CLion has the MCU set to STM32F030F4. You can change the MCU in the MCU Selector of STM32CubeMX:
Change MCU
But STM32CubeMX will then reset the project name (as it creates a new one) and you’ll have to provide it in STM32CubeMX’s Project Manager and overwrite the recently created project. You are nearly done here. Just check that the Toolchain / IDE is set to SW4STM32 and check Generate Under Root:
Generate code
You are ready to generate code now!

Go back to CLion and wait until the project is reloaded. A CMake project will be created for you automatically, and CLion will suggest selecting the board config:
Select Board Config

Open an existing project in CLion

If you already have an embedded project, just open it in CLion. When you then first open an .ioc file in the editor, CLion will generate the CMake project for you:
Existing project

What can I do now with my embedded project in CLion?

When the project is loaded and CMake is correctly generated, a few Run/Debug configurations are created automatically for you in CLion, including the OpenOCD one:
OpenOCD configuration

Use it to debug on your microcontroller.

You can also use Tools | CMake | Update CMake Project with STM32CubeMX to regenerate the underlying CMake for your project.
You are now free to create some cool stuff working on your STM board. CLion will assist you with editing and reading the code, and all the smart actions like refactorings and code generation will be available for your project in CLion!

What’s next?

This is just a first step into the vast area of Embedded Development. More smart IDE actions, deeper integration with STM boards and other MCUs, and other big features are definitely coming later this year. Give this EAP build a try, let us know what you think, and stay tuned for more!

By the way, next week, Thursday, February 28th, we’ll do a live webinar on Remote Development with CLion. Remote development on Raspberry Pi will be discussed as an example. There are still a few places left! Register now.

Other improvements

A new IntelliJ Platform feature worth mentioning here is the Recent Locations Popup (Shift+Ctrl+E on Win/Lin, ⇧⌘E on macOS). It lists all the locations that you’ve visited in a chronological order, with the latest visited location at the top and the first visited locations at the bottom.

A few great things to know about this new popup:

  • You can filter by changed code locations.
  • You can search by file name or code snippet: simply start typing, and the instant search will filter the matches for you.
  • You can remove any location from the popup by pressing Backspace or Delete.

Recent Locations Popup

That’s it. Read the full release notes if you like, and download and try the EAP build today. We are looking forward to your feedback!

DOWNLOAD CLION 2019.1 EAP

Your CLion Team
JetBrains
The Drive to Develop

This entry was posted in Announcement, Early Access Preview and tagged , , , . Bookmark the permalink.

45 Responses to CLion 2019.1 EAP: CLion for Embedded Development, Part III

  1. Anton says:

    Control+Shift+E doesn’t do anything on Windows here. Moreover, it seems like CLion “remembers” the pressed Control key after using this shortcut: I can’t type at all until I restart CLion. I assigned an additional shortcut for this action and it works well so far.
    There is a chance it’s my own local issue though.

    • Anastasia Kazakova says:

      Try to switch to the default keymap, does it has the same issue? Can you also check Control+Shift+E isn’t used at your system?

  2. Kevin says:

    Why integrate STM32CubeMX on that level?
    Ever thought about embedded projects which are not based on STM32CubeMX?
    What about native GDB server support instead of openOCD server, any plans on this?

    • Anastasia Kazakova says:

      Remote GDB server debug is already there in CLion. OpenOCD is a very popular embedded debugger, that’s why we’ve integrated it.
      Regarding the STM32CubeMX – it’s one of the most popular ways to generate project for STM board. Other boards/mcu will definitely come, but later. That’s just a first step.

    • elmot says:

      If you do not use STM32, you can completely ignore STM32CubeMX part of the plugin and use virtually any kind of MCU and a probe, which are supported by GCC and OpenOCD. In this case, you need manually write CMakeLists.txt, then find suitable CMSIS and linker script.

      Then you need to make your own Run Configuration of type “OpenOCD Download & Run”. For instance, someone reported PIC32 MCU working with CLion, and I personally tried nrf51XXX MCU + FTDI/SWD probe (I believe this is cheapest possible JTag ever).

  3. Henry Borchers says:

    I’m not an embedded developer but I find this is super interesting. I love CLion so much that it make me almost interested enough to try embedded programming. This is not something that I’ll really use for my work but I’m glad that you have this in here. I’m sure it’ll make a number of people out there very happy. I love whenever I can move away from other tools for CLion and other Jetbrains programs in my projects.

    Side note: I hope that the MSVC debugger mentioned in the roadmap is coming along well, and at least a preview will still come out for 2019.1. I’m sure you can’t comment on it right now but just wanted you know that you have me very excited about this feature.

    Keep up the excellent work!

    • Anastasia Kazakova says:

      Thank you for your feedback and we are really glad to impress you and push to some experiments with embedded dev!

      As for MSVC debugger, it’s indeed under development. However, I doubt it will be ready in 2019.1, but definitely, we’ll start the preview with 2019.2 EAP then.

      • Henry Borchers says:

        Anastasia, You are very welcome!

        Don’t worry, I completely understand about pushing the MSVC debugger preview to 2019.2 EAP. You explained what was involved a while back and it sounds like a very large and challenging task. I’m just happy that you’re working on it and I’ll get to use it soon.

  4. Richard Vowles says:

    You should consider direct support for PlatformIO. It would greatly enhance the usefulness and decrease the pain of embedded development if CLion had similar if not better integration than vscode.

  5. Samuel Urban says:

    I was using segger embedded studio for all my mcu related work and clion for pretty much everything else.. you can’t imagine how happy am i knowing that you support STMCube!

    Anyway, there are still some issues with IDE itself(especially slow indexing on large files/projects) but clearly, one of the best i’ve ever used. I also want to say that i’ve seen large steps forward(using clion from 2017-ish) in your c++ in time analysis as the completition is more and more contextual, templates and lambdas are not giant red block of text marked as syntax error and so on.. Thank you very much for this amazing IDE, but please, really look forward into those bottlenecks as they are becoming annoying at some point :)

    • Anastasia Kazakova says:

      Thank you very much for your feedback! We do appreciate it greatly and really happy you are staying with CLion for that long!

      And I want to assure you that performance is our top priority for now and we do our best to address such issues as much as we can.

  6. Taw says:

    I really hope that the team will concentrate also on bugs, there are a lot of very old bugs which are not solved yet are annoying, example: CPP-7364, CPP-5501.
    Also for me is unusable on Windows because of CPP-15505, it loads for 9 hours and then it fails…

    Instead, in 2019.1 EAP, we got naming conventions. :-)

    • Anastasia Kazakova says:

      We definitely fix bug and currently investigating your issue with CMake load. However, while some users care about some particular bugs, others are waiting for some features that are critical for their workflow. Naming is one of such features. So we try to share our resources among both parties)

      • Taw says:

        Thank you, I understand that your resources are limited.
        So some users consider naming conventions “critical” for their workflow…funny.:)
        Regarding my issue, I will try to use VStudio or WSL with CLion, perhaps it will work.

  7. Richard Vowles says:

    Anastasia – that is not “nicely” that is cmake with the command line. Please compare the VSCode integration. However if you are not wishing to play in this space, thats ok too.

    • Anastasia Kazakova says:

      Why the command line? You can configure the File Watcher that will regenerate CMake project every time you touch the Platform IO files. We’ve discussed that with Platform IO team and they seem it’s a nice way to go. Anything in particular you would like to see in terms of integration?

  8. Belussi says:

    Hi,

    Native embedded development support is something I’m waiting for a very long time. I’m using elmot’s plugin with Microchip MCUs and is working perfectly. Unfortunately, this is still not enough to convince people to move from eclipse. For example, memory view is something what should be added (I know that some work is in progress).To be honest, without OpenOCD plugin I wouldn’t buy CLion for sure.

    Thanks,

  9. Iziren says:

    Hi is there anything yet for using CLion with TM4C Series Microcontrollers (ARM-M Microcontrollers from Texas Instruments). Thanks!

    • elmot says:

      Yes, you can write code, compile, flash and debug your application with CLion. There is OpenOCD support for TI Stellaris MCU family. Most probably you need to migrate your project to CMake for that.

  10. Oleksandr Gusiev says:

    Looks good as a first step, but it is far far from perfect, we need deep integration with CubeMX, like in Atollic or IAR, current level of manual configuration is unacceptable for every day usage. Hope it will be as easy, as “create new project from CubeMX -> next -> next -> finish” in future, otherwise it is noncompetitive.

    • Anastasia Kazakova says:

      Indeed, that’s just a very first step. We communicate with STMicroelectronics and hope CubeMX will soon get some API to do the deeper integration.

  11. Regaron says:

    PlatformIO plugin like that of VSCode or Atom would be nice.

  12. Belussi says:

    Hi,

    What about including SVD files for example for Microchip MCUs? It would be good to state of all peripherals.

    Second thing is RTOS-aware debugging. VSCode has it.

    Thanks,

  13. Hauke Radtki says:

    I was able to make this example work. But my main intention to switch to CLion would be good (host) test integration.

    I’m currenlty failing at setting up two toolchains with integration to CLion needed to both crosscompile for the target and compile tests for the host system.

    Is test support considered/being worked on for embedded development in CLion?

    • Anastasia Kazakova says:

      Not sure what you mean under “test support”. Any specific testing tool/framework?

      • Hauke Radtki says:

        Basically: Run tests on non-target dependent modules on the host machine (means, compile tests for x86 and run them on the development pc) with any testing framework (be it GTest, Catch, Boost.Test) from within the IDE.

        For this CMake/CLion need to have two toolsets. But since the arm-none-eabi-gcc toolchain only configured within CMake and not within CLion, this doesn’t work out. When creating a test launch configuration it would build for the target (arm) and fail to execute on the host (x86).

        • Elmot says:

          Your desired setup looks quite complicated, and we are moving forward to make such kind of setups easier in future CLion version. Anyway, you may try to setup your project using some tricks. First of all, you may move toolchain definitions out of your CMakeLists.txt into toolchain file, as it was done here, and then configure two CMake profiles, one with that toolchain file for ARM and one without, for host x86.

  14. Klaus Nagel says:

    I appreciate your work for embedde development very much!
    I dont like the out of the box, often not stable eclipse based solutions from the semicoductor vendors for professional development. At the moment i use the SEGGER Jlink Probe with the GDB Remote Debug Debug cofiguration. What I’m missing there is the possibility of a build before launch step like in the OpenOCD Configuration. Do you plan to integrate this also in the GDB Remote Debug configuration?

  15. skyyu.zhang says:

    After having CLion for Embedded Development I found some questions. When I use cubeMX to create demo with Fatfs system. then I write some code to verify it is ok to run . compiling is successful !!!! but unfortunately it not work . The question seem to be some “low hardware driver error”. so it can not create any file on my tf card. but when I use SW4STM32 to compile it , it works !!!!! I don’t why?? the same code also it can be compiled successfully on any software keil SW4STM32 CLion but not the same resultcompile !!!! help me

    • Elmot says:

      Sounds really strange, because CLion uses the same compiler as SW4STM32 does, but keil uses it’s own compiler. Most likely, there is a problem with the project setup. And I have not enough information to find it, sorry.

  16. Sergey Kilimnik says:

    CLion 2019.1.2

    I create new Embeded developer project, CLion creates .ioc file and instead of “STM32F030F4 configured” I see “No MCU Configured, invalid file content”. Opening in MX Cube, changing boards doesn’t help at all. Any of old ioc file I’ve tested doesn’t work.

Leave a Reply

Your email address will not be published. Required fields are marked *