一、設備樹生成及編譯
1、執行petalinux-create創建工程
2、執行petalinux-config --get-hw-description導入硬件配置
3、執行petalinux-config -c device-dree生成設備樹,生成的設備樹在petalinux_project\components\plnx_workspace\device-tree\ 目錄下
4、執行petalinux-build -c device-dree 編譯設備樹,編譯后的dtb文件為petalinux_project\pre-built\linux\images\system.dtb。(如果是執行petalinux-build則一步到位編譯設備樹、內核、uboot等)
注:如果不是第一次編譯設備樹,即使修改了設備樹執行petalinux-build -c device-dree也不會生成dtb文件,這時應先執行petalinux-build -c device-tree -x cleansstate 清理編譯狀態后再編譯設備樹。
二、修改設備樹
petalinux_project\components\plnx_workspace\device-tree\ 目錄下的設備樹是軟件自動生成的,最好不做修改,xilinux提供了一個用戶設備樹,該設備樹為:petalinux_project\project-spec\meta-user\recipes-bsp\device-tree\files\system-user.dtsi。petalinux_project\components\plnx_workspace\device-tree\ system-top.dts最終是包含了system-user.dtsi,如下圖所示:
1、將 system-user.dtsi復制到petalinux_project\components\plnx_workspace\device-tree\ 目錄下(如果將system-user.dtsi放在原來目錄,則修改無效,原因未知)
2、執行petalinux-build -c device-tree -x cleansstate清理設備樹編譯狀態
3、執行petalinux-build -c device-dree編譯設備樹
三、設備樹反編譯
dtb文件可用dtc編譯工具反編譯成dts,linux提供的dtc源碼在petalinux_project\build\tmp\work-shared\zynqmp-generic\
kernel-source\scripts\dtc目錄下。執行petalinux-build后,會將dtc源碼編譯成dtc應用程序petalinux_project\build\tmp\sysroots-components\x86_64\dtc-native\usr\bin\dtc,
可以把system.dtb復制到該目錄下,進入該目錄。執行“./dtc -I dtb -O dts -o system.dts system.dtb” 會生成system.dts。
或則使用linux自帶的dtc命令直接編譯:dtc -I dtb -O dts -o system.dts system.dtb