The Complete Guide to Linux Device Trees
Learn the device tree language, how Linux uses it, and how to write, build, layer, validate and debug a board description from a blank file to a bound driver.

A board boots, prints half a kernel log and stops. Or it boots perfectly and the temperature sensor you soldered on last week is nowhere in /sys. Or a node you wrote carefully compiles without a single warning and the driver never runs. Each of those stories ends in the same file, the device tree, and each is solved by the same small set of ideas: what a node is, how a property is encoded, how the kernel turns a node into a device and a device into a bound driver, and how to look at what the kernel actually received. This guide teaches those ideas from a blank file to a working, validated board description. It uses Linux 6.12 and the device tree compiler 1.7, and every example is written so you can follow it with a 64-bit ARM board and a USB serial cable in front of you.
The guide is long on purpose. It builds one board description step by step, adds a driver that reads it, validates it against a schema and ends with a field manual of the failures that account for most of the time people lose. Where a topic deserves its own deep treatment, such as pin multiplexing, interrupts or overlays, the section here gives you the working model and the shape of the code, and the dedicated posts in this series go further.
Why Linux needs a description of hardware
A PC discovers its hardware by asking it. PCI devices answer a configuration query, USB devices announce themselves, and firmware hands the kernel ACPI tables that list what is soldered to the motherboard. An ARM system on a chip has none of that for its on-chip peripherals. The UART, the I2C controller and the interrupt controller are blocks of logic at fixed physical addresses, and reading an address where nothing lives can stall the bus. Someone has to tell the kernel what is where.
Until about 2011 the "someone" was C code. Every board had a file under arch/arm/mach-* holding tables of devices, and every board meant a kernel patch. The tree grew by thousands of files and the maintainers stopped it. The replacement was to move the description out of the kernel into a data file compiled separately, a format taken from the Open Firmware standard that PowerPC machines had used for years. ARM64 and RISC-V use it as the normal way to describe hardware, and so do many MIPS and PowerPC systems.
The practical consequence is the single most useful thing to know about this subject. The kernel image is board neutral. The same Image file runs on a Raspberry Pi, an i.MX board and a Rockchip board, and the only thing that changes is the device tree blob the bootloader hands over. When a board does not work, you are almost always looking for a wrong fact in a data file, and that is a much smaller search than a kernel.
The language: nodes, properties and values
A device tree is a tree of nodes. Each node has a name, a set of properties and zero or more child nodes. A property is a name with a value, or a name alone when it is a flag. The text form, device tree source in a .dts file, is the thing you write. Here is a complete, valid tree:
/dts-v1/;
/ {
model = "Acme Demo Board";
compatible = "acme,demo-board";
#address-cells = <1>;
#size-cells = <1>;
chosen {
bootargs = "console=ttyS0,115200";
};
memory@40000000 {
device_type = "memory";
reg = <0x40000000 0x10000000>;
};
};Read it from the outside in. /dts-v1/; declares the syntax version and is required in the file that gets compiled. / { ... }; is the root node, of which there is exactly one. The properties of the root say what the machine is: model is a human readable name, and compatible is a machine readable identifier. chosen is a special child that carries parameters the bootloader wants to pass to the kernel, the command line among them. memory@40000000 describes 256 MiB of RAM starting at 0x40000000.
Property values come in a handful of forms:
| Syntax | Meaning | Example |
|---|---|---|
"text" | A string | model = "Acme Demo Board"; |
"a", "b" | A list of strings | compatible = "acme,board", "acme,soc"; |
<1 2 3> | A list of 32-bit cells | reg = <0x40000000 0x10000000>; |
[0a 1b 2c] | A list of bytes | local-mac-address = [00 11 22 33 44 55]; |
<&label> | A reference to another node (a phandle) | clocks = <&clk 3>; |
| none | A boolean flag, present or absent | interrupt-controller; |
A cell is 32 bits, big endian, and it is the unit of nearly everything numeric. A 64-bit quantity takes two cells, high half first. Numbers are written in decimal or hexadecimal with 0x. A phandle is a number the compiler assigns to a node so another node can refer to it; in source you write the label of the target with an ampersand and the compiler fills in the number. Strings are NUL terminated in the binary, and a list of strings is stored back to back.
Two naming conventions run through everything. Property names use lowercase letters and hyphens, such as clock-frequency and interrupt-parent, and a few historical ones keep underscores, such as device_type. Node names are generic roles, such as serial or i2c, followed by @ and a unit address that repeats the first address in the node's reg. The unit address is how two nodes with the same role stay distinct: serial@10000000 and serial@10001000. The dedicated post on naming conventions covers the rules and the checks that enforce them.
Compiling and reading a tree
The device tree compiler, dtc, turns source into a blob, a compact binary with the extension .dtb, and back again. Compile the tree above and ask what it made:
dtc -I dts -O dtb -o minimal.dtb minimal.dts
file minimal.dtbminimal.dtb: Device Tree Blob version 17, size=200, boot CPU=0, string block size=102, DT structure block size=64The sizes depend on the source, so yours will differ. A silent dtc run means success. The blob begins with the magic number 0xd00dfeed, which is how a bootloader or a person recognizes one in a firmware dump. To go the other way, read a blob back into source:
dtc -I dtb -O dts minimal.dtb/dts-v1/;
/ {
model = "Acme Demo Board";
compatible = "acme,demo-board";
#address-cells = <0x01>;
#size-cells = <0x01>;
chosen {
bootargs = "console=ttyS0,115200";
};
memory@40000000 {
device_type = "memory";
reg = <0x40000000 0x10000000>;
};
};Notice what the round trip lost. Comments are gone, numbers print in a fixed hexadecimal form, and labels have vanished because they never reached the binary. Decompiling is the tool for the question that comes up on every board that does not behave: what does the kernel actually have? You can ask the running kernel directly, because it exposes the tree it received as a directory:
dtc -I fs -O dts /sys/firmware/devicetree/base | head -12
ls /proc/device-tree/The fs input format reads that directory and prints source, so you can diff what the bootloader passed against what you built. Expect differences the bootloader added, such as the real memory size and the command line.
Addresses, sizes and the cells that encode them
The line reg = <0x40000000 0x10000000>; is two numbers, a base address and a size, and whether they are two cells or four is decided not by the node that holds reg but by its parent. The parent's #address-cells says how many cells an address takes, and #size-cells says the same for a size. With both set to 1, as in the root above, reg is one address cell and one size cell. A 64-bit machine sets both to 2 at the root, and the memory node then reads reg = <0x0 0x40000000 0x0 0x10000000>;, four cells that still mean the same thing.
Defaults are a trap: if a node leaves the properties out, the language assumes 2 for addresses and 1 for sizes, which almost nobody intends. Set both on every node that has children with a reg.
Peripherals usually sit on a bus whose addresses are not the CPU's. The ranges property on the bus node says how a child address maps into the parent's space. Here a bus whose children count from zero is mapped to physical 0x10000000:
/ {
#address-cells = <2>;
#size-cells = <2>;
soc {
compatible = "simple-bus";
#address-cells = <1>;
#size-cells = <1>;
ranges = <0x0 0x0 0x10000000 0x10000000>;
serial@1000 {
compatible = "ns16550a";
reg = <0x1000 0x100>;
};
};
};The ranges entry reads: child address 0x0 maps to parent address 0x0 0x10000000 (two cells, because the parent is 64-bit) for a length of 0x10000000. So the UART at child address 0x1000 lives at physical 0x10001000. The kernel does that arithmetic for every reg, and the result is visible in /proc/iomem, where the device appears as 10001000.serial. The relevant post on ranges, #address-cells and #size-cells works through the 64-bit and 32-bit cases and the warnings dtc raises.
An empty ranges; means the child space is identical to the parent's. A missing ranges means the child addresses are private to the bus and cannot be translated, which is correct for I2C and SPI, whose reg values are bus addresses and chip selects and not memory addresses.
compatible: how a node finds its driver
The property that makes a node useful is compatible. It is a list of strings from most specific to least, each of the form "vendor,model", and the kernel uses it to choose a driver:
serial@1000 {
compatible = "acme,demo-uart", "ns16550a";
reg = <0x1000 0x100>;
};This node says: I am an Acme demo UART, and if you do not have a driver for that, treat me as a standard 16550. The kernel walks the registered drivers and picks the one whose match table contains the earliest string in the node's list. A driver declares its table like this:
static const struct of_device_id demo_of_match[] = {
{ .compatible = "acme,demo-uart" },
{ }
};
MODULE_DEVICE_TABLE(of, demo_of_match);The MODULE_DEVICE_TABLE line turns each entry into a module alias, so udev can load the right module when the device appears. You can see the strings the kernel holds for a bound device in sysfs:
cat /sys/bus/platform/devices/10001000.serial/ueventDRIVER=demo-uart
OF_NAME=serial
OF_FULLNAME=/soc/serial@1000
OF_COMPATIBLE_0=acme,demo-uart
OF_COMPATIBLE_1=ns16550a
OF_COMPATIBLE_N=2
MODALIAS=of:NserialT(null)Cacme,demo-uartCns16550aDRIVER= names the bound driver and the two OF_COMPATIBLE lines are the list in order. If DRIVER= is empty, no driver matched, and the first place to look is the spelling of the string. The dedicated post on compatible strings covers the ranking rules and the fallback pattern in detail.
From source file to a running kernel
The path a description takes to the kernel is worth knowing step by step, because each step is where a different class of mistake appears.
The first step is building. In the kernel tree, board files live under arch/arm64/boot/dts/<vendor>/, and they are not plain device tree source. They use the C preprocessor, so you see #include <dt-bindings/gpio/gpio.h> at the top. The build runs cpp first, then dtc, and a bare dtc on such a file stops with syntax error at the first #include. The preprocessor is what lets the source say GPIO_ACTIVE_LOW instead of 1, and it lets drivers and trees share the same headers. Build every board with make ARCH=arm64 dtbs, or one with make ARCH=arm64 vendor/board.dtb, and the blob appears next to the source.
The second step is loading. The bootloader, usually U-Boot, reads the blob from storage into RAM, optionally edits it, and starts the kernel with the blob's physical address in a register. On arm64 that is register x0. A typical sequence at the U-Boot prompt:
=> load mmc 0:1 ${kernel_addr_r} /boot/Image
=> load mmc 0:1 ${fdt_addr_r} /boot/dtbs/acme/acme-demo.dtb
=> booti ${kernel_addr_r} - ${fdt_addr_r}U-Boot also edits the tree before handing it over: it fills in /chosen/bootargs, resizes the memory node to the RAM it detected and adds a MAC address. The blob must be placed at an 8-byte aligned address and be no larger than 2 MiB, and it must not overlap the kernel or the initial RAM disk, which is why the load addresses matter.
The third step is parsing. Early in boot, before most of the kernel exists, the arm64 setup code verifies the blob and scans it. A blob without the right magic number produces a message on the early console and then a halt with no further output, which looks exactly like a hang:
Error: invalid device tree blob at physical address 0x000000004fa00000 (virtual address 0xffff00000fa00000)
The dtb must be 8-byte aligned and must not exceed 2 MB in sizeThe address in your case will differ. If you see no output at all, enable the early console, earlycon, on the command line, since a failure this early happens before the normal console exists.
The fourth step is device creation. After the early scan, the kernel walks the tree and creates a platform device for each node of a bus it knows how to populate (the root, and any node whose compatible includes simple-bus or similar), skipping those with status = "disabled". I2C and SPI controllers create their own children when they probe. Each created device then waits for a driver, as described in the previous section, and the driver's probe() function is called once the match succeeds.
The special nodes: chosen, aliases and memory
A few nodes at the root have a meaning the kernel defines.
chosen carries boot parameters. bootargs is the kernel command line, and stdout-path names the node to use as the console before any driver has probed:
chosen {
bootargs = "root=/dev/mmcblk0p2 rootwait";
stdout-path = "serial0:115200n8";
};The serial0 there refers to an entry in aliases, a node that gives stable names to devices so drivers number them predictably:
aliases {
serial0 = &uart0;
serial1 = &uart1;
i2c0 = &i2c0;
mmc0 = &sdhci0;
mmc1 = &emmc;
};Without aliases, a driver numbers its devices in probe order, which changes between boots when probing is asynchronous. With them, /dev/ttyS0 is always the same port and mmcblk0 is the same card slot. A fixed root device name in bootargs depends on that.
memory nodes describe RAM, and reserved-memory carves regions out of it for buffers a driver will use, such as a framebuffer or a block shared with a coprocessor:
reserved-memory {
#address-cells = <2>;
#size-cells = <2>;
ranges;
framebuffer@5f000000 {
reg = <0x0 0x5f000000 0x0 0x01000000>;
no-map;
};
};no-map tells the kernel not to map the region into its linear address space, so nothing else touches it. The region must lie inside the memory ranges, and a mismatch is a classic source of random memory corruption when a firmware or coprocessor writes where the kernel also allocates.
Layering a tree: SoC, module and board
Real trees are not written as one file. A chip vendor describes the SoC once, every peripheral present on the die, in a .dtsi include file, with most peripherals disabled because the chip does not know which pins a board wires out. A board file includes the SoC file, enables what the board uses and adds what is on the board:
/ {
#address-cells = <1>;
#size-cells = <1>;
soc {
compatible = "simple-bus";
#address-cells = <1>;
#size-cells = <1>;
ranges;
uart0: serial@10000000 {
compatible = "ns16550a";
reg = <0x10000000 0x100>;
status = "disabled";
};
};
};/dts-v1/;
#include "acme-soc.dtsi"
/ {
model = "Acme Demo Board";
compatible = "acme,demo-board", "acme,soc";
};
&uart0 {
status = "okay";
};The uart0: before the node is a label, a compile-time name, and &uart0 outside a node is a block that merges into the node the label names. The rules of the merge are the whole mechanism: a repeated node combines with the earlier one, a repeated property replaces the earlier value, and new children are added. The board's status = "okay" therefore replaces the SoC's "disabled". The order of inclusion matters because the last definition wins.
To remove what a lower layer defined, use /delete-property/ and /delete-node/. The post on .dtsi includes and labels shows a three-layer tree and the decompiled result.
Providers and consumers: clocks, resets, regulators and GPIOs
A device rarely works from its registers alone. It needs a clock, perhaps a reset line, a power rail and some GPIOs. The device tree models each of these as a provider node that offers a resource and a consumer that refers to it with a phandle and optional arguments. The pattern is the same in every subsystem, and learning it once covers all of them.
The provider declares how many argument cells select a resource, with a #...-cells property:
clk: clock-controller@10003000 {
compatible = "acme,clk";
reg = <0x10003000 0x100>;
#clock-cells = <1>;
};
gpio1: gpio@10004000 {
compatible = "acme,gpio";
reg = <0x10004000 0x100>;
gpio-controller;
#gpio-cells = <2>;
};
reg_3v3: regulator-3v3 {
compatible = "regulator-fixed";
regulator-name = "3v3";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
regulator-always-on;
};The consumer then writes a phandle and the arguments the provider asked for:
#include <dt-bindings/gpio/gpio.h>
sensor@48 {
compatible = "acme,sensor";
reg = <0x48>;
clocks = <&clk 3>;
clock-names = "xtal";
vdd-supply = <®_3v3>;
reset-gpios = <&gpio1 7 GPIO_ACTIVE_LOW>;
};<&clk 3> is the clock controller and clock number 3, one argument cell because #clock-cells = <1>. reset-gpios is the controller, pin 7 and a flag, two cells because #gpio-cells = <2>. The -names properties let the driver ask for a resource by name instead of position. A driver then needs no knowledge of the numbers:
priv->clk = devm_clk_get(dev, "xtal");
priv->reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);Both calls read the properties above. devm_gpiod_get(dev, "reset", ...) looks for reset-gpios, and the GPIO_ACTIVE_LOW flag means the driver can write logical 1 to assert reset without knowing the electrical polarity. The polarity lives in the tree, where the schematic is, and not in the driver, where it would be wrong on the next board.
The interrupt model has the same shape with more indirection, because controllers chain. The dedicated post on interrupts, interrupt-parent and interrupt-map covers it, and the pinctrl post covers the subsystem that muxes pins.
Pins, buses and the devices on them
Most SoC pins serve several functions, and the pin controller chooses which. A device names the configuration it needs with pinctrl-names and pinctrl-0, and the driver core applies the default state before the driver's probe() runs:
&uart0 {
pinctrl-names = "default";
pinctrl-0 = <&uart0_pins>;
status = "okay";
};The group uart0_pins is defined in the pin controller's node using that vendor's bindings. A UART enabled with no pin state works only if the bootloader happened to leave the pins muxed, which is a classic "works from U-Boot, dies in Linux" bug.
Devices on I2C and SPI are children of their controller node, and their reg is a bus address and not a memory address. The parent sets #address-cells = <1> and #size-cells = <0>:
&i2c1 {
status = "okay";
clock-frequency = <400000>;
#address-cells = <1>;
#size-cells = <0>;
temperature-sensor@48 {
compatible = "ti,tmp102";
reg = <0x48>;
};
};
&spi0 {
status = "okay";
#address-cells = <1>;
#size-cells = <0>;
adc@0 {
compatible = "microchip,mcp3008";
reg = <0>;
spi-max-frequency = <1000000>;
};
};On I2C, reg is the 7-bit address. On SPI it is the chip select number, and spi-max-frequency is mandatory. After boot the kernel creates 1-0048 under /sys/bus/i2c/devices/ and spi0.0 under /sys/bus/spi/devices/, which is how you confirm the nodes did their job.
A driver that reads the tree
To see the whole path in one place, here is a small platform driver that a node with compatible = "acme,demo-uart" binds to. It maps its registers, reads a property and logs both:
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/of.h>
#include <linux/io.h>
struct demo_priv {
void __iomem *base;
};
static int demo_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct demo_priv *priv;
u32 freq;
int ret;
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
priv->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(priv->base))
return PTR_ERR(priv->base);
ret = of_property_read_u32(dev->of_node, "clock-frequency", &freq);
if (ret)
return dev_err_probe(dev, ret, "missing clock-frequency\n");
dev_info(dev, "registers mapped, input clock %u Hz\n", freq);
platform_set_drvdata(pdev, priv);
return 0;
}
static const struct of_device_id demo_of_match[] = {
{ .compatible = "acme,demo-uart" },
{ }
};
MODULE_DEVICE_TABLE(of, demo_of_match);
static struct platform_driver demo_driver = {
.probe = demo_probe,
.driver = {
.name = "demo-uart",
.of_match_table = demo_of_match,
},
};
module_platform_driver(demo_driver);
MODULE_DESCRIPTION("Device tree demonstration driver");
MODULE_LICENSE("GPL");The matching node:
serial@10000000 {
compatible = "acme,demo-uart";
reg = <0x10000000 0x100>;
clock-frequency = <24000000>;
};Loading the module prints one line, with the device name taken from the translated address:
demo-uart 10000000.serial: registers mapped, input clock 24000000 Hzdevm_platform_ioremap_resource(pdev, 0) reads the first reg entry, translated through any ranges, and maps it. of_property_read_u32() reads one cell from a property by name. dev_err_probe() logs a failure and, if the error is a request to retry later, records the reason in /sys/kernel/debug/devices_deferred. Remove the clock-frequency line and the probe fails with missing clock-frequency, and the device stays unbound: that is how a missing property shows up in practice. The driver never contained an address, an interrupt number or a clock rate, and moving it to another board is a change to the tree.
Overlays and changes at boot
A tree that describes a board with an optional daughter board has two choices: carry a variant of the whole file for each combination, or describe the daughter board once as an overlay that is merged into the base. An overlay is device tree source with /plugin/; at the top, whose fragments name where to attach their contents:
/dts-v1/;
/plugin/;
&i2c1 {
#address-cells = <1>;
#size-cells = <0>;
touch@38 {
compatible = "edt,edt-ft5x06";
reg = <0x38>;
};
};Build it with dtc -@ -I dts -O dtb -o display.dtbo display-overlay.dts, and the base tree must have been built with -@ so its labels exist as symbols in the blob. The merge usually happens in the bootloader: U-Boot's fdt apply and the fdtoverlays keyword of extlinux.conf do it, and the Raspberry Pi firmware does it from dtoverlay= lines in config.txt. The kernel itself can also apply an overlay at run time on kernels with CONFIG_OF_OVERLAY, which suits hot-pluggable boards and needs driver support for removal. The overlay posts cover each route.
Bindings: the contract and how to check it
A node's properties are not free-form. Each compatible has a binding, a document that says which properties are required, which are allowed and what they mean. Since 2018 bindings are written as YAML schemas under Documentation/devicetree/bindings/ and validated by a tool, so an error in a tree is found at build time and not at probe time. A schema for the demo UART:
%YAML 1.2
---
$id: http://devicetree.org/schemas/serial/acme,demo-uart.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: Acme demo UART
maintainers:
- Jane Developer <[email protected]>
properties:
compatible:
const: acme,demo-uart
reg:
maxItems: 1
clock-frequency:
description: Frequency of the input clock in hertz.
required:
- compatible
- reg
- clock-frequency
additionalProperties: false
examples:
- |
serial@10000000 {
compatible = "acme,demo-uart";
reg = <0x10000000 0x100>;
clock-frequency = <24000000>;
};
...Install the checker with pip install dtschema, then validate the schema's own example and then every board that uses the binding:
make ARCH=arm64 dt_binding_check DT_SCHEMA_FILES=acme,demo-uart.yaml
make ARCH=arm64 dtbs_check DT_SCHEMA_FILES=acme,demo-uart.yamlA board that omits the frequency fails with a message that names the file, the node and the rule:
arch/arm64/boot/dts/acme/acme-demo.dtb: serial@10000000: 'clock-frequency' is a required property
from schema $id: http://devicetree.org/schemas/serial/acme,demo-uart.yaml#additionalProperties: false turns a misspelled property into an error as well, which is the failure that otherwise costs an afternoon: a clock-frequence that nothing reads and nothing reports. The posts on dtbs_check and on writing a binding cover the schema language and the workflow for sending one upstream.
Debugging a tree on a running board
Every board that misbehaves lets you ask the same four questions in the same order, and each has a direct answer from the running system.
What did the kernel receive? Decompile the live tree and compare it with what you built.
dtc -I fs -O dts /sys/firmware/devicetree/base > running.dts
dtc -I dtb -O dts arch/arm64/boot/dts/acme/acme-demo.dtb > built.dts
diff -u built.dts running.dtsExpect the bootloader's bootargs, memory size and MAC address and not much more. A larger difference means the board loaded a different blob than you think, from another partition or an old copy, and that is the cause more often than a wrong edit.
Did the node become a device? Look under /sys/bus/platform/devices/, /sys/bus/i2c/devices/ or /sys/bus/spi/devices/. If it is missing, the node is disabled, under a disabled parent, or on a bus whose controller has not probed.
Did a driver bind? A bound device has a driver symlink, and uevent shows DRIVER= and the compatible strings the kernel saw. An empty driver with a correct node means the string does not match any driver table or the driver is not built.
Did it fail or wait? Read dmesg for probe ... failed with error, and read /sys/kernel/debug/devices_deferred for devices waiting on a dependency. The error -517 is a request to retry, and the dependency it waits on is where to look. Probe failures and deferral have a dedicated post with a full triage routine.
Two kernel parameters help during bring-up: earlycon prints before the normal console exists, and deferred_probe_timeout=10 makes the kernel report which devices are still waiting after that many seconds.
A field manual of the failures that cost the most time
These are the mistakes that appear again and again, with how to recognize them.
| Symptom | Likely cause | First check |
|---|---|---|
| Silent after "Starting kernel" | Invalid or misplaced blob, or no early console | earlycon on the command line, fdt addr and fdt print in U-Boot |
Node in /proc/device-tree, no device | status is not okay, or the parent does not instantiate children | cat the node's status; check parent compatible |
Device exists, no driver link | compatible typo, or driver not built | uevent, then grep the string in the kernel source |
Probe fails with -2 or -22 | A required property is missing or invalid | The driver's of_property_read_* calls against your node |
Probe returns -517 forever | A dependency never probed | devices_deferred, then the supplier's own state |
| UART silent in Linux but fine in U-Boot | No pinctrl state, so the mux is wrong | pinctrl-names and pinmux-pins in debugfs |
| Interrupt never fires | Wrong cell values or parent | /proc/interrupts for the hardware number and trigger |
| Registers read zero or the bus hangs | Wrong reg, or ranges missing | /proc/iomem against the datasheet address |
| Works on one board, not the next | A value copied from the wrong layer | Where each property is defined in the include chain |
When a symptom does not fit a row, return to the four questions above. They narrow any case to one of the five states a node can end in: absent, created with no driver, matched with a failed probe, deferred or bound.
A habit prevents most of this table: build with W=1 so dtc runs its extra checks, and run dtbs_check on every change. The unit address and reg mismatches, the missing size cells and the unknown properties are all caught before a board is involved.
CPUs, the interrupt controller and the timer
A board description is not only peripherals. The kernel also needs to know the processors, how to start them and where the interrupt controller and system timer are. These nodes come from the SoC file, and a board almost never changes them, but reading them once makes every vendor tree less opaque.
cpus {
#address-cells = <2>;
#size-cells = <0>;
cpu0: cpu@0 {
device_type = "cpu";
compatible = "arm,cortex-a53";
reg = <0x0 0x0>;
enable-method = "psci";
};
cpu1: cpu@1 {
device_type = "cpu";
compatible = "arm,cortex-a53";
reg = <0x0 0x1>;
enable-method = "psci";
};
};
psci {
compatible = "arm,psci-1.0";
method = "smc";
};Each cpu@N node's reg is the CPU's identifier, the value of its MPIDR register that firmware knows it by, and not an address in memory, which is why #size-cells is 0 here. enable-method = "psci" says secondary CPUs are started by calling firmware through the Power State Coordination Interface, and the psci node says that call is made with the smc instruction. Boot a kernel with a wrong method and the secondary cores never come online. The kernel tells you in the early log:
psci: probing for conduit method from DT.
psci: PSCIv1.1 detected in firmware.
psci: Using standard PSCI v0.2 function IDs
psci: Trusted OS migration not required
smp: Bringing up secondary CPUs ...
smp: Brought up 1 node, 2 CPUsThe exact lines depend on your firmware, and a board that stops after Bringing up secondary CPUs is waiting on a core that firmware could not start.
The interrupt controller and the architectural timer follow the same shape. The GIC node you met in the section on providers has interrupt-controller; and three interrupt cells, and the timer lists four private peripheral interrupts that every ARMv8 core has:
timer {
compatible = "arm,armv8-timer";
interrupts = <GIC_PPI 13 IRQ_TYPE_LEVEL_LOW>,
<GIC_PPI 14 IRQ_TYPE_LEVEL_LOW>,
<GIC_PPI 11 IRQ_TYPE_LEVEL_LOW>,
<GIC_PPI 10 IRQ_TYPE_LEVEL_LOW>;
};Without a working timer node the kernel has no clock tick and stops very early with no clear message, one of the quietest boot failures there is. Treat these three nodes, cpus, psci and timer, as part of the SoC and change them only on advice from the vendor.
Reading a vendor tree you did not write
Most of the time you inherit a tree and need to understand it, so reading is a skill worth practicing. This order works for any board.
Start from the board file and read only it: the
model, thecompatiblelist, thechosenandaliasesnodes and every&labelblock. These are the board's decisions, and they are usually under two hundred lines.Follow each
#includeupward to the file that holds the layer below it, and note which layers exist: SoC, module, board.For one device you care about, such as the UART, find the original definition by its label in the SoC file. Read its
compatible,reg,interrupts,clocksandstatus, then read the board's override of it. The difference is the board's contribution.Open the binding for its
compatibleunderDocumentation/devicetree/bindings/and check each property against the list of allowed ones.Open the driver, found by searching the kernel for the compatible string, and read
probe()to see which properties it reads and what it does when one is missing.Compare with the running system: decompile
/sys/firmware/devicetree/baseand confirm the result matches what you read.
Those six steps take about twenty minutes for one device, and they replace the guessing that otherwise fills an afternoon. The point of step five deserves emphasis: the driver is the authority on what a property means in practice, whatever the binding says, and when they disagree the kernel is right and the binding has a bug.
The order to write a new board
When you write a tree for a new board from the SoC file, resist the urge to start with the exciting peripherals. The order that fails least is the order the kernel needs things.
First, the root: model, compatible and the cells. Second, memory with the right size and chosen with stdout-path, so the console works. Third, aliases for the serial port. Fourth, enable the console UART and its pin state. At this point the board should boot to the early console, and you should build and test it before going further, because a failure from here on is in what you added last. Then add peripherals one at a time in the order storage, network, buses and sensors, and after each one check the sysfs entry and a data read before moving on. A tree written all at once and tested at the end leaves you to find several mistakes that interact, and a tree grown in steps leaves you one at a time.
The status property and who creates a device
The status property decides whether a node becomes a device at all. A node with no status is treated as enabled. The values the specification defines are "okay", "disabled", "reserved", "fail" and "fail-sss", and in practice you meet the first two nearly always. "disabled" means the hardware exists and should not be used, which is how a SoC file ships every peripheral, and "reserved" means the device is in use by something else, such as secure firmware, and the kernel must not touch it. The kernel's helper of_device_is_available() treats a node as present when status is absent, "okay" or the old spelling "ok".
Disabling a parent disables everything below it for the purposes of device creation. If you enable a UART whose parent bus is disabled, the UART never appears, and the symptom is the one in the field manual above: the node is in /proc/device-tree and absent from sysfs. The check is to read the status of each ancestor, from the node up to the root.
It also matters who turns a node into a device. The kernel creates platform devices for the children of the root and of any node with a compatible string of "simple-bus", "simple-mfd" or similar, through of_platform_populate(). The children of an I2C controller are created by the I2C core when the controller driver registers its adapter, and the children of an SPI controller by the SPI core. A node placed under a parent that nobody populates stays a node forever. When you write a bus node of your own, such as a bridge or a block of memory mapped peripherals under a custom controller, give it compatible = "simple-bus" and the right ranges, or its children will never become devices.
cat /proc/device-tree/soc/status 2>/dev/null || echo "no status property (enabled)"
ls /sys/bus/platform/devices/ | head -5no status property (enabled)
10000000.serial
10003000.clock-controller
10004000.gpio
fe000000.sdhciThe device names are the translated unit addresses followed by the node name, which is the quickest way to match a sysfs entry to its node. Yours depend on the board.
The bootloader can also change status. U-Boot commands such as fdt set /soc/serial@10000000 status okay edit the tree in memory before the kernel starts, and some vendor boot scripts enable or disable nodes depending on the detected board revision. When a tree behaves differently from its source, diff the running tree against the built one, as the debugging section describes, and the bootloader's edits show up directly.
Where this guide does not apply
The device tree is the right tool on ARM, ARM64, RISC-V and the embedded MIPS and PowerPC systems. It is not the answer everywhere.
PCs and servers using ACPI. x86 machines and ARM servers that boot through UEFI describe their hardware with ACPI tables, and the kernel reads those. If you work on such a system, the tools here help little and acpidump and lspci help a lot. Some arm64 systems support both, and the firmware chooses which to hand over.
Microcontrollers without Linux. An STM32 or an RP2040 running a bare-metal or RTOS program does not use a Linux device tree. Zephyr borrows the syntax for its own hardware description, with its own bindings and generated headers, so skills transfer but files do not.
Devices that can describe themselves. A PCIe card or a USB device is found by enumeration. The tree describes the host controller, and the card needs no node.
Vendor kernels with out-of-tree bindings. A BSP from a chip vendor may use properties that only its fork understands. The checker cannot validate those, and the working reference is that vendor's kernel source. Plan to carry the difference, or to upstream the driver, as the board support posts of this series discuss.
For someone who maintains a product, the boundary that matters is ownership. The SoC file belongs to the vendor, the board file to you, and every property you add to the first one is a patch you carry on every kernel update. Keep your changes in the board layer where the language lets you, and the next kernel upgrade is a rebuild and a re-test and not a merge.


