
DT-Overlay
- Introduction. A device tree overlay is a file that can be used at runtime (by the bootloader in our case) to dynamically modify the device tree, adding nodes to the ...
- Build DT-Overlay from sources. The source code has been taken from the master branch which is pointing to the latest branch we use.
- Recent FAQ
What is a Devicetree overlay used for?
A Devicetree’s overlay purpose is to modify the kernel’s live tree, and have the modification affecting the state of the kernel in a way that is reflecting the changes.
What are DTDT overlays?
DT overlays are piece of device tree source codes that enables addition of extra nodes to the live device tree of an embedded linux system. They allow additional hardware devices to become part of current system.
What is an overlay source file?
The overlay source file, let's call it eeprom.dts, would have contents: The __overlay__ node contains the thing to insert into the device tree (the red part), and the target or target-path property specifies where to insert this into the device tree. An overlay can contain multiple fragments.
What is the uart1 device tree overlay?
Below is the device tree overlay for the UART1 device. It tells the kernel everything it needs to know in order to properly enable UART1 on pins P9_24 and P9_26.

What is Devicetree overlay?
A Devicetree’s overlay purpose is to modify the kernel’s live tree, and have the modification affecting the state of the kernel in a way that is reflecting the changes. Since the kernel mainly deals with devices, any new device node that result in an active device should have it created while if the device node is either disabled ...
What does FDT_APPLY do?
Call of_overlay_fdt_apply () to create and apply an overlay changeset. The return value is an error or a cookie identifying this overlay.
Does a callback store pointers?
Note that a notifier callback is not supposed to store pointers to a device tree node or its content beyond OF_OVERLAY_POST_REMOVE corresponding to the respective node it received.
How to write a DT overlay?
The code snippet below is DT overlay for MCP4132-502 which is attached to SPI0 and using chip select 1.
How to compile a DT overlay?
Now, once you have the DT overlay code written into a .dts file, you have to compile it to .dtbo file. Command to compile the .dts file is:
What is the purpose of a device tree?
A Device Tree’s overlay purpose is to modify the kernel’s live tree, and have the modification affecting the state of the kernel in a way that is reflecting the changes. Since the kernel mainly deals with devices, any new device node that result in an active device should have it created while if the device node is either disabled or removed all together, the affected device should be deregistered.
Does a callback store pointers?
Note that a notifier callback is not supposed to store pointers to a device tree node or its content beyond OF_OVERLAY_POST_REMOVE corresponding to the respective node it received.
Is API easy to use?
The API is quite easy to use.
The concept of Device Tree overlays
The Device Tree language is a way to describe hardware that is present in a system and cannot be automatically detected. That’s the case of devices directly implemented on a System on a Chip, such as serial ports, Ethernet or Nand flash controllers.
Writing Device Tree overlays
When the Device Tree overlays were first proposed, their syntax was very special and hard to remember. Fortunately, since version 1.5, the Device Tree compiler ( dtc) supports a much more natural syntax for writing such overlays.
Compiling Device Tree overlays
Once you have the source code of the your overlay, it is supposed to be easy to compile it with the Device Tree Compiler. This time, let’s take the example of the BBORG_FAN-A000.dts overlay for the Fan cape, slightly modified:
Applying Device Tree overlays
As we already explained, U-Boot is the place where the Device Tree Overlays should be applied. To do this, here are the commands to run in U-Boot. As an example, we’re using the BeagleBone Black and its Relay Cape as example, assuming all the files where copied to the first partition of a micro-SD card, containing a FAT filesystem:
Example usage on BeagleBone Black
You can of course follow this example, but you can also test it by yourself if you own the BeagleBone Black (or similar BeagleBone boards), and its Relay Cape.
What to remember
Device Tree Overlays are Device Tree fragments used to customize the Device Tree of a given board, typically to describe components added externally, including entire expansion boards, or tweak pin multiplexing.
Part One: Rockchip
Kernel provided DT overlay files are in /boot/dtbs/$ (uname -r)/rockchip/overlay/
Part Two: Meson
Kernel provided DT overlay files are in /boot/dtbs/$ (uname -r)/amlogic/overlay/
