Creating Devicetree from Devicetree Generator for Zynq Ultrascale and Zynq 7000

In this brief demo, we will see how to generate the devicetree (dts) from the Xilinx devicetree generator (dtg). We will then compile this using the devicetree compiler. We can also discuss how to generate a patch for devicetree recipe used in Petalinux

Table of Contents

Downloading Devicetree sources from Github:

Here we shall be using the xilinx-v2018.3 branch of the devicetree generator:

dtg github
mkdir -p repo/my_dtg
cd repo/my_dtg
git clone https://github.com/Xilinx/device-tree-xlnx
cd device-tree-xlnx
git checkout xilinx-v2018.3

Generating the DTS from DTG:

Here, we shall be using the HSI to create the DTS:

hsi create dts
set hdf path/to/hdf-file.hdf
open_hw_design $hdf
set_repo_path ./repo
create_sw_design device-tree -os device_tree -proc psu_cortexa53_0
generate_target -dir my_dts
close_hw_design [current_hw_design]

proc

Here the -proc is set to psu_cortexa53_0. If user is targeting Zynq 7000, then this would be -proc ps7_cortexa9_0

For more information on the HSI API, and how to debug users can see the wiki here

If users noticed an issue in a older release. It is worth replicating in the master branch to see if the issue persists.

Compiling the DTS using DTC:

The DTC compiler can be used if the petalinux is sourced. However, users can compiler this manually too (see wiki here to manually compile DTC).

Also, in the devicetree, there is #include files which need to be precompiled, similar to a C application:

dtc
gcc -I my_dts -E -nostdinc -undef -D__DTS__ -x assembler-with-cpp -o my_dts/system-top.dts.tmp my_dts/system-top.dts
dtc -I dts -O dtb -o my_dts/system-top.dtb my_dts/system-top.dts.tmp

dtb to dts

If users made changes to the dts, compiled and want to verify the changes where added. Then, they can use the dtc to convert from dtb to dts

dtc -I dtb -I dts -o dump.dts my_dts/system-top.dtb

Generating DTG patch against a Petalinux version:

If users have noticed an error in the DTG, and want to patch the current version. Then they can create a patch in device-tree-xlnx. For example, here I will create a patch against 2018.3

create patch
cd repo/my_dtg/device-tree-xlnx
git diff xilinx-v2018.3 > 0001_your_patch_here.patch
Adding Patch to Petalinux devicetree recipe:

Copy the patch to project-spec/meta-user/recipes-bsp/device-tree/files and update the device-tree.bbappend as follows:

bbappend
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"

SRC_URI += "file://system-user.dtsi"

SRC_URI_append += " file://your_patch_here.patch"