Devicetree and Kconfig support - nRF Connect for VS Code
Skip to content

Devicetree and Kconfig support

The extension pack provides dedicated features to support nRF Connect SDK application development with Devicetree and Kconfig. These are two of several configuration systems that the nRF Connect SDK and Zephyr use for defining hardware- and software-related options.

Snippet support

The extension provides support for snippets when working with either Devicetree or Kconfig. This is a Zephyr mechanism for defining portable build system overrides that could be applied to any application. Read Zephyr's Snippets documentation for more information.

Devicetree overview

Devicetree is a hierarchical data structure used to describe hardware in Zephyr and the nRF Connect SDK.

Devicetree source files are used by Zephyr and the nRF Connect SDK to describe hardware, provide hardware initial configuration, as well as modify the hardware-related configuration of an application.

Applications can use devicetree files to provide additional board functionality such as enabling a peripheral that is disabled by default, or selecting a sensor on the board for an application-specific purpose. Along with the Kconfig system, this makes it possible to reconfigure the kernel and device drivers without modifying the source code.

The devicetree files include the following files:

  • *.dts files - the base devicetree files.
  • *.overlay files - additional files that extend the base devicetree files with application-specific modifications.
  • *.dtsi files - partial devicetree files that the preprocessor includes into the base devicetree files when the building starts.

The build system puts together these three file types to complete the devicetree configuration context of a build configuration. You will be mostly working with *.dts and *.overlay files.

To learn more about Devicetree, read the following pages:

Devicetree support in the extension

The extension pack provides different layers of support for working with the devicetree files, mostly through its nRF DeviceTree extension. The support ranges from devicetree language support and structuring the devicetree information in the devicetree context to dedicated GUI for editing the devicetree configuration. The nRF DeviceTree extension takes the information about devicetree boards and bindings from the files whose paths are defined in the devicetree.modules setting.


The nRF DeviceTree extension follows the devicetree configuration structure, which can change over time. For example, in the nRF Connect SDK versions earlier than v1.6.0 you could only set the Active low or high flag for the pins. If some configuration options are not available for your devicetree files, make sure to check the latest changes to the devicetree language first.

Devicetree context

All devicetree files within a build configuration are part of a larger devicetree context, which consists of a board file and a list of overlay files, as described in the section above.

You can specify the devicetree overlay file that you want to use with the board file when you set up a build configuration. If you work with more than one application or board, you will have multiple sets of devicetree contexts - one for each of your build configurations.

The devicetree configuration context is detailed in the Devicetree Visual Editor's Overview, which can be accessed after creating an overlay file or opening a file in the devicetree context.

Devicetree context

Devicetree Visual Editor

To make it easier to convert hardware schematics into devicetree language, the extension pack provides the Devicetree Visual Editor, which comes with the following features:

  • Overview of the devicetree context
  • A visual representation of the devicetree file structure
  • A visual representation of the hardware peripherals
  • Real-time propagation of updates to the hardware schematic based on the edits made to the devicetree nodes and properties in .dts and .overlay files
  • An interface for inspecting, adding, and editing nodes and properties
  • Integration with the devicetree language support from the nRF DeviceTree extension, which provides the most commonly used nodes and properties in Zephyr and the nRF Connect SDK

Devicetree Visual Editor

See How to work with Devicetree Visual Editor for more information.


You still need to manually create a devicetree file before you edit them in the Devicetree Visual Editor.

Devicetree language support

The extension pack includes devicetree language support, which can help you edit the overlay files in the Editor more efficiently. Read the following sections for an overview of the available features.

Syntax validation and highlighting

The extension pack comes with built-in linting for the overlay files, which validates the tree structure and points out potential issues in the tree, such as overlapping assignments or missing references.

Use this feature to see if a node has been correctly added or if it is already assigned. Review any linting errors to see information about how to fix them.

Validating a node

Code completion

With context-aware autocompletion, you can speed up the process of adding properties, nodes, and values to overlay files. Start typing in the file and look for the code completion marks in the editor.

Devicetree code completion

C file macro arguments and definitions

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


C macro completion

The extension also provides definitions for these four macros and their respective arguments.

Adding missing C file directives

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

C file #include directive completion

Adding missing binding file code 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

Kconfig overview

Kconfig is a configuration language developed for configuring the Linux kernel. Zephyr and nRF Connect SDK use this language for configuring its subsystems at build time, with the nRF Connect SDK implementing several additions on top of it.

Kconfig is structured into a hierarchical tree of configuration options, with most options linked to a configuration entry in the Kconfig files. These entries are often called symbols.

To learn more about Kconfig, read the following pages:

Kconfig support in the extension

The extension pack comes with the following features for supporting the Kconfig language:

  • The nRF Kconfig GUI, which is the extension-specific graphical representation of the Kconfig tree structure.
  • Support for all Kconfig-based configuration files, including autocompletion and syntax checking.
  • Support for the standard Kconfig interactive interfaces supported by Zephyr and the nRF Connect SDK, namely menuconfig and guiconfig.

See the following sections for more information.

nRF Kconfig GUI

When working with Kconfig in the extension, use the nRF Kconfig GUI. The GUI displays a list of the Kconfig options used in your project files (such as prj.conf) and allows you to view their description and manage their values.

Kconfig GUI main screen

Read the How to work with nRF Kconfig GUI page to learn how to configure your application by customizing and saving Kconfig options in the GUI. For detailed information about all elements of the UI, see the nRF Kconfig GUI reference page.

Configuration file support

VS Code comes with syntax highlighting for configuration files. The nRF Kconfig extension adds the following contextual information for the configuration files of boards and shields:

  • Autocompletion based on Kconfig files
  • Hover information
  • Go to definition
  • Syntax checking
  • Linting
    • Typechecking configuration values
    • Range checking
    • Checking for redundant entries
    • Checking for invalid combinations
    • Dependency checking
    • Warning about entries without prompts
  • Code Actions
    • Add missing dependencies
    • Remove redundant entries
    • Use selector entry when trying to set entries without prompts

The support also includes a warning for Kconfig project files in the Status Bar.

C file features

The extension adds symbol information for CONFIG_ defined in C files. Relevant information and the go-to definition are provided for all defines starting with CONFIG_ when hovering over them. This feature can be turned off with the kconfig.cfiles configuration entry.

Support for menuconfig and guiconfig

The nRF Kconfig GUI is the default and recommended interface setting for editing Kconfig options in the nRF Connect for VS Code extension pack.

The extension also integrates the standard Kconfig interactive interfaces supported by Zephyr and the nRF Connect SDK, namely menuconfig and guiconfig. The interface selection is available from the Actions View next to the default nRF Kconfig GUI action. From there, you can chose one of the following options:

  • Temporarily change the interface to either Menuconfig or Guiconfig. This selection will be valid only for the current session.
  • Change the default selection by clicking the Configure... button. This opens the nrf-connect.kconfig.interface configuration setting where you can select Menuconfig or Guiconfig from the drop-down menu. The name of the action in the Actions View will change accordingly.