Device Tree

(Redirected from Device tree)
Jump to: navigation, search

The Device Tree is a data structure for describing hardware. Mainline Linux uses it to activate and configure the drivers available in the kernel's binary (similar to script.bin for linux-sunxi). Mainline U-Boot is also migrating towards the device tree model.


Sources for information


For a general introduction on device trees see:

In a nut shell, the kernel uses properties of the form

compatible = "<manufacturer>,<model>"

to identify a driver and initialize it with the configuration additionally provided by more attributes or sub-section.

Particular Drivers

Every driver has its particular parameters, documented in:

Complete Examples

Writing a device tree for your board, you might want to look at:

Writing a Device Tree

It is good to start with an example of a device which is close to the one you're working on. Trim down the original device's dts to what your device actually provides. If your device came with a fex file, check settings like the gpio for enabling the usb vbus in the fex file and adjust them in the dts file as necessary. Finally, work on activating drivers particular to your device. Again parameters might be taken over from a fex file.

Coding Style

Recently, coding style moved over from using a full node hierarchy to using label references in board dts files, see e.g. :

Note that the nodes should be sorted alphabetically.

Get the Device-tree Compiler

This program is usually called dtc. You can retrieve a standalone version, or install a distribution-provided package (see below for some examples).

For Gentoo

emerge dtc

For openSUSE

zypper install dtc

For Debian/Ubuntu

apt-get install device-tree-compiler

For Arch

pacman -S dtc

Compiling the Device Tree

Device tree sources in the kernel deviate from the regular syntax, by using the cpp preprocessor for includes and substitution. This proceeds as follows:


cpp -nostdinc -I include -undef -x assembler-with-cpp $SRC > $TMP
dtc -O dtb -b 0 -o $DST $TMP
rm $TMP

Sticky-note-pin.png Note: A quick way to rebuild the device tree blobs for any enabled board(s) is to use the command make dtbs from an already configured kernel source directory.

Using the Device Tree

To actually make the kernel use the device tree, see Mainline_Kernel_Howto#Boot.

Adding a new device

Add your <device>.dts file to /arch/arm/boot/dts/ and include it to /arch/arm/boot/dts/Makefile as done in this patch. Help others by publishing your device tree as a patch.

Personal tools