Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

3.3 Device Tree Nodes

Nodes within a Device Tree can represent a physical hardware component, an entire system subsystem, or an interconnect bus. A node description is structurally defined by its node name, localized unit address, absolute hierarchical path, and node label.

The node name specifies the technical identifier of the block, typically naming the node after the explicit device class it represents. The naming convention follows the format name@address, where the name segment is a string of 1 to 31 characters selected from 0-9, a-z, A-Z, ,, ., _, +, and -. The trailing address segment defines the base address or unit identifier of the component. This address can correspond to the device's physical layout within the CPU's memory-mapped I/O (MMIO) space, or it can represent a bus-specific coordinate system; its low-level interpretation is governed entirely by the Device Tree parsing routines compiled within the operating system driver.

Similar to file system folder structures, the absolute path of a node represents its full hierarchical lineage starting from the root node, separated by forward slashes (/), and formed by the corresponding node names (including their unit addresses). For example, the absolute path for the cpu0 node illustrated previously is:

/cpus/cpu0

A node label is an arbitrary string token suffixed with a colon (:) that resides immediately before the node name, isolated by whitespace characters. System software can reference or cross-access a target node either by invoking its symbolic node label or by referencing its full absolute path.

3.3.1 Root Node

The root node is represented by a single forward slash (/), mapping to the absolute path /. It can host the #address-cells, #size-cells, model, compatible, and serial-number properties. The serial-number property is optional, whereas the remaining properties are strictly mandatory. The #address-cells property is configured as one or more 32-bit integer cells. It specifies the exact cell count required to encode the unit address of its immediate child nodes. The #size-cells property maps to a 32-bit integer cell defining the cell count needed to represent the memory allocation length or address space size of those child nodes. The compatible property contains a string list identifying the target platform architectures compatible with the given Device Tree, typically structured as a "manufacturer,model" pair separated by a comma.

The direct child tree underneath the root node typically encapsulates specific structural container nodes, including /aliases, /memory, /reserved-memory, /chosen, and /cpus.

3.3.2 /aliases Node

The aliases node is utilized to define shorthand alternate names for fully qualified paths, allowing client software to locate or query complex nodes via abbreviated terms. An alias string consists of 1 to 31 characters drawn from 0-9, a-z, and -. The assigned property value maps directly to the absolute path of the targeted node. For example:

/ {
    aliases {
        serial0 = "/simple-bus@fe000000/serial@llc500";
    };
};

In this block, serial0 = "/simple-bus@fe000000/serial@llc500" binds the symbolic reference alias serial0 directly to the serial@llc500 node. Operating system routines can subsequently query serial0 to interact with that peripheral.

3.3.3 /memory Node

The memory node defines the physical layout of the system's volatile random-access memory (RAM). Every valid Device Tree must contain at least one operational memory node. If the physical memory architecture consists of multiple non-contiguous memory regions, the Device Tree can instantiate multiple independent memory nodes to capture the layout. Each individual memory block supports four properties: device_type, reg, initial-mapped-area, and hotpluggable. The device_type and reg properties are strictly mandatory, while the remainder are optional. The device_type string value must be explicitly set to "memory". The reg property contains one or more <address size> arrays mapping the base address and length vectors of the target memory banks. The hotpluggable property is an empty boolean flag; its presence indicates that the associated memory block supports dynamic hot-plug hardware operations. The following example shows a dual-bank memory topology configuration:

memory@0 {
	device_type = "memory";
	reg = <0x000000000 0x00000000 0x00000000 0x80000000>;
};
memory@100000000 {
	device_type = "memory";
	reg = <0x000000001 0x00000000 0x00000001 0x00000000>;
	hotpluggable;
};

3.3.4 /reserved-memory Node

The reserved-memory node declares specific regions of memory that must be protected and isolated from standard operating system memory management use. The reserved-memory container defines these protected blocks through dedicated child nodes. The container node must explicitly declare three attributes: #address-cells, #size-cells, and ranges. The value fields for #address-cells and #size-cells are 32-bit unsigned integers, while the ranges attribute must be left completely empty.

