UPGRADE YOUR BROWSER
We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!
01-09-2019 02:14 PM
I find myself fighting with the device-tree. What is the fastest way to generate the device tree?
I've tried:
petalinux-build -b device-tree
This takes about a minute on my computer. I've also tried:
petalinux-build -c device-tree -x build
But that seems to take about the same amount of time.
I found this post on Stackoverflow: https://stackoverflow.com/questions/38917745/quick-rebuild-of-device-tree-only-with-yocto-bitbake
The dtc aproach doesn't work, it appears I need to pre-process the device tree files into a single file (using GCC???).
01-09-2019 05:41 PM
Not sure if this will help you, but... if the .dts and .dtsi files located within the kernel source tree, then you can use the kernel's main Makefile to rebuild the .dtb. For example for arch/arm/boot/dts/zynq-zc702.dts you would run:
make ARCH=arm zynq-zc702.dtb
The above is done in the source code of the kernel (or wherever it was built). It will run gcc to combine multiple files, and then runs dtc to generate the .dtb. Takes less than 1 second on my machine.
01-10-2019 07:10 AM
Thanks for the reply. That doesn't work with Petalinux unfortunately.
01-10-2019 07:32 AM
you can create it manually. See the WIKI below:
https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18841722/ZCU102+Image+creation+in+OSL+flow
01-10-2019 07:50 AM
I'm not sure I follow. That page indicates you can use the DTC to compile your DTS to a DTB file:
dtc -I dts -O dtb -o my_dts/system-top.dtb my_dts/system-top.dts
The problem is the DTS/DTSI files that Petalinux generates has non-DTC compliant text in it. For example,t he ZCU104 system-top-dts file looks like this:
/* * CAUTION: This file is automatically generated by Xilinx. * Version: * Today is: Thu Jan 10 14:31:11 2019 */ /dts-v1/; #include "zynqmp.dtsi" #include "zynqmp-clk-ccf.dtsi" #include "zcu104-revc.dtsi" #include "pl.dtsi" #include "pcw.dtsi" / { chosen { bootargs = "earlycon clk_ignore_unused"; stdout-path = "serial0:115200n8"; }; aliases { ethernet0 = &gem3; i2c0 = &i2c1; i2c1 = &sensor_iic; serial0 = &uart0; serial1 = &uart1; spi0 = &qspi; }; memory { device_type = "memory"; reg = <0x0 0x0 0x0 0x7ff00000>; }; }; #include "system-user.dtsi"
Those #includes are not valid syntax. Some program needs to pre-process those includes to pull them in (like a C compiler pre-processor output). Further, my system-user.dtsi file contains includes from C header files:
#include <dt-bindings/media/xilinx-vip.h> ... xlnx,video-format = <XVIP_VF_MONO_SENSOR>;
This needs to be converted to a number and not a symbolic value. When I run the DTC on the top level DTS file I get the following errors:
nlbutts@ubuntu16:~/projects/maza_linux$ ./build/tmp/work/zcu104_zynqmp-xilinx-linux/device-tree/xilinx+gitAUTOINC+b7466bbeee-r0/recipe-sysroot-native/usr/bin/dtc -I dts -O dtb -o system.dtb -i./components/plnx_workspace/device-tree/device-tree ./components/plnx_workspace/device-tree/device-tree/system-top.dts Error: ./components/plnx_workspace/device-tree/device-tree/system-top.dts:9.1-9 syntax error FATAL ERROR: Unable to parse input tree n
I tried to use GCC -E, but the DTC syntax uses #, which causes problems.
01-10-2019 08:55 AM - edited 01-10-2019 09:01 AM
You're on the right track... and yes, you can call the "dtc" command directly. But as you also noted, the #includes need to be pre-processed. This is done using the C pre-processor (gcc -E is a way of running just the pre-processor).
Figuring out the exact right options to pass (include paths, etc) can be a bit fiddly. That's why I mentioned using the kernel's existing Makefile, which allows you to just do "make NAME.dtb" and it will do the gcc -E followed by dtc commands for you.
Doing it manually is certainly possible. If the system-top.dts is in the same place as the #includes it relies on, then you can just do the following:
cd my_dts gcc -E -nostdinc -undef -D__DTS__ -x assembler-with-cpp -o system-top.dts.tmp system-top.dts dtc -I dts -O dtb -o system-top.dtb system-top.dts.tmp
If the #includes are located in other places, you will need to add one or more -I flags to the gcc command. Each one specifies an additional directory to search for includes.
01-10-2019 09:16 AM
@rfs613 nice. Ill update the wiki to include this. However, in the OSL flow, there is no sytem-user.dtsi, but still useful info.
So, for reference:
cd <plnx_proj_dir>\components\plnx_workspace\device-tree\device-tree
gcc -I ../../../../project-spec/meta-user/recipes-bsp/device-tree/files -E -nostdinc -undef -D__DTS__ -x assembler-with-cpp -o system-top.dts.tmp system-top.dts
dtc -I dts -O dtb system-top.dtb system-top.dts.tmp
You can then verify, by converting back:
dtc -I dtb -O dts dump.dts system-top.dts.tmp
In my case, the only thing in the system-user.dtsi was:
&gem3 {
local-mac-address = [00 0a 35 00 22 02];
};
So, check if this was applied to the gem node:
ethernet@ff0e0000 {
compatible = "cdns,zynqmp-gem\0cdns,gem";
status = "okay";
interrupt-parent = <0x04>;
interrupts = <0x00 0x3f 0x04 0x00 0x3f 0x04>;
reg = <0x00 0xff0e0000 0x00 0x1000>;
clock-names = "pclk\0hclk\0tx_clk\0rx_clk\0tsu_clk";
#address-cells = <0x01>;
#size-cells = <0x00>;
#stream-id-cells = <0x01>;
iommus = <0x09 0x877>;
power-domains = <0x11>;
clocks = <0x03 0x1f 0x03 0x34 0x03 0x30 0x03 0x34 0x03 0x2c>;
phy-handle = <0x12>;
pinctrl-names = "default";
pinctrl-0 = <0x13>;
phy-mode = "rgmii-id";
xlnx,ptp-enet-clock = <0x00>;
local-mac-address = [00 0a 35 00 22 02];
phy@c {
reg = <0x0c>;
ti,rx-internal-delay = <0x08>;
ti,tx-internal-delay = <0x0a>;
ti,fifo-depth = <0x01>;
ti,rxctrl-strap-worka;
phandle = <0x12>;
};
};
01-18-2019 09:24 AM
Hi
From Linux kernel directory
"make arch=ARM CROSS_COMPILE=arm-xilinx-linux-gnueabi- dtbc"
this provides .dtb files for corrspending platform boards , which is intiated initailly with defconfig
Ex. For xilinx boards, zc702.dtb, zedboard.dtb etc.. will be created.
you can take whatever the board you want,
because here .dtsi represents SoC , .dts represents board file
when we say make ARCH=arm dtbc, it will create for all boards .dts files
Provide kudos if post is helpful
Thanks & Regards
Satish G