One of the output products of a PetaLinux project is a compiled (binary) device tree. Sometimes we’d like to be able to read that compiled device tree to see exactly what is inside it. This can help with debugging a problem, or you may just want to make sure that your device tree additions are actually being pulled in. Either way, a compiled device tree can be “decompiled” using a tool that you can find hidden away in the PetaLinux build collateral.
Device tree compiler (DTC)
DTC is a tool that can be used to interpret a compiled device tree (.dtb) and convert
it into a text file (.dts). You can find DTC inside a build PetaLinux project after
has been run, but the exact path will depend on the version of PetaLinux that you are using. The paths
listed below are specifically for PetaLinux 2020.2, but the paths in earlier versions should be very
Where to find it
To find DTC in your PetaLinux project, first check the value of
project-spec/configs/config file. Now the path to DTC is given by the path shown
<CONFIG_YOCTO_MACHINE_NAME> replaced with the correct value for your project.
You also have to swap all of the dashes (
-) for underscores (
_) in the Yocto machine name.
Here’s an example path to DTC in a Microblaze based design where the Yocto machine name
Here’s an example path to DTC in a Zynq based design where the Yocto machine name is
How to use it
The compiled device tree of a PetaLinux project is
system.dtb and it can be found in the
images/linux directory. DTC can be called from that directory to parse the device tree like this:
../../<path-to-dtc>/dtc -I dtb -O dts -o system.dts system.dtb
The output file
system.dts is a text file that you can read in a text editor.