This article introduces Linux device trees, and talks about some of the basics.
For related subjects, please refer to the SOC Table of Contents.
Device trees are tree structures used to describe a system’s physical hardware. Device trees consist of nodes, where each node contains information about the device it represents.
Note that device tree files have the extension .dts, which stands for device tree source. These files are typically located under the /arch/arm/boot/dts/ directory in the kernel.
As mentioned in the introduction, dts is the file type for device tree files. There is typically one written for each piece of hardware, thus resulting in large amounts of .dts files being stored in the kernel’s source code.
Shared dts settings can be abstracted to the dtsi file, which is similar to the h header file in C. For example, in the automatically generated system-top.dts file, we can see three .dtsi files included: zynq-7000.dtsi, pl.dtsi, and pcw.dtsi.
zynq-7000.dtsi mainly contains the hardware peripheral configuration information of the zynq-7000 series processors, pl.dtsi mainly consists of configuration information regarding the pl end peripheral, and pcw.dtsi mainly consists of the PS peripherals that are already enabled.
Note that we cannot directly edit .dtsi files.
dtc stands for device tree compiler, which is used to compile .dts files to corresponding binary files. The dtc tool is located in the scripts/dtc directory of the Linux kernel. If you wish to edit the dtc file, we need to go into the directory of the Linux source code and execute the command “make all” or “make dtbs”. Note make all compiles everything in the Linux source code, which includes zImage and device trees, and make dtbs only compiles the device tree.
.dtb files are obtained after compiling the .dts file to binary. Note that this is the same file that was used when transferring Linux systems.