CLion 2024.1 Help

Device tree files

A device tree is a hierarchical data structure primarily used to describe hardware.

CLion recognizes .dts/.dtsi files and provides them with сode assistance and code analysis features.

Configure the board (Zephyr)

If you are working with Zephyr, make sure to select the board you are using in the settings:

  1. Go to Settings | Languages & Frameworks | Devicetree.

  2. Use one of the options:

    • Derive Zephyr settings from CMake

      The Sync with CMake option is enabled by default. Note that the find_package(Zephyr) command is required to fetch the board name.

    • Specify the Zephyr installation path and select the board

      Clear the Sync with CMake checkbox. Provide the path to Zephyr installation if it was not detected automatically and select the board from the list:

      Selecting the board

Code with assistance

Find below a few examples of coding assistance features available for the device tree files.

  • Syntax highlighting and code formatting:

    Syntax highlighting and code formatting for device tree
  • Code folding for nodes:

    Code folding gutter icon
    A folded block
  • Quick documentation for the device tree elements:

    Quick documentation for device tree elements

    By default, quick doc is displayed on mouse hover. Refer to Quick documentation for instructions on how to change this, as well as general information about this feature.

  • Structure view for the device tree files:

    Structure view for device tree

    To open the Structure view, go to View | Tool Windows | Structure in the main menu or press Alt+7.

  • Code completion for standard properties, /commands/, labels, and code elements:

    Code compeltion for dts commands
    Code completion for dts elements
  • A line marker to indicate overwritten properties. You can also use it to navigate to the original property:

    Highlighting overwritten properties
    Navigating to the overridden property
  • Automatic insertion of missing semicolons, matching braces, and quotation marks while you type.

Quick-fixes and intentions for the device tree code

  • CLion provides a set of checks for your device tree code.

    You can explore and adjust the list of inspections in Settings | Editor | Inspections:

    Devicetree inspections

    For example, CLion validates the names in your code:

    Names validation
Last modified: 11 February 2024