petalinux 修改设备树

一、设备树生成及编译

  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

 

posted @ 2021-02-26 18:34  YYFaGe  阅读(5958)  评论(0编辑  收藏  举报