Skip to content
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 1 commit into from
Jun 25, 2018

Conversation

carlescufi
Copy link
Member

@carlescufi carlescufi commented Jun 21, 2018

Try to clarify the scope of Device Tree vs Kconfig in order to allow
Zephyr users to identify where a particular configuration option when
developing an application, board support or SoC support.

Fixes #7230

Signed-off-by: Carles Cufi [email protected]

@carlescufi
Copy link
Member Author

cc @b0661

@carlescufi
Copy link
Member Author

I put this together in the context of a discussion in the TSC call where we decided to track the changes required to DT and Kconfig in order to achieve better integration. See #8499 for more details.

Copy link
Collaborator

@ulfalizer ulfalizer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides the nit, looks good to me.

DTS describes stuff, Kconfig configures stuff.


As mentioned above there are several tools used to configuring the build with
Zephyr.
The two main ones, Device Tree and Kconfig might seem to overlap in its purpose,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove "its".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, thank you.

Copy link
Collaborator

@SebastianBoe SebastianBoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good description of how we are using DeviceTree and it resolves #7230.

This isn't IMHO what the relationship between DT and Kconfig 'should' be, but that is another matter :)

@codecov-io
Copy link

codecov-io commented Jun 21, 2018

Codecov Report

Merging #8507 into master will increase coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #8507      +/-   ##
=========================================
+ Coverage    63.8%   63.8%   +<.01%     
=========================================
  Files         426     426              
  Lines       40890   40890              
  Branches     6921    6921              
=========================================
+ Hits        26088   26089       +1     
  Misses      11666   11666              
+ Partials     3136    3135       -1
Impacted Files Coverage Δ
boards/posix/native_posix/timer_model.c 95.16% <0%> (+1.61%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7a7e4f5...d06895e. Read the comment docs.

* 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**.
Copy link
Member

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:

	chosen {
		zephyr,console = &uart0;
		zephyr,uart-mcumgr = &uart0;
		zephyr,sram = &sram0;
		zephyr,flash = &flash0;
	};

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.

Copy link
Member Author

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?

Copy link
Member Author

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

Copy link
Member

@ioannisg ioannisg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

basically style comments, but some other content-related comments, too

replace or curtail the use of some 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 Kconfig, CMSIS
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to fully replace?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, it doesn't replace it at all. I will rephrase instead

Device Tree vs Kconfig
**********************

As mentioned above there are several tools used to configuring the build with
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to configure

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed


As mentioned above there are several tools used to configuring the build with
Zephyr.
The two main ones, Device Tree and Kconfig might seem to overlap in purpose,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kconfig,

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

As mentioned above there are several tools used to configuring 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 is intended to serve as a reference when
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

intends

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


The scope of each configuration tool can be summarized as follows:

* Device Tree is used to describe the **hardware** and its **boot-time
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or build-time

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, this might be a bit confusing, since Kconfig is also determining the build-time configuration.
So maybe
Device Tree is used to describe the hardware capabilities and configuration at build time.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well actually I disagree, I think my original wording (taken form Erwan) is clearer. Boot-time here really means that, when the hardware boots. Compilation and build time are really irrelevant IMHO

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I see the "its" refers to "hardware, This clarifies it.
In principle, "software" also has "boot-time" configuration.

* 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**.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

firmware features?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I chose to phrase this differently, see last version of the commit

of the hardware peripheral in memory or its interrupt line.
* Additional, **hardware boot-time configuration** is also described with Device
Tree. This includes things like the interrupt line and IRQ priority. These
might also be modifiable at runtime later, but their boot-time "default"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

might 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. In this way users can opt not to include
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Through Kconfig, the users can opt to....

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


* Device Tree describes the presence of a radio peripheral compatible with a
certain radio driver.
* Additional hardware boot-time configuration settings might also be present
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

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 might decide to select BLE or 802.15.4, which will both depend on
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@carlescufi carlescufi force-pushed the dt_doc branch 2 times, most recently from c44d86e to d8ae655 Compare June 21, 2018 16:11
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 inteds to serve as a reference when
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to: (and removing the misspelled "intends")

This section serves as a reference to help you decide whether to place
configuration items in Device Tree or Kconfig.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

the final image, and their **configuration**.

Hence Device Tree deals mostly with hardware and Kconfig with software. A
noteworthy exception is Device Tree's `chosen` keyword, which allows the user
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use two backticks:

``chosen``

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Hence Device Tree deals mostly with hardware and Kconfig with software. A
noteworthy exception is 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 using this keyword to select
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about:

An example of this is selecting a particular UART for use
as the system's console.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it. Fixed.

purpose by the software. An example of this is using this keyword to select
a particular UART to be used as the system's console.

In order to further clarify this separation, let's use a particular, well-known
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete the "In order":

To further clarify this separation, ...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

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.
* Additional, **hardware boot-time configuration** is also described with Device
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to Additionally,

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

"immutable" (i.e. not software-configurable) settings such as the base address
of the hardware peripheral in memory or its interrupt line.
* Additional, **hardware boot-time configuration** is also described with Device
Tree. This includes things like the interrupt line and IRQ priority. These
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change like to such as

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


* 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd delete the quotes on immutable. Using the quotes implies that it might not be immutable, such as saying, Bob and his "wife" went out to dinner.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, thank you. Fixed.

of the hardware peripheral in memory or its interrupt line.
* Additional, **hardware boot-time configuration** is also described with Device
Tree. This includes things like the interrupt line and IRQ priority. These
may also be modifiable at runtime later, but their boot-time "default"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, no need for the quotes on default

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed

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 could be a device with a 2.4GHz, multi-protocol radio supporting
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change could be to is

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

* 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 perhaps a
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd delete the word perhaps

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deleted

describe hardware. Device tree is not intended to replace CMSIS or vendor
include files.
replace or curtail the use of some Kconfig files throughout the system, and
instead use device tree files to describe the configuration of device nodes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"replace or curtail the use of some Kconfig files throughout the system, and instead use device tree files to describe the configuration of device nodes"
Isn't it rather a temporary side effect of device tree introduction?
While it makes sense to us, this might be unclear for a future Zephyr user.
I think we'd rather remove this part or provide a generic description with no reference with Kconfig, as:
"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."

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionnaly, we might want to add a reference to specification, if not already present (http://www.devicetre.org/)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with you. Will make the change

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.
Copy link
Member

@erwango erwango Jun 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this part should be clarified as it eludes the device tree "status" property.
Should we use it?
If we use it (which I think we should do), we should mention it will take precedence and then Kconfig will be able to amend only if status is "okay". If "status" is "disabled" it won't be available in Kconfig.
If we don't use it, we'll need to change the (device tree extract scripts) code.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will add a comment about this

Copy link
Collaborator

@tbursztyka tbursztyka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tiny comment

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 interrupt line and IRQ priority. These
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a very particular example, changing irq/prio at runtime is going to be very rare. Use the i2c clock-frequency instead, since it's very common to change it at runtime.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've amended this now using UART baudrate

Try to clarify the scope of Device Tree vs Kconfig in order to allow
Zephyr users to identify where a particular configuration option when
developing an application, board support or SoC support.

Fixes zephyrproject-rtos#7230

Signed-off-by: Carles Cufi <[email protected]>
@carlescufi
Copy link
Member Author

@ioannisg @erwango @tbursztyka @dbkinder addressed your comments

Copy link
Contributor

@dbkinder dbkinder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, thanks!

Copy link
Collaborator

@agross-oss agross-oss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks nice

@carlescufi carlescufi merged commit 4574505 into zephyrproject-rtos:master Jun 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants