In this lesson, you will learn how to dissect the hierarchical composition of Device Tree Source (.dts) files to accurately describe complex hardware topologies to the Linux kernel.
The Hierarchical Tree
At its core, a Device Tree is a tree-based data structure where every piece of hardware is defined as a node. These nodes form a parent-child hierarchy that mirrors the physical layout of the system (e.g., a memory controller node containing a child node for a specific RAM module).
Nodes are defined by a name and a unit address, followed by curly braces containing their properties:
/ {
soc {
serial@48000000 {
compatible = "ns16550a";
reg = <0x48000000 0x100>;
interrupts = <10>;
};
};
};
Nodes and Properties
- Nodes: These represent hardware components. The top-level
/node represents the entire machine. The@suffix inserial@48000000indicates the base address of the device, which must match the first value in theregproperty. - Properties: These are key-value pairs that describe the characteristics of the node. A
compatiblestring allows the kernel to match the node to a specific device driver, whileregdefines the memory-mapped I/O address ranges. - Inclusion (
/include/): Because modern SoCs share many components across different boards, we use/include/ "soc-common.dtsi"to pull in shared definitions. This prevents duplication, allowing a specific board file (.dts) to merely override or append details (like specific pin muxing) to the base hardware description (.dtsi).
Why Structure Matters
The kernel uses this tree to perform "Device Tree Probing." During boot, the kernel traverses this structure to identify which devices exist, what resources they require (memory, IRQs, DMA channels), and which drivers should be instantiated. By separating the hardware description from the kernel binary, the Device Tree provides a clean abstraction that allows the same kernel image to run on variations of hardware simply by swapping the appended or linked binary device tree file (.dtb).
Key Takeaway: The Device Tree uses a hierarchical node structure and inclusion mechanism to decouple static hardware topology from the Linux kernel, enabling a single kernel build to support diverse hardware configurations.