This section will detail how to modify a hardware device tree. It will not tell you how to modify a device tree for your specific hardware and peripherals, but it will provide the tools to do so.
A device tree is a way to represent hardware. It is comprised of many device tree source (DTS) files and DTS include (DTSI) files. When the source files are compiled, a flattened device tree (FDT), also known as a device tree blob (DTB), is created. QEMU and Linux use the DTB to understand the structure of the hardware without any hard coding involved.
Acquiring the Tools
Before proceeding, the following programs and files should be installed on your computer
BSPs, on this page we will use a ZCU102 BSP
Device tree compiler (DTC)
These are available with PetaLinux, Yocto, or Vitis tools.
Modifying a Device Tree
It is strongly recommended to read the device tree specification before modifying a device tree. The specification will cover the structure, syntax, and good practices of device tree modification.
Device Tree Properties and QEMU
QEMU uses device trees to represent hardware. This device tree is not passed to the guest and is sometimes referred to as the hardware device tree.
Some devices contain device-specific properties that should exist in the hardware device tree.
For example, an SI57X may have a device node that looks like:
As we can see, it only looks for the temperature-stability property.
If a property is not defined in a device node, QEMU will use a default value. In this case, 50PPM.
Device Tree Properties and the Guest
QEMU guests, such as Linux, can use device trees to understand the hardware it has access to. For instance, a guest device tree may list partitions for a SPI flash. So for this example, we will modify the device tree to add a partition to SPI flash on a ZCU102 platform using PetaLinux.
Create your ZCU102 project if you haven't already:
When modifying device trees, your changes must make sense as if you were representing physical hardware. Just because the device tree will build properly doesn't mean it will work properly with hardware, virtualized or otherwise.