1. Purpose[edit | edit source]
The objective of this chapter is to give general information about the device tree.
An extract of the device tree specification[1] explains it as follows:
"A device tree is a tree data structure with nodes that describe the devices in a system. Each node has property/value pairs that describe the characteristics of the device being represented. Each node has exactly one parent except for the root node, which has no parent. ... Rather than hard coding every detail of a device into an operating system, many aspect of the hardware can be described in a data structure that is passed to the operating system at boot time."
In other words, a device tree describes the hardware that can not be located by the operating system drivers while probing.
1.1. Device tree basis[edit | edit source]
The webinar below gives the foundations of device tree applied to STM32MP1 products and boards. It is highly recommended to start from this video if you are beginner on this subject.
- Device Tree for STM32MP [2]
1.2. Source files[edit | edit source]
- .dts: The device tree source (DTS). This format is a textual representation of a device tree in a form that can be processed by DTC (Device Tree Compiler) into a binary file (.dtb) expected by software components: Linux® Kernel, U-Boot and TF-A.
- .dtsi: Source files that can be included from a DTS file.
- .h: Header files that can be included from DTS and DTSI files.
1.3. Bindings[edit | edit source]
The device tree data structures and properties are named bindings. Those bindings are described in:
- The Device tree specification[1] for generic bindings.
- The software component documentations:
- Linux® Kernel: Linux kernel device tree bindings
- U-Boot: doc/device-tree-bindings/
- TF-A: TF-A device tree bindings
- OP-TEE: OP-TEE device tree bindings
1.4. Build[edit | edit source]
- A tool named DTC[3](Device Tree Compiler) allows compiling the DTS sources into a binary.
- input file: the .dts file described in section above (that includes itself one or several .dtsi and .h files).
- output file: the .dtb file described in section above.
DTC is an open source tool available in an independent git repository[4], and it is also available directly in particular software components: Linux Kernel, U-Boot, TF-A, OP-TEE .... For those components, the device tree building is directly integrated in the component build process.
Information |
If dts files use some defines, dts files should be preprocessed before being compiled by DTC. |
1.5. Tools[edit | edit source]
The device tree compiler offers also some tools:
- fdtdump: Print a readable version of a flattened device tree file (dtb)
- fdtget: Read properties from a device tree
- fdtput: Write properties to a device tree
- ...
There are several ways to get those tools:
- In the device tree compiler project source code[4]
- Directly in software components: Kernel, u-boot, tf-a, op-tee ...
- Via a Debian package[5]
2. STM32 MPU[edit | edit source]
For STM32MP1, the device tree is used by four software components: Linux® kernel, U-Boot, OP-TEE and TF-A.
For STM32MP2, the device tree is also used for TF-M running on Cortex-M core.
The device tree is part of the OpenSTLinux distribution. It can also be generated by STM32CubeMX tool.
To have more information about the device tree usage on STM32MP1, see STM32 MPU device tree page.
3. How to go further[edit | edit source]
4. References[edit | edit source]
- ↑ 1.0 1.1 https://github.com/devicetree-org/devicetree-specification/releases/tag/v0.2(latest), Device tree specification
- ↑ https://www.youtube.com/watch?v=a9CZ1Uk3OYQ, Device Tree for STM32MP
- ↑ https://git.kernel.org/pub/scm/utils/dtc/dtc.git/tree/Documentation/manual.txt(master), DTC manual
- ↑ 4.0 4.1 https://git.kernel.org/pub/scm/utils/dtc/dtc.git(master), DTC source code
- ↑ https://packages.debian.org/search?keywords=device-tree-compiler(master), DTC debian package
- ↑ Device Tree Reference, eLinux.org
- ↑ Device Tree Usage, eLinux.org