What is a Device Tree?

Device tree nodes






A device tree (DT) is a file that contains information about the devices present on any given system. This can be any device that the physical system has such as a camera, keyboard, mouse, an LED, a hard drive, a modem, etc. It is a data exchange format used for exchanging hardware description data with the operating system, so that the operating knows about the devices present on a system.

The importance of a device tree is that it makes it unnecessary for the operating system to have all the hardware information about a system encoded in it. This makes sense because different machines and systems have differing devices on it. Instead of hardcoding the hardware information to the operating system, we instead include a device tree for a particular machine or embedded microcontroller or whatever hardware device we are working with. This way, the operating system can know all about the devices it is working with.

The device tree is passed to the operating system at boot time.

Previously this information was hardcoded into kernel source files. But this gets messy because it would then have to be modified when dealing with different physical systems. To avoid this, device trees are created for each particular hardware system. This device tree file will then be completely specific to a specific hardware system. For example, each specific beaglebone board would need its own device tree file. One beaglebone board differs from another in terms of physical devices on the board such as memory and other factors. Therefore, each version of a board requires its own device tree file.

Device trees make the approach more modular.

Device trees are a new and recommended way to describe non-discoverable devices (called platform devices) to the Linux kernel.

An operating system uses the Device Tree to discover the topology of the hardware at runtime, and thereby support a majority of available hardware (assuming drives are available for all devices).

Since the hardware information is not hardcoded into the kernel code, a single kernel image can support a wide range of hardware without any need for modifications.

So an operating system uses a device tree for platform identification (e.g., Beaglebone Black Board) and device population (memory, peripheral components, LEDs).

The kernel parses the device tree data and generates the required software data structure, which will be used by the kernel code.

Ideally, also, the device tree is independent of any operating system. So whether you are using Linux or another operating system such as Windows, the same device tree file can be used.



Related Resources





HTML Comment Box is loading comments...