Home » Linux Kernel » DTS (Device Tree) File Syntax

DTS (Device Tree) File Syntax

A Device Tree Source (DTS) file is used in the context of the Linux kernel to describe the hardware structure and configuration of a system. It provides a way to specify information about the devices and their connections on a particular platform, enabling the kernel to dynamically configure itself based on the hardware it runs on. Here’s a brief overview of the syntax used in a Device Tree Source file:

Device Tree Header:


This line signifies the version of the Device Tree Source format being used.

Include Statements:

#include <dt-bindings/interrupt-controller/irq.h>
#include "some_other_file.dtsi"

Include statements are used to include other Device Tree Source files or headers.

Node Definition:

node {
    compatible = "vendor,board";
    model = "Example Board";
    // Properties and subnodes go here

Nodes describe devices or components in the hardware system. The compatible property helps the kernel match the node to a device driver.

Property Definition:

property-name = <value>;

Properties describe characteristics of a node. They can have various types, such as strings, integers, or arrays.


subnode {
    // Subnode properties and subnodes go here

Nodes can have subnodes, providing a hierarchical structure to describe complex hardware arrangements.

Phandles and References:

some_device@0 {
    // ...
    phandle = <&some_other_device>;

Phandles are used to create references between nodes, allowing one device to refer to another.


interrupts = <2 3>;
interrupt-parent = <&gpio0>;

Describes interrupt information for a device. The format can vary depending on the hardware architecture.

Address Cells and Size Cells:

reg = <0x1 0x2 0x3>;

Specifies the address and size of a device’s register space. The number of cells used depends on the hardware architecture.


aliases {
    ethernet0 = &some_ethernet_device;

Aliases provide convenient names for commonly referenced nodes.

This is a basic overview, and the structure can become more complex depending on the specific hardware and system configuration. Device Tree Source files are typically compiled into Device Tree Blob (DTB) files, which are then used by the Linux kernel during boot to configure the system.

Subscribe our Rurban Life YouTube Channel.. "Rural Life, Urban LifeStyle"

Leave a Comment