Working with Zephyr® RTOS projects using West
In CLion, you can open, build, and run/debug Zephyr projects with a built-in West plugin. Compared to CLion’s CMake integration, the West integration provides an easier way to set up and build Zephyr projects. Although you can still use CMake, we recommend using CLion’s native West integration.
This guide explains how to build, run, and debug a Zephyr application.
Install Zephyr, West, and Python dependencies on your system.
Install Zephyr SDK on your system.
Click Open on the Welcome screen or select File | Open from the main menu.
Select a directory with a Zephyr project that contains the CMakeLists.txt file.
Open your project settings via Settings | Build, Execution, Deployment | Embedded Development | West.
tip
You may see the following CMake error message in the West tool window when opening a Zephyr West directory for the first time:
BOARD is not being defined on the CMake command-line, in the environment or by the app. Fix...
This means you have not yet configured your board in the West project settings. Click Fix…, and the West dialog with your project settings will open.
CLion will automatically fill in the Toolchain, West executable, and Build directory fields with default values in the West dialogue. You can change them if necessary.
Select your board name in the corresponding field if it has not already been selected automatically.
Click OK. CLion will load the project and display the results in the West tool window:
CLion detects the project build targets and creates the native West configurations for them. To set up additional parameters:
Select Run / Debug Configurations | Edit Configurations… from the main toolbar or Run | Edit Configurations… from the main menu. The West Run/Debug Configurations dialog will open.
Copy the command line arguments you use to run the
west flash
andwest debug
commands in the Terminal. Paste them into the Flash options and Debug options fields, respectively. If you select the Launch Run and Debug on the QEMU emulator option, the Flash options and Debug options fields will become unavailable.Click OK, and your program will be ready to run and debug.
To run or debug your program, you can use the configuration widget (click or ), the Run menu, or the gutter icons next to the program’s entry point.
Here is an example of debugging a Zephyr program:
note
CLion supports multi-threaded RTOS debugging, which allows you to view each thread separately. To do this:
Enable the RTOS integration in Settings | Build, Execution, Deployment | Embedded Development | RTOS Integration.
Set
CONFIG_THREAD_MONITOR
andCONFIG_THREAD_NAME
in your prj.conf files.
If you have an existing Zephyr project that you run as a CMake one, you can convert it to a West project. To do this, right-click a CMakeLists.txt file in your project directory and select Convert to West Project from the context menu.
You can also convert a West project back to CMake. Right-click a CMakeLists.txt file in your project directory and select Convert to CMake Project from the context menu.
Thanks for your feedback!