Yocto: Introduction to Device Trees

From Compulab Mediawiki
Jump to: navigation, search

What are Device Trees?

A device tree is a data structure that describes the system hardware: System-on-Chip internal modules, on-board peripheral device and their relationship with one another. Device trees are used to pass the hardware description to the Linux kernel. Much like source code, device trees can exist as human readable source files (.dts, .dtsi), or as compiled blobs (.dtb). Before a device tree is passed to the kernel, its source must be compiled into a blob. This compilation happens automatically as part of building the kernel.

Device Tree Structure

Device trees contain segments called "nodes". Each node contains information about a hardware component. The contents of each node are dictated by the driver that is responsible for handling the hardware component. The various nodes are organized in a tree-like hierarchy, which reflects the relationship between the hardware components. For example, if we have an I2C bus with multiple devices, the nodes that represent these devices will be sub nodes of the I2C bus node. (NOTE: device nodes can also make direct references to other nodes in the system, so in practice the device tree is more like a device graph).

Device trees can include other device trees. This facilitates modularity of the hardware representation. A common pattern in the ARM world is for the SoC vendor (e.g. NXP) to define a device tree that describes the SoC (e.g. i.MX93), and the SoM vendor (e.g. CompuLab) would include it in the device tree of a product that is based on the SoC (e.g. UCM-iMX93). The inclusion works in a cascading fashion: if device tree B includes device tree A, the result will have the content of both device trees. However, if both A and B happen to define the same property, the value in device tree B will override the value provided by device tree A. In the opposite case (device tree A includes device tree B), the value from A woulde override the value from B.

  • To learn more about device tree syntax, visit the official Device Tree WiKi pages and refer to Device Tree tutorial
  • For information about what content (bindings) should appear in various nodes, see Documentation/devicetree/bindings/ folder in the Linux kernel source code.

When Device Tree Customization is Required?

Compulab provides a default Device Tree that matches the I/O interconnections and peripheral devices implemented on the Compulab reference carrier-board.
Customers designing a custom carrier-board will often need to make changes to the device tree in order to describe the I/O interconnections and peripheral devices specific to their design.
To learn more please refer to Device Tree Customization article.