CLion 2024.2 Help

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 and Python dependencies

  1. Install Zephyr, West, and Python dependencies on your system.

  2. Install Zephyr SDK on your system.

Open your West project

  1. Click Open on the Welcome screen or select File | Open from the main menu.

  2. Select a directory with a Zephyr project that contains the CMakeLists.txt file.

  3. Open your project settings via Settings | Build, Execution, Deployment | Embedded Development | West.

    West project settings
  4. 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.

  5. Select your board name in the corresponding field if it has not already been selected automatically.

  6. Click OK. CLion will load the project and display the results in the West tool window:

    West project loading

Set up a run/debug configuration

CLion detects the project build targets and creates the native West configurations for them. To set up additional parameters:

  1. 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.

    West run/debug configuration
  2. Copy the command line arguments you use to run the west flash and west 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.

  3. Click OK, and your program will be ready to run and debug.

Run and debug your program

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:

Zephyr West debugging

    Convert an existing CMake project to West and vice versa

    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.

    Convert CMake project to West

    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.

    Last modified: 04 November 2024