Download - All IT eBooks

Transcript
Chapter 2
The device tree should not be confused with the Linux kernel configuration. The device
tree specifies what devices are available and how they are accessed, not whether the
hardware is used.
The device tree was first used by the PowerPC architecture and was adopted later on by ARM
and all others, except x86. It was defined by the Open Firmware specification, which defined
the flattened device tree format in Power.org Standard for Embedded Power Architecture
Platform Requirements (ePAPR), which describes an interface between a boot program and
a client.
Platform customization changes will usually happen in the device tree without the need to
modify the kernel source.
How to do it...
A device tree is defined in a human-readable device tree syntax (.dts) text file. Every board
has one or several DTS files that correspond to different hardware configurations.
These DTS files are compiled into Device Tree Binary (DTB) blobs, which have the
following properties:
ff
They are relocatable, so pointers are never used internally
ff
They allow for dynamic node insertion and removal
ff
They are small in size
Device tree blobs can either be attached to the kernel binary (for legacy compatibility) or, as is
more commonly done, passed to the kernel by a bootloader like U-Boot.
To compile them, we use a Device Tree Compiler (DTC), which is included in the kernel source
inside scripts/dtc and is compiled along with the kernel itself, or we could alternatively
install it as part of your distribution. It is recommended to use the DTC compiler included in
the kernel tree.
The device trees can be compiled independently or with the Linux kernel kbuild system, as we
saw previously. However, when compiling independently, modern device trees will need to be
preprocessed by the C preprocessor first.
It's important to note that the DTC currently performs syntax checking but no binding
checking, so invalid DTS files may be compiled, and the resulting DTB file may result in a nonbooting kernel. Invalid DTB files usually hang the Linux kernel very early on so there will be no
serial output.
The bootloader might also modify the device tree before passing it to the kernel.
91