CLion Tutorial – Device Tree Files

Device tree is a hierarchical data structure primarily used to describe hardware.
CLion recognizes .dts/.dtsi files and provides code assistance and code analysis features.

Configure Development Board (Zephyr) If you are using Zephyr, make sure to select the development board you are using in the settings:
Go to Settings | Languages & Frameworks | Device Tree.

Use one of the following options:
  • Derive Zephyr settings from CMake

    The option to synchronize with CMake is enabled by default. Note that the find_package(Zephyr) command is needed to obtain the development board name.

👇 Click to Claim 👇
👉 C Language Knowledge Resource Collection
  • Specify the Zephyr installation path and select the development board

    Uncheck the synchronize with CMake checkbox. If the Zephyr installation path is not automatically detected, please provide the path and select the development board from the list:

    CLion Tutorial - Device Tree Files

Coding with Assistance

Here are several examples of coding assistance features available for device tree files.

  • Syntax highlighting and code formatting:

    CLion Tutorial - Device Tree Files

    You can configure the color scheme and code style in Settings | Editor | Color Scheme | Device Tree and Settings | Editor | Code Style | Device Tree.

  • Code folding for nodes:

    CLion Tutorial - Device Tree Files

    CLion Tutorial - Device Tree Files

    Press Ctrl+Shift+Numpad – to collapse all code snippets, and Ctrl+Shift+Numpad + to expand all code snippets.

  • Quick documentation for device tree elements:

    CLion Tutorial - Device Tree Files

    When displaying documentation, CLion loads additional information from the Zephyr bindings.

    By default, quick documentation is displayed on mouse hover.

  • Structure view of device tree files:

    CLion Tutorial - Device Tree Files

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

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

    CLion Tutorial - Device Tree Files

    CLion Tutorial - Device Tree Files

  • A line marker indicates overridden properties. You can also use it to navigate to the original properties:

    CLion Tutorial - Device Tree Files

    CLion Tutorial - Device Tree Files

  • Automatically insert missing semicolons, matching braces, and quotes while typing.

Quick Fixes and Intentions for Device Tree Code

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

    You can explore and adjust the checklist in Settings | Editor | Inspections:

    CLion Tutorial - Device Tree Files

  • For example, CLion verifies the names in your code:

    CLion Tutorial - Device Tree Files


Hot Recommendations
  • Interviewer: “How many offers do you have?” How to respond?

  • Adjusting expected salary from 40K to 20K, getting bombarded by HR…

  • Undignified but lucrative jobs…

Leave a Comment