设备树生成方法汇总

作者:Terry Ni,AMD工程师;来源:AMD开发者社区

一、引言

设备树(Device Tree)是一种数据结构,用于描述计算机硬件组件,以便操作系统内核能够识别和管理这些组件。随着嵌入式工具的不断发展,设备树也分为了传统设备树(classic device-tree)和系统设备树(sytem device-tree)。在Vitis 2022版本之前,只能使用传统设备树(classic device-tree),而在2022版本之后加入了系统设备树(system device-tree)。系统设备树(System device-tree)的使用,可以更好的契合嵌入式开发的流程。比传统设备树中包含更多的硬件或者组件的描述信息,不再只是包含Linux或APU需要使用到的信息。下面以2024.2版本为例,分别汇总传统设备树(classic device-tree)和系统设备树(system device-tree)的生成方法,便于大家使用。

二、传统设备树(classic device-tree)生成

1. 利用petalinux工具

a. 创建一个petalinux工程,以zynqMP器件为例

petalinux-create -t project --template zynqMP --name petalinux-for-device-tree

b. 导入XSA

Petalinux-config --get-hw-description=../myprj.xsa –silentconfig

c. 生成设备树文件

petalinux-config -c device-tree

d. 设备树文件在petalinux工程目录的/components/plnx_workspace/device-tree/device-tree文件夹中

1.png

e. 如果你需要生成dtb文件,那么执行petalinux-build指令后,可以在images\linux目录下找到。

petalinux-build -c device-tree

2.png

2. 利用vitis工具

Classic IDE流程:

a. 从git下载传统设备树的生成源码

git clone https://github.com/Xilinx/device-tree-xlnx.git

b. 打开Vitis classic IDE后,在window下选择Preferences,然后在Software Reposition中把下载的传统设备树源码位置添加进去。

3.png

c. 然后在Vitis菜单栏下选择“Generate Device Tree”

4.png

d. 选择XSA文件,以及输出的文件夹,就可以生成传统设备树了

5.png

Unified IDE流程:

a. 打开vitis unified IDE后,选择一个worksapce

b. 选择创建一个platorm,并且选择XSA文件

c. 在platform\Sources\hw\sdt文件夹下就可以看到生成的设备树源码文件。

6.png

3. 利用xsct工具

a. 安装了vitis软件或者vivado_lab之后,运行XSCT(Software commandline Tool)工具

7.png

b. 使用createdts命令生成设备树

createdts -hw myprj.xsa -platform-name my_devicetree -out ../

c. 在my_devicetree/psu_cortexa53_0/device_tree_domain/bsp下找到设备树文件

8.png

三、系统设备树(system device-tree)生成

1、利用xsct工具

a. 运行XSCT(Software commandline Tool)工具

b. 配置XSA和输出文件夹

 sdtgen set_dt_param -xsa ../myprj.xsa -dir outdir

c. 生成系统设备树

sdtgen generate_sdt

d. 在输出文件夹中找到生成的设备树文件

四、设备树生成git源文件

传统设备树和系统设备树生成源文件都已在git开源。链接地址如下:

传统设备树git:https://github.com/Xilinx/device-tree-xlnx

系统设备树git:   https://github.com/Xilinx/system-device-tree-xlnx

最新文章

最新文章