Modify Petalinux Device Tree

June 26, 2019


Recently I have noticed that it is not easy to modify the device tree in the image.ub generated by Petalinux. Based on the Xilinx wiki page, the main challenge is that devicetree.dtb file is no longer exposed in the boot partition. Instead, the image.ub wraps it up along with uImage and possibly other images together. In this case there are certain steps to follow in order to change that device tree during boot time.


I have put a Github gist document on this. To summarize, the basic flow is:


1. Extrace device tree from image.ub. For example,

dumpimage -T flat_dt -p 1 -i image.ub system.dtb


2. Use dtc to de-compile it into user-readable format.

dtc -I dtb -O dts -o system.dts system.dtb


3. Modify system.dts and save.


4. Recompile the device tree blob.

dtc -I dts -O dtb -o system.dtb system.dts


5. Bake the device tree into the new image.ub.

mkimage -f image.its image.ub


If you boot your system with the new image.ub, you will be able to see the changes you just made to the system device tree. For more information, please refer to the Github gist mentioned previously.