Skip to content

Day04 - Device Tree Overlay


Objective

  • Understand how to create a Device Tree Overlay
  • Compile .dts into .dtbo
  • Load overlay dynamically on Raspberry Pi

Environment

  • Board: Raspberry Pi 5
  • OS: Debian (Raspberry Pi OS Lite)
  • Architecture: arm64

Step 1 — Create DTS File

Create a file:

nano test-device.dts

Example content:

/dts-v1/;
/plugin/;

/ {
compatible = "brcm,bcm2712";
fragment@0 { target-path = "/";

__overlay__ {
    test_device {
        compatible = "test,device";
        status = "okay";
    };
};

}; };


Step 2 — Compile Device Tree Overlay

dtc -@ -I dts -O dtb -o test-device.dtbo test-device.dts

Step 3 — Load Overlay

sudo dtoverlay test-device

Step 4 — Verify

Check kernel logs:

dmesg | tail

Observations

  • Overlay can be loaded dynamically without reboot
  • Kernel accepts new hardware description at runtime
  • No actual driver is bound yet (no compatible match)

Key Learnings

  • Device Tree describes hardware, not behavior
  • Overlay modifies existing Device Tree
  • compatible is critical for driver matching

Common Issues

1. dtc not found

Install:

sudo apt install device-tree-compiler

2. Overlay not applied

Check:

dmesg | grep overlay

Next Step

  • Bind Device Tree to a real driver
  • Explore platform driver model