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.
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:
*.dtsfiles - the base devicetree files.
*.overlayfiles - additional files that extend the base devicetree files with application-specific modifications.
*.dtsifiles - 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.
You will be mostly working with
To learn more about Devicetree, read the following pages:
- nRF Connect SDK's Configuration system overview
- Zephyr's Devicetree pages
Devicetree Visual Editor¶
The devicetree source files are written using their own custom devicetree language. 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:
- A visual representation of the devicetree file structure
- A simplified hardware circuit schematic
- Real-time propagation of updates to the hardware schematic based on the edits made to the devicetree nodes and properties in
- An interface for 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
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 GUI editor.
The configuration included in the board and overlay files is summarized in devicetree contexts, each of which consists of a board file and a list of overlay files. The board file contains the basic configuration for a build target, while the overlay files contain the configuration for more specific use cases.
The contexts are listed in the Devicetree View and appear after creating an overlay file.
If you work with more than one application or board, you will have multiple sets of devicetree contexts - one for each of your builds. Every time you open a new devicetree file, the extension will add a devicetree context (unless the file is already part of an existing context.)
Each devicetree context presents an overview of what the common resources are and which components use them. Each entry in the overview is linked with a specific node or property in the devicetree. Clicking one of these will go to the primary definition of the linked node or property.
See Devicetree contexts in the UI reference section for a detailed description of each context.
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.
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.
Adding missing C file macro arguments¶
The extension uses data from the most recent devicetree context to provide completion items for the arguments of the following macros in C:
Adding missing C file directives¶
The extension includes autocompletion for the C preprocessor files'
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
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:
- Official Kconfig documentation
- Zephyr's Configuration System pages
- nRF Connect SDK's Build and configuration system page
The extension pack features the nRF Kconfig GUI, which is a graphical representation of the Kconfig tree structure. It provides support for the standard Kconfig interactive interfaces supported by Zephyr and the nRF Connect SDK, namely menuconfig and guiconfig, which can be selected from the Actions View.
nRF Kconfig GUI¶
When working with Kconfig in the extension, we recommend using 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 and manage your Kconfig options.
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 Kconfig interface options, see the Kconfig features and GUI UI reference page.