-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
doc: dt: Clarify the relationship between DT and Kconfig #8507
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,9 +28,9 @@ Information about the system is extracted from the compiled DTS and used to | |
create the application image. | ||
|
||
Device tree uses a specific format to describe the device nodes in a system. | ||
This format is described in `EPAPR document`_. | ||
This format is described in the `Device Tree Specification`_. | ||
|
||
.. _EPAPR document: https://www.devicetree.org/downloads/devicetree-specification-v0.1-20160524.pdf | ||
.. _Device Tree Specification: https://github.com/devicetree-org/devicetree-specification/releases | ||
|
||
More device tree information can be found at the `device tree repository`_. | ||
|
||
|
@@ -57,14 +57,9 @@ information is intended to augment the device tree descriptions. The main | |
reason for this is to leverage existing device tree files that a SoC vendor may | ||
already have defined for a given platform. | ||
|
||
Today, configuration in Zephyr comes from a number of different places. It can | ||
come from Kconfig files, CMSIS header files, vendor header files, prj.conf | ||
files, and other miscellaneous sources. The intent of using device tree is to | ||
replace or curtail the use of Kconfig files throughout the system, and instead | ||
use device tree files to describe the configuration of device nodes. CMSIS and | ||
vendor header files can be used in conjunction with the device tree to fully | ||
describe hardware. Device tree is not intended to replace CMSIS or vendor | ||
include files. | ||
Device Tree provides a unified description of a hardware system used in an | ||
application. It is used in Zephyr to describe hardware and provide a boot-time | ||
configuration of this hardware. | ||
|
||
The device tree files are compiled using the device tree compiler. The compiler | ||
runs the .dts file through the C preprocessor to resolve any macro or #defines | ||
|
@@ -80,6 +75,64 @@ This .fixup file by default resides in the board directory and is named | |
dts.fixup. This fixup file maps the generated include information to the | ||
current driver/source usage. | ||
|
||
.. _dt_vs_kconfig: | ||
|
||
Device Tree vs Kconfig | ||
********************** | ||
|
||
As mentioned above there are several tools used to configure the build with | ||
Zephyr. | ||
The two main ones, Device Tree and Kconfig, might seem to overlap in purpose, | ||
but in fact they do not. This section serves as a reference to help you decide | ||
whether to place configuration items in Device Tree or Kconfig. | ||
|
||
The scope of each configuration tool can be summarized as follows: | ||
|
||
* Device Tree is used to describe the **hardware** and its **boot-time | ||
configuration**. | ||
* Kconfig is used to describe which **software features** will be built into | ||
the final image, and their **configuration**. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. firmware features? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I chose to phrase this differently, see last version of the commit |
||
|
||
Hence Device Tree deals mostly with hardware and Kconfig with software. | ||
A couple of noteworthy exceptions are: | ||
|
||
* Device Tree's ``chosen`` keyword, which allows the user to select a | ||
particular instance of a hardware device to be used for a concrete purpose | ||
by the software. An example of this is selecting a particular UART for use as | ||
the system's console. | ||
* Device Tree's ``status`` keyword, which allows the user to enable or disable | ||
a particular instance of a hardware device in the Device Tree file itself. | ||
This takes precedence over Kconfig. | ||
|
||
To further clarify this separation, let's use a particular, well-known | ||
example to illustrate this: serial ports a.k.a. UARTs. Let's consider a | ||
board containing a SoC with 2 UART instances: | ||
|
||
* The fact that the target hardware **contains** 2 UARTs is described with Device | ||
Tree. This includes the UART type, its driver compatibility and certain | ||
immutable (i.e. not software-configurable) settings such as the base address | ||
of the hardware peripheral in memory or its interrupt line. | ||
* Additionally, **hardware boot-time configuration** is also described with Device | ||
Tree. This includes things such as the IRQ priority and boot-time UART | ||
baudrate. These may also be modifiable at runtime later, but their boot-time | ||
default configuration is described in Device Tree. | ||
* The fact that the user intends to include **software support** for UART in the | ||
build is described in Kconfig. Through the use of Kconfig, users can opt not | ||
to include support for this particular hardware item if they don't require it. | ||
|
||
Another example is a device with a 2.4GHz, multi-protocol radio supporting | ||
both the Bluetooth Low Energy and 802.15.4 wireless technologies. In this case: | ||
|
||
* Device Tree describes the presence of a radio peripheral compatible with a | ||
certain radio driver. | ||
* Additional hardware boot-time configuration settings may also be present | ||
in the Device Tree files. In this particular case it could be a | ||
default TX power in dBm if the hardware does have a simple, cross-wireless | ||
technology register for that. | ||
* Kconfig will describe which **protocol stack** is to be used with that radio. | ||
The user may decide to select BLE or 802.15.4, which will both depend on | ||
the presence of a compatible radio in the Device Tree files. | ||
|
||
Device tree file formats | ||
************************ | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I agree to this general stating, I think we should clarify the use of 'chosen' node:
Device Tree specification provides the following definition:
"3.5 /chosen Node:
The /chosen node does not represent a real device in the system but describes parameters chosen or specified by the system firmware at run time. It shall be a child of the root node."
This lis kind of SW oriented configuration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good point. Where do you think we should add this information? I would not want to include it in those first 2 lines, but rather add it as a precision later?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this now a bit below