Device tree: telling the kernel how the board is put together
A file that records which devices are attached at which addresses and pins. The reason the same kernel can run on many boards.
Why it is needed
MCU firmware wrote pin numbers into the code for each board. Linux, to use the same kernel binary on many boards, separates the board configuration into a data file. That is the device tree (.dts → compile → .dtb).
Example: adding a temperature sensor on I2C
&i2c1 {
status = "okay";
clock-frequency = <400000>;
tmp102@48 {
compatible = "ti,tmp102";
reg = <0x48>;
};
};
compatible: the kernel finds the driver that matches this string and binds itreg: the address (I2C address, memory-mapped address)status = "okay": turns on a controller that is off by default
Overlays
Boards such as the Raspberry Pi add expansion-board configuration by laying an overlay (.dtbo) over the base .dtb. A dtoverlay= line in config.txt is exactly that.
Checking
- After boot, check the tree that was actually applied under
/proc/device-tree/ - Check that the driver bound with
dmesg | grep tmp102 - If the pin-function selection (pinctrl) is missing, the controller is on but no signal reaches the pins