Each immediate child node under the reserved-memory block maps to a distinct reserved memory layout. These sub-nodes support seven optional properties: reg, size, alignment, alloc-ranges, compatible, no-map, and reusable. The array encoding rules for the reg property are determined by the #address-cells and #size-cells parameters established in the parent container, while the word width of the size property matches the parent's #size-cells directive. The alignment property dictates the boundary allocation constraint for the region, encoded using the cell size mandated by the parent's #size-cells. The format for the alloc-ranges property mirrors the structure of the standard reg array.

The no-map and reusable properties are empty boolean flags. When a child node declares the no-map attribute, the operating system kernel is strictly prohibited from instantiating a virtual memory mapping (such as a page table entry or cacheable kernel map) over that physical region. Conversely, the presence of the reusable attribute indicates that the operating system can temporarily leverage the memory block for general purposes; however, when the underlying peripheral driver explicitly requests the allocation, the kernel must yield the region back to its primary hardware owner. The following block outlines a complete structural example implementing standard memory and reserved memory allocations:

/ {
	    #address-cells = <1>;
	    #size-cells = <1>;
	    memory {
		    reg = <0x40000000 0x40000000>;
	    };
	    reserved-memory {
		    #address-cells = <1>;
		    #size-cells = <1>;
		    ranges;
		    linux,cma {
			    compatible = "shared-dma-pool";
			    reusable;
			    size = <0x2000000>;
			    alignment = <0x1000>;
			    linux,cma-default;
		    };
		    display: framebuffer@88000000 {
			    reg = <0x88000000 0x800000>;
		    };
		    multimedia: multimedia@70000000 {
			    compatible = "acme,multimedia-memory";
			    reg = <0x70000000 0x4000000>;
		    };
	    };
	    fb0: video@12300000 {
		    memory-region = <&display>;
	    };
	    codec: codec@12600000 {
		    memory-region = <&multimedia>;    
	    };
};

3.3.5 /chosen Node

The chosen node does not represent a physical hardware device; instead, it passes runtime parameters directly to the operating system. This node can contain three attributes: bootargs, stdin-path, and stdout-path. The bootargs property passes the command-line initialization string directly to the Linux kernel. The stdin-path and stdout-path properties designate the default standard input and standard output devices, respectively. All three attributes are stored as string types. The values for stdout-path and stdin-path specify either the absolute hierarchical path or the symbolic phandle referencing the standard input/output terminal hardware. The following example outlines the standard implementation framework for the /chosen node:

/ {
	chosen {
		bootargs = "root=/dev/nfs rw nfsroot=192.168.1.1 console=ttyS0,115200";
		stdout-path = &uart3;
		stdin-path = &uart3;
	};
	bus@20000000 {
       		uart3: uart3@20000000 {
                ...
       		};
	};
};

In this configuration, uart3 functions as a symbolic label pointing to a specific peripheral node within the Device Tree structure.

3.3.6 /cpus Node

The cpus container node describes the system's central processing units (CPUs). The top-level root node is strictly required to contain exactly one /cpus node. The cpus block houses multiple sequential cpu child nodes, and it must explicitly implement the #address-cells and #size-cells properties to define the address encoding scheme for its children. The cpus node can also host optional standard properties; when defined at this level, these properties represent common attributes shared universally across all child CPU cores.

3.3.7 /cpus/cpu* Child Nodes

A cpu* child node represents an independent hardware execution core capable of running an operating system context without interfering with sister CPU nodes, where * denotes the unique numerical index or identifier of the processing core. Hardware structures sharing a common Memory Management Unit (MMU) topology should be encapsulated within the same cpu node boundaries to ensure distinct CPU configurations remain mutually independent.

