Q: How to use Device Tree (DTS) overlays for configuring hardware on embedded Linux?
Answer
Device Tree overlays (.dtbo) dynamically modify the base .dtb to enable/configure hardware without rebuilding the kernel. Create overlay: write a .dts with a fragment@0 { target = <&i2c1>; __overlay__ { status = okay; new_device@60 { compatible = ti,tmp117; reg = <0x60>; }; }; }; then compile: dtc -@ -I dts -O dtb -o my-overlay.dtbo my-overlay.dts. Load at boot: add dtoverlay=my-overlay to /boot/config.txt (RPi) or configure U-Boot fdt apply. Load at runtime: echo my-overlay > /sys/firmware/devicetree/base/ship. Verify with ls /proc/device-tree/. Remove: echo – > /sys/firmware/devicetree/base/ship. Always match compatible strings to kernel driver matches.
Filed under: FAQ
