Home / Learn Chip Programming / Device Tree: Describing Hardware to the Kernel
Device Tree: Describing Hardware to the Kernel
A text file tells Linux which chips exist and where.
Theory in plain words
What it is
A device tree (.dts) is a data structure that lists CPUs, memory, buses and devices with addresses, interrupts and properties. It is compiled to a .dtb binary that U-Boot passes to the kernel.
Why we use it
The same kernel binary works on many boards because the hardware description is separate. Adding a sensor means adding a node, not changing kernel code.
How it works
Nodes are named device@address; compatible strings select the driver; reg gives the address; interrupts and clocks reference other nodes; status = "okay" enables it.
Where it is used
- Adding an I2C sensor on Raspberry Pi
- Custom board bring-up
- Overlays
Device tree node builder
The node name carries the address; the compatible string selects the driver. After adding it the sensor appears under /sys/bus/iio or /dev.
| Property | Meaning |
|---|---|
| compatible | driver match string "vendor,model" |
| reg | address and size (or I2C address) |
| status | "okay" or "disabled" |
| interrupts / interrupt-parent | which IRQ line |
| clocks / resets | references to clock and reset controllers |
| pinctrl-0 | pin multiplexing setup |
| gpios | GPIO controller, pin, flags |
dtoverlay=i2c-rtc,ds3231) instead of editing the full tree.Quick quiz
1. What does "compatible" do?
The kernel matches it with driver tables.
2. Compiled device tree extension?
Device tree blob.
Common questions
What does "compatible" do?
Selects the matching driver. The kernel matches it with driver tables.
Compiled device tree extension?
.dtb. Device tree blob.