ARM architectures frequently deploy multiple decoupled CPU blocks. For example, the NXP i.MX6Dual integrates two Cortex-A class cores, the i.MX6Quad hosts four Cortex-A class cores, and the high-performance i.MX8 platform features a heterogeneous configuration comprising four Cortex-A72 cores, two Cortex-A53 cores, two Cortex-M real-time microcontrollers, a dedicated DSP, and two GPUs. Because these processing elements can operate independently, they are partitioned into distinct cpu nodes within the layout.

A valid cpu* node must contain the device_type, reg, clock-frequency, and timebase-frequency properties. Additional attributes can include status, enable-method, cpu-release-addr, power-isa-version, and mmu-type, alongside other standard metadata properties. The device_type string value must be set to "cpu", identifying the block as a core execution unit. The reg property defines the core's relative index mapping inside the parent cpus address space, formatted according to the parent's #address-cells and #size-cells properties.

The clock-frequency property is stored as a 32-bit or 64-bit unsigned integer, specified in Hertz (Hz), defining the current operating frequency of the CPU. Similarly, the timebase-frequency property is a 32-bit or 64-bit unsigned integer that specifies the operating frequency of the low-level system timebase generator.

The status property is a string value typically set to either "okay" or "disabled", where "okay" indicates the core is fully functional, and "disabled" denotes that the core is forced into a sleep, offline, or hard reset state. The remaining secondary attributes are less pervasive in standard configurations and are omitted here; readers can refer to the official Device Tree Specification for granular edge-case tracking. The following block show a complete Device Tree configuration for a dual-core system implementing a unified three-tier (L1, L2, L3) cache hierarchy:

cpus {
	#address-cells = <1>;
	#size-cells = <0>;
	cpu@0 {
		device_type = "cpu";
		reg = <0>;
		cache-unified;
		cache-size = <0x8000>; // L1, 32 KB
		cache-block-size = <32>;
		timebase-frequency = <82500000>; // 82.5 MHz
		next-level-cache = <&L2_0>; // phandle to L2
		L2_0: l2-cache {
			compatible = "cache";
			cache-unified;
			cache-size = <0x40000>; // 256 KB
			cache-sets = <1024>;
			cache-block-size = <32>;
			cache-level = <2>;
			next-level-cache = <&L3>; // phandle to L3
			L3: l3-cache {
				compatible = "cache";
				cache-unified;
				cache-size = <0x40000>; // 256 KB
				cache-sets = <0x400>; // 1024
				cache-block-size = <32>;
				cache-level = <3>;
			};
		};
	};
	cpu@1 {
		device_type = "cpu";
		reg = <1>;
		cache-unified;
		cache-block-size = <32>;
		cache-size = <0x8000>; // L1, 32 KB
		timebase-frequency = <82500000>; // 82.5 MHz
		clock-frequency = <825000000>; // 825 MHz
		cache-level = <2>;
		next-level-cache = <&L2_1>; // phandle to L2

		L2_1: l2-cache {
			compatible = "cache";
			cache-unified;
			cache-size = <0x40000>; // 256 KB
			cache-sets = <0x400>; // 1024
			cache-line-size = <32>; // 32 bytes
			next-level-cache = <&L3>; // phandle to L3
		};
	};
};

Cache-specific sub-properties encompass compatible, cache-unified, cache-size, cache-sets, cache-line-size, and next-level-cache. Out of these, cache-unified, cache-size, cache-sets, and cache-line-size explicitly define the internal physical topology layout of the cache controller; developers familiar with microarchitecture specifications can parse these properties without extended commentary. The next-level-cache property holds the unique phandle referencing the subsequent lower level of the memory cache hierarchy, allowing an upstream cache controller to cleanly map and traverse downstream cache nodes.

Copyright © 2026 Guangzhou eSmart Information Technology Co., Ltd. All Rights Reserved.
All content in this book is copyrighted by the author. For personal learning and exchange only. Commercial use without authorization is strictly prohibited. Email:

✉ 3348194517@qq.com | hai616878@gmail.com