Course contentsShow
← Embedded Systems & Computer Architecture
Lesson 786 of 93611. Introduction to Embedded LinuxFree lesson

Understanding the Role of Device Trees

Explain how the Device Tree separates hardware description from kernel code to provide a platform-independent approach to hardware initialization.

In this lesson, you will learn how the Device Tree acts as a structured data contract that decouples hardware topology from the compiled Linux kernel binary.

The Problem of Hardcoded Hardware

In early embedded Linux development, hardware details—such as memory base addresses, interrupt lines, and I/O pin assignments—were frequently hardcoded directly into the kernel source files. This meant that even a minor change to the hardware board revision required recompiling the entire kernel, leading to massive code duplication and a "one kernel per board" maintenance nightmare.

Decoupling via the Device Tree

The Device Tree (DT) solves this by separating the "what" (the hardware description) from the "how" (the kernel driver logic). The Device Tree is a tree-like data structure that describes the physical components of the system in a platform-independent format (the .dts source file). This file is compiled into a binary Device Tree Blob (.dtb) and passed to the kernel at boot time.

Instead of hardcoding memory addresses in a driver, a Linux driver now requests resources from the kernel based on the information provided in the DT. The kernel parses the binary blob, identifies the devices, and matches them to the appropriate drivers dynamically.

For example, a simple hardware description for a UART controller looks like this:

uart@48020000 {
    compatible = "ns16550a";
    reg = <0x48020000 0x1000>;
    interrupts = <72>;
    status = "okay";
};

In this snippet, the compatible string allows the kernel to identify which driver handles this specific controller, while the reg and interrupts properties provide the platform-specific parameters. Because the driver only looks for the ns16550a compatible string, the same driver code can run on a variety of different SoCs without modification. The kernel remains generic, while the Device Tree carries the unique DNA of your specific hardware configuration.

Key Takeaway: The Device Tree provides a platform-independent abstraction layer that allows the same kernel binary to support multiple hardware platforms by moving hardware-specific configuration into an external, data-driven structure.