Device Tree (dtb)

From postmarketOS
Revision as of 11:43, 8 May 2018 by MayeulC (talk | contribs) (→‎See also: Add a link to the mainlining guide)
Jump to navigation Jump to search

The Device Tree Blob (or binary) is a file containing information about the board and its hardware.

Why is it needed?

Most embedded platforms do not provide a way of discovering the hardware they have. You either have to resort to guesswork (which is not viable), or provide the Linux kernel with information about the board and the peripherals.

Before the dtb was introduced, each board needed a kernel specifically compiled for them, which was hardcoded to use the peripherals. With the dtb, a single kernel can run on multiple devices, if it is given the right dtb at boot time.

How is it created?

The dtb is created from device tree source (dts) files. Those contain the hardware description in a readable format. The dtb format merely exists to make loading them simpler for the kernel. As such, dts can be converted to and from dtb with a device tree compiler, dtc, which is available on most linux distributions.

How is it used?

The dtb is loaded in memory by the bootloader (often uboot) before the kernel is started.

Some older versions of uboot do not support loading a separate dtb file, which means that the dtb has to be embedded in the kernel zImage.


Some Qualcomm devices also use the QCDT format, where the dtb is appended to the end of the filesystem (boot.img) instead of the zImage.

Where can I find a dts for my device?

Those are generally present in the kernel fork your device uses. Look in the boards/ directory, or in arch/your_device_arch/boot/dts. When a board is mainlined, the corresponding dts file is mainlined as well (though those may be put in a separate repository in the future).

See also


Device Tree Blob (Flat Device Tree)

Linux documentation on the ARM boot process