Skip to content

nRF DeviceTree features

See the following section for an overview of the nRF DeviceTree extension features related to the devicetree language support. These are available for development of the nRF Connect SDK applications in VS Code.

Code completion

With context-aware autocompletion, you can speed up the process of adding properties, nodes, and values to overlay files.

Devicetree code completion

Add missing required properties

nRF DeviceTree includes a code action to add all required properties missing from a devicetree node. When applicable, a button with a light bulb icon appears next to the selected node in the Editor. To add the missing required property, click on this icon, and then Add required properties.

Add required properties

Syntax validation and highlighting

Built-in syntax checking and linting for the devicetree files validates the tree structure and points out potential issues in the tree, such as overlapping assignments or missing references.

Validating a node

Copy C identifiers

References to a node or property can be copied from the devicetree file and pasted into C code.

Copy from the devicetree file

To copy C identifiers directly from a devicetree file, select the string in the file, right-click and choose Devicetree: Copy C identifier.

Copy identifier

If the selected symbol has a corresponding C macro, like DT_PROP(DT_NODELABEL(adc), label), it will be copied to the clipboard. A message shows up in the Status Bar with the copied string.

Copied identifier

Copy C identifier of a node

To copy the C identifier of a node:

  1. Expand the appropriate section in the Devicetree View.

  2. Hover your mouse over the node you want to copy.

  3. Click on the More actions... menu icon.

  4. Click on Copy C Identifier of Node.

Copy C Identifier of Node

C file macro argument completion

The extension will use data from the most recent devicetree context to provide completion items for the arguments of the following macros in C:


C macro completion

C file directive completion

The extension includes autocompletion for the C preprocessor files' #include directives.

C file #include directive completion

Bindings files code completion and schema validation

The devicetree bindings are described in YAML files. This extension uses a schema file for Red Hat's YAML extension, which provides code completion, documentation, and validation for YAML files under dts/bindings.

Bindings completion

Show compiled output

To view the compiled devicetree output file, click the Show Compiled Devicetree Output button located in View Toolbar of the Devicetree View. A new screen opens with the compiled output in one file. Click on any context item in the Devicetree View and the compiled output will jump to that section in the code.

Show Compiled Devicetree Output

View definition source file

You can view the source file of a definition that is within the compiled devicetree output file. Select a line from the compiled devicetree output file and the source of that definition will be shown at the end of that line.

Compiled devicetree output file