In Embedded Systems firmware development, hardware is traditionally described inside header files (.h or .hh). nRF Connect SDK uses a more structured and modular method to describe hardware borrowed from the Zephyr RTOS, which is through a construct called a devicetree.
A devicetree is a hierarchical data structure that describes hardware. The hardware described could be a development kit, SoC, SiP, module, defining everything ranging from the GPIO configurations of the LEDs on a development kit to the memory-mapped locations of peripherals. The devicetree uses a specific format consisting of nodes connected together, where each node contains a set of properties.
A node named a-node, which is a child of the root node
A node named a-sub-node, which is a child of a-node
Nodes can be given labels, which are unique shorthands that can be used to refer to the labeled node elsewhere in the devicetree. Above, a-sub-node has the label subnode_label. A node can have no, one, or multiple node labels.
Devicetree nodes can also have properties. Properties are name/value pairs. Property values can be an array of strings, bytes, numbers, or any mixture of types.
The node a-sub-node has a property named foo, whose value is a cell with value 3. The size and type of foo‘s value are implied by the enclosing angle brackets (< and >) in the DTS. Properties might have an empty value if conveying true-false information. In this case, the presence or absence of the property is sufficiently descriptive.
Devicetree nodes have paths identifying their locations in the tree. Like Unix file system paths, devicetree paths are strings separated by slashes (/), and the root node’s path is a single slash: /. Otherwise, each node’s path is formed by concatenating the node’s ancestors’ names with the node’s own name, separated by slashes. For example, the full path to a-sub-node is /a-node/a-sub-node.
Devicetree bindings (YAML files)
Devicetree bindings define the compatible property. It declares requirements on the contents of devicetree nodes, and provides semantic information about the contents of valid nodes. Zephyr’s devicetree bindings are defined as YAML files. Every devicetree node must have a compatible property. A devicetree node is matched using the compatible property with its definition in the devicetree binding.
Below is an example of a devicetree binding file (.yaml) that defines the compatible property named nordic,nrf-sample with one required property named num-sample of type integer.
Below is a sample DTS file (.dts) with the node node0 that is set to the compatible nordic,nrf-sample. This means the node0 node must have the required property num-sample and that property must be assigned an integer value. Otherwise, the build will fail.
The devicetree bindings are shipped with the SDK in <install_path>\zephyr\dts\bindings . The devicetree bindings for Nordic Semiconductor devices are listed here as well. In some situations, you define your own YAML files, such as when creating your custom driver. This is something covered in the nRF Connect SDK Intermediate course.
Aliases
It is common to add aliases to the devicetree. The /aliases node contains properties that are aliases, where the name of the property is the name of that alias and the value of the property is a reference to a node in the device tree, see below.
The code snippet above assigns the node a-sub-node, referenced by its label subnode_label to the alias subnode_alias. The purpose here is that your C/C++ application code (Ex: main.c) will use the alias. The definition of fixed aliases (Ex: led0 for the first LED on a board ) in boards’ dts files can make the application code more portable, as it can avoid hard-coding varying device node names and make the application code more flexible to changes in the board used.
Accessing the devicetree
To get information about a particular devicetree node in your source code, you need a node identifier for it. This is just a C macro that refers to the node. There are many ways to get a node identifier.
The two common ones are by the node label through the macro DT_NODELABEL() and by an alias through the macro DT_ALIAS().
For example, to get the node identifier of a-sub-node:
Copy
DT_NODELABEL(subnode-label)
C
To get the value assigned to a certain devicetree property, we can use the macro DT_PROP(). For example, to get the value assigned to the foo property:
Copy
DT_PROP(DT_NODELABEL(subnode-label), foo)
C
Devicetree example
Let’s take an actual example to understand these concepts better. The nRF52833 DK has four user-configurable LEDs (LED1 – LED4) connected to GPIO pins P0.13 – P0.16 as shown in the screenshots below obtained from the schematics (Available in Downloads -> Hardware Files on a development kit page ) of the nRF52833 DK.
DK devicetree file
These hardware details are all described in the devicetree file for the nRF52833 DK. Let’s examine this file, available in <install_path>\zephyr\boards\arm\nrf52833dk_nrf52833\nrf52833dk_nrf52833.dts.
The devicetree file for the DK includes the devicetree for the specific SoC variant used in the development kit. In the case of the nRF52833 DK, it is the file nrf52833_qiaa.dtsi available in the directory <install_path>\zephyr\dts\arm\nordic. This file is used because this corresponds to the package variant and function variant of the SoC used on the nRF52833 DK. The I in DTSI stands for Include. dtsi files generally contain SoC-level definitions. It also includes the pin mapping, defined in nrf52833dk_nrf52833-pinctrl.dtsi
LED1 on the nRF52833 DK has the node name led_0 and the node label led0. The node label is commonly used to refer to the node, like this &led0.
The led_0 has two properties: gpios and label.
You can see that the property gpios is referencing the node gpio0 through the & symbol. gpio0 is defined in the SoC devicetree, as we will see in the following paragraph. The GPIO pin where LED1 on the kit is connected to the nRF52833 SoC is defined with GPIO 0 as pin 13 (P0.13) and active low.
Important
A node usually has a node label, but it can also have a property with the name label. For instance, the node led_0 has the node label led0 and a property label with the value “Green LED 0“. In this context, the label property adds a Human readable string describing the LED. Using the label property (Ex: “Green LED 0”) to get a node identifier is deprecated and should not be used. Instead, to get a node identifier, the node label (led0) is recommended to be used.
The alias node is also defined in the DK devicetree file, see the image below.
We can see from the /aliases node in the DK devicetree, that node led_0, referenced by its node label as &led0, is given the alias led0. This might sound redundant; however, it is here to make sure that all boards with LEDs nodes will have a constant alias for their LEDs(Ex: led0 for the first LED) so that the application code (Ex: main.c )will compile on different boards, without the need for you to manually inspect the DTS files and figure out the node label used for the LEDs on different boards.
If we take a look at some of the other peripheral nodes, you will notice various pinctrl properties (defined in <install_path>\zephyr\dts\bindings\pinctrl\pinctrl-device.yaml). For example, &uart0, the node describing the UART0 peripheral has the properties pinctrl-0, pinctrl-1 and pinctrl-names.
This is based on Zephyr’s pin control and assigns specific pin configurations to the devicetree nodes through the &pinctrl node that is defined in the pin control devicetree file.
Pin control devicetree file
The devicetree file relies on the pin control devicetree file for the pin mappings of the various nodes (except for LEDs and buttons). As seen in the image above, the &uart0 node has references to the nodes &uart0_default and &uart0_sleep, which are defined in this file. The pin control devicetree file is found in <install_path>\zephyr\boards\arm\nrf52833dk_nrf52833\nrf52833dk_nrf52833-pinctrl.dtsi.
The &pinctrl node (defined in <install_path>\zephyr\dts\bindings\pinctrl\nordic,nrf-pinctrl.yaml) includes all device pin configurations in its sub-nodes.
The node uart0_default encodes the pin configurations for the default state of the UART0 peripheral. The pin control API lets you assign different pins to the peripherals based on states; the two standard states are default and sleep.
Pin configurations are organized in groups within each sub-node, where each group specifies a list of pin function selections in the psels property. The group1 node is one of these groups, specifying the pin configurations for UART_TX and UART_RTS.
A group can also specify shared pin properties common to all specified pins. The group2 node is specifying the pin configurations for UART_RX and UART_CTS, and setting the bias-pull-up property for both of them.
SoC variant devicetree file
Now, examine the SoC variant devicetree nrf52833_qiaa.dtsi available in the directory <install_path>\zephyr\dts\arm\nordic.
The SoC variant devicetree includes the base SoC devicetree nrf52833.dtsi, which is available in the same directory.
It contains information related to the SoC variant (version) such as the RAM and flash base addresses and sizes.
Base SoC devicetree file
The SoC devicetree contains SoC-level hardware descriptions for all the peripherals and system blocks. Examine the base SoC devicetree nrf52833.dtsi available in the directory <install_path>\zephyr\dts\arm\nordic.
The gpio0 node is defined here.
The node specifies which hardware it represents via the compatible property. This is used by the driver to select which nodes it supports.
It also defines the address space for the node.
This should give you a basic overview of how hardware is described and presented using the devicetree. To get more information about the devicetree, you can download the devicetree specification here.
v1.6.0 – v1.9.1
In Embedded Systems firmware development, hardware is traditionally described inside header files (.h or .hh). nRF Connect SDK uses a more structured and modular method to describe hardware borrowed from the Zephyr RTOS, which is through a construct called a devicetree.
A devicetree is a hierarchical data structure that describes hardware. The hardware described could be a development kit, SoC, SiP, module, defining everything ranging from the GPIO configurations of the LEDs on a development kit to the memory-mapped locations of peripherals. The devicetree uses a specific format consisting of nodes connected together, where each node contains a set of properties.
A node named a-node, which is a child of the root node
A node named a-sub-node, which is a child of a-node
Nodes can be given labels, which are unique shorthands that can be used to refer to the labeled node elsewhere in the devicetree. Above, a-sub-node has the label subnode_label. A node can have no, one, or multiple node labels.
Devicetree nodes can also have properties. Properties are name/value pairs. Property values can be an array of strings, bytes, numbers, or any mixture of types.
The node a-sub-node has a property named foo, whose value is a cell with value 3. The size and type of foo‘s value are implied by the enclosing angle brackets (< and >) in the DTS. Properties might have an empty value if conveying true-false information. In this case, the presence or absence of the property is sufficiently descriptive.
Devicetree nodes have paths identifying their locations in the tree. Like Unix file system paths, devicetree paths are strings separated by slashes (/), and the root node’s path is a single slash: /. Otherwise, each node’s path is formed by concatenating the node’s ancestors’ names with the node’s own name, separated by slashes. For example, the full path to a-sub-node is /a-node/a-sub-node.
Devicetree example
Let’s take an actual example to better understand these concepts. The nRF52833 DK has four user-configurable LEDs (LED1 – LED4) connected to GPIOpinsP0.13 – P0.16 as shown in the screenshots below obtained from the schematics of the nRF52833 DK.
DK devicetree file
These hardware details are all described in the devicetree file for the nRF52833 DK. Let’s examine this file, available in <install_path>\zephyr\boards\arm\nrf52833dk_nrf52833\nrf52833dk_nrf52833.dts.
The first thing to notice is that it includes the devicetree for the specific SoC variant used in the development kit. In the case of the nRF52833 DK, it is the file nrf52833_qiaa.dtsi available in the directory <nRF Connect SDK Installation Path>\zephyr\dts\arm\nordic. This file is used because this corresponds to the package variant and function variant of the SoC used on the nRF52833 DK. The I in DTSI stands for Include. dtsi files generally contain SoC-level definitions.
LED0 on the nRF52833 DK has the node name led_0 and the node label led0. The node label is commonly used to refer to the node, like this &led0.
The led_0 has two properties: gpios and label.
You can see that the property gpios is referencing the node gpio0 through the & symbol. gpio0 is defined in the SoC devicetree, as we will see in the following paragraph. The GPIO pin, where LED1 on the kit is connected to the nRF52833 SoC, is defined with GPIO 0 as pin 13 (P0.13) and active low.
Important
A node usually has a node label, but it can also have a property with the name label. For instance, the node led_0 has the node label led0 and a property label with the value “Green LED 0“. In this context, the label property adds a Human readable string describing the LED.
Aliases
It is common to add aliases to the devicetree. An alias is a property of the aliases node. These are usually added in the devicetree file of the DK. Aliases are added as a way to ensure compatibility across different hardware with all samples.
The node led_0, referenced here with its node label, as &led0, is given the alias led0.
SoC variant devicetree file
Now, examine the SoC variant devicetree nrf52833_qiaa.dtsi available in the directory <nRF Connect SDK Installation Path>\zephyr\dts\arm\nordic.
The SoC variant devicetree includes the base SoC devicetree nrf52833.dtsi, which is available in the same directory.
It contains information related to the SoC variant (version) such as the RAM and flash base addresses and sizes.
Base SoC devicetree file
The SoC devicetree contains SoC-level hardware descriptions for all the peripherals and system blocks. Examine the base SoC devicetree nrf52833.dtsi available in the directory <nRF Connect SDK Installation Path>\zephyr\dts\arm\nordic.
The gpio0 node is defined here.
The node specifies which hardware it represents via the compatible property. This is used by the driver to select which nodes it supports.
It also defines the address space for the node.
This should give you a basic overview of how hardware is described and presented using the devicetree. To get more information about the devicetree, you can download the devicetree specification from here.
Nordic Developer Academy Privacy Policy
1. Introduction
In this Privacy Policy you will find information on Nordic Semiconductor ASA (“Nordic Semiconductor”) processes your personal data when you use the Nordic Developer Academy.
References to “we” and “us” in this document refers to Nordic Semiconductor.
2. Our processing of personal data when you use the Nordic Developer Academy
2.1 Nordic Developer Academy
Nordic Semiconductor processes personal data in order to provide you with the features and functionality of the Nordic Developer Academy. Creating a user account is optional, but required if you want to track you progress and view your completed courses and obtained certificates. If you choose to create a user account, we will process the following categories of personal data:
Email
Name
Password (encrypted)
Course progression (e.g. which course you have completely or partly completed)
Certificate information, which consists of name of completed course and the validity of the certificate
Course results
During your use of the Nordic Developer Academy, you may also be asked if you want to provide feedback. If you choose to respond to any such surveys, we will also process the personal data in your responses in that survey.
The legal basis for this processing is GDPR article 6 (1) b. The processing is necessary for Nordic Semiconductor to provide the Nordic Developer Academy under the Terms of Service.
2.2 Analytics
If you consent to analytics, Nordic Semiconductor will use Google Analytics to obtain statistics about how the Nordic Developer Academy is used. This includes collecting information on for example what pages are viewed, the duration of the visit, the way in which the pages are maneuvered, what links are clicked, technical information about your equipment. The information is used to learn how Nordic Developer Academy is used and how the user experience can be further developed.
2.2 Newsletter
You can consent to receive newsletters from Nordic from within the Nordic Developer Academy. How your personal data is processed when you sign up for our newsletters is described in the Nordic Semiconductor Privacy Policy.
3. Retention period
We will store your personal data for as long you use the Nordic Developer Academy. If our systems register that you have not used your account for 36 months, your account will be deleted.
4. Additional information
Additional information on how we process personal data can be found in the Nordic Semiconductor Privacy Policy and Cookie Policy.
Nordic Developer Academy Terms of Service
1. Introduction
These terms and conditions (“Terms of Use”) apply to the use of the Nordic Developer Academy, provided by Nordic Semiconductor ASA, org. nr. 966 011 726, a public limited liability company registered in Norway (“Nordic Semiconductor”).
Nordic Developer Academy allows the user to take technical courses related to Nordic Semiconductor products, software and services, and obtain a certificate certifying completion of these courses. By completing the registration process for the Nordic Developer Academy, you are agreeing to be bound by these Terms of Use.
These Terms of Use are applicable as long as you have a user account giving you access to Nordic Developer Academy.
2. Access to and use of Nordic Developer Academy
Upon acceptance of these Terms of Use you are granted a non-exclusive right of access to, and use of Nordic Developer Academy, as it is provided to you at any time. Nordic Semiconductor provides Nordic Developer Academy to you free of charge, subject to the provisions of these Terms of Use and the Nordic Developer Academy Privacy Policy.
To access select features of Nordic Developer Academy, you need to create a user account. You are solely responsible for the security associated with your user account, including always keeping your login details safe.
You will able to receive an electronic certificate from Nordic Developer Academy upon completion of courses. By issuing you such a certificate, Nordic Semiconductor certifies that you have completed the applicable course, but does not provide any further warrants or endorsements for any particular skills or professional qualifications.
Nordic Semiconductor will continuously develop Nordic Developer Academy with new features and functionality, but reserves the right to remove or alter any existing functions without notice.
3. Acceptable use
You undertake that you will use Nordic Developer Academy in accordance with applicable law and regulations, and in accordance with these Terms of Use. You must not modify, adapt, or hack Nordic Developer Academy or modify another website so as to falsely imply that it is associated with Nordic Developer Academy, Nordic Semiconductor, or any other Nordic Semiconductor product, software or service.
You agree not to reproduce, duplicate, copy, sell, resell or in any other way exploit any portion of Nordic Developer Academy, use of Nordic Developer Academy, or access to Nordic Developer Academy without the express written permission by Nordic Semiconductor. You must not upload, post, host, or transmit unsolicited email, SMS, or \”spam\” messages.
You are responsible for ensuring that the information you post and the content you share does not;
contain false, misleading or otherwise erroneous information
infringe someone else’s copyrights or other intellectual property rights
contain sensitive personal data or
contain information that might be received as offensive or insulting.
Such information may be removed without prior notice.
Nordic Semiconductor reserves the right to at any time determine whether a use of Nordic Developer Academy is in violation of its requirements for acceptable use.
Violation of the at any time applicable requirements for acceptable use may result in termination of your account. We will take reasonable steps to notify you and state the reason for termination in such cases.
4. Routines for planned maintenance
Certain types of maintenance may imply a stop or reduction in availability of Nordic Developer Academy. Nordic Semiconductor does not warrant any level of service availability but will provide its best effort to limit the impact of any planned maintenance on the availability of Nordic Developer Academy.
5. Intellectual property rights
Nordic Semiconductor retains all rights to all elements of Nordic Developer Academy. This includes, but is not limited to, the concept, design, trademarks, know-how, trade secrets, copyrights and all other intellectual property rights.
Nordic Semiconductor receives all rights to all content uploaded or created in Nordic Developer Academy. You do not receive any license or usage rights to Nordic Developer Academy beyond what is explicitly stated in this Agreement.
6. Liability and damages
Nothing within these Terms of Use is intended to limit your statutory data privacy rights as a data subject, as described in the Nordic Developer Academy Privacy Policy. You acknowledge that errors might occur from time to time and waive any right to claim for compensation as a result of errors in Nordic Developer Academy. When an error occurs, you shall notify Nordic Semiconductor of the error and provide a description of the error situation.
You agree to indemnify Nordic Semiconductor for any loss, including indirect loss, arising out of or in connection with your use of Nordic Developer Academy or violations of these Terms of Use. Nordic Semiconductor shall not be held liable for, and does not warrant that (i) Nordic Developer Academy will meet your specific requirements, (ii) Nordic Developer Academy will be uninterrupted, timely, secure, or error-free, (iii) the results that may be obtained from the use of Nordic Developer Academy will be accurate or reliable, (iv) the quality of any products, services, information, or other material purchased or obtained by you through Nordic Developer Academy will meet your expectations, or that (v) any errors in Nordic Developer Academy will be corrected.
You accept that this is a service provided to you without any payment and hence you accept that Nordic Semiconductor will not be held responsible, or liable, for any breaches of these Terms of Use or any loss connected to your use of Nordic Developer Academy. Unless otherwise follows from mandatory law, Nordic Semiconductor will not accept any such responsibility or liability.
7. Change of terms
Nordic Semiconductor may update and change the Terms of Use from time to time. Nordic Semiconductor will seek to notify you about significant changes before such changes come into force and give you a possibility to evaluate the effects of proposed changes. Continued use of Nordic Developer Academy after any such changes shall constitute your acceptance of such changes. You can review the current version of the Terms of Use at any time at https://academy.nordicsemi.com/terms-of-service/
8. Transfer of rights
Nordic Semiconductor is entitled to transfer its rights and obligation pursuant to these Terms of Use to a third party as part of a merger or acquisition process, or as a result of other organizational changes.
9. Third Party Services
To the extent Nordic Developer Academy facilitates access to services provided by a third party, you agree to comply with the terms governing such third party services. Nordic Semiconductor shall not be held liable for any errors, omissions, inaccuracies, etc. related to such third party services.
10. Dispute resolution
The Terms of Use and any other legally binding agreement between yourself and Nordic Semiconductor shall be subject to Norwegian law and Norwegian courts’ exclusive jurisdiction.