释放 Vitis Unified IDE 中系统设备树 (SDT) 的潜力
Introduction 介绍
In this short blog, users will learn about the System Device Tree (SDT) and how it is used in the Vitis Unified IDE to maintain the Hardware metadata from the XSA. Users will also learn how the SDT can be manipulated to allow for more flexible use cases within the Vitis Unified IDE.
在这篇简短的博客中,用户将了解系统设备树 (SDT) 以及如何在 Vitis Unified IDE 中使用它来维护来自 XSA 的硬件元数据。用户还将了解如何操作 SDT,以便在 Vitis Unified IDE 中实现更灵活的用例。
What is the XSA and what does it contain
什么是 XSA 以及它包含什么
The XSA is the container file that is generated in Vivado based on the Block Design (BD) used in Vivado IP Integrator.
XSA 是根据 Vivado IP Integrator 中使用的块设计 (BD) 在 Vivado 中生成的容器文件。
This means that only IP that are in the BD will be present in the XSA. If users have IP which is external to the BD, or are using a Chip2Chip solution for example, then the main BD will be used in the XSA creation.
这意味着只有 BD 中的 IP 才会出现在 XSA 中。例如,如果用户拥有 BD 外部的 IP,或者使用 Chip2Chip 解决方案,则主 BD 将用于 XSA 创建。
System Device Tree (SDT)
If users are unaware of the SDT, then we can do a quick recap here. The SDT is a new concept that was introduced into the Vitis Unified IDE in the 2023.2 release.
如果用户不知道 SDT,那么我们可以在这里快速回顾一下。 SDT 是在 2023.2 版本中引入到 Vitis Unified IDE 中的新概念。
The SDT is a collection of .dts/.dtsi files created using the SDTGEN utility, while the Platform Component is generated using the XSA exported from Vivado.
SDT 是使用 SDTGEN 实用程序创建的 .dts/.dtsi 文件的集合,而平台组件是使用从 Vivado 导出的 XSA 生成的。
The System Device Tree (SDT) uses the same concept as the device tree used in the Linux sphere. However, the device tree used in Linux is specific to a target processor and will contain the nodes for the IP on the memory map of the target processor. As the name would suggestion, the System Device Tree is system aware. This means that all of the CPU clusters and each processor address map is present in the System Device Tree. The SDT also contains all of the top level memory nodes. While a Target processor device tree blob (DTB) can be lopped from the SDT, this is not the intent of the SDT used in Vitis. In Vitis, the SDT is purely used to maintain the Hardware metadata.
系统设备树 (SDT) 使用与 Linux 领域中使用的设备树相同的概念。然而,Linux 中使用的设备树特定于目标处理器,并且将包含目标处理器的内存映射上的 IP 节点。顾名思义,系统设备树是系统感知的。这意味着所有 CPU 集群和每个处理器地址映射都存在于系统设备树中。 SDT 还包含所有顶级内存节点。虽然可以从 SDT 中删除目标处理器设备树 blob (DTB),但这并不是 Vitis 中使用的 SDT 的目的。在 Vitis 中,SDT 纯粹用于维护硬件元数据。
How is the SDT used in Vitis?
Vitis 中如何使用 SDT?
Vitis uses the SDT in situations where hardware metadata is needed.
Vitis 在需要硬件元数据的情况下使用 SDT。
Among these are the creation of the xparameters.h file, the dynamically generated driver config file, getting a list of drivers on a target processor, the linker script generation and the BSP creation.
其中包括 xparameters.h 文件的创建、动态生成的驱动程序配置文件、获取目标处理器上的驱动程序列表、链接器脚本生成和 BSP 创建。
These all use the Lopper Python based utility to read the SDT and extract the specific metadata that it needs to execute its task.
这些都使用基于 Python 的 Lopper 实用程序来读取 SDT 并提取执行任务所需的特定元数据。
How can users unlock the potential of the System Device Tree
用户如何释放系统设备树的潜力
As mentioned above, one of the use cases for the Lopper is to return the list of drivers on a target processor. This means that if a user has an IP which is external to the BD, then the SDT will not be automatically populated with this metadata. However, users can manipulate the SDT file-set to include this.
如上所述,Lopper 的用例之一是返回目标处理器上的驱动程序列表。这意味着,如果用户拥有 BD 外部的 IP,则 SDT 将不会自动填充此元数据。但是,用户可以操作 SDT 文件集以包含此内容。
As discussed above, the XSA is only aware of the IP in the Block Design in Vivado IP integrator. This means that if a users is using a development board such as the Versal VCK190 or Zynq UltraScale+ ZCU111, then the board information such as the PHY or the clocks on the I2C bus are lost.
如上所述,XSA 仅了解 Vivado IP 集成器中块设计中的 IP。这意味着,如果用户使用 Versal VCK190 或 Zynq UltraScale+ ZCU111 等开发板,则 PHY 或 I2C 总线上的时钟等板信息将会丢失。
In the System Device Tree, users can make the SDT "board aware" by passing the board .dtsi file that is delivered in the SDTGEN.
在系统设备树中,用户可以通过传递 SDTGEN 中提供的板 .dtsi 文件来使 SDT “板感知”。
Adding External IP to the SDT in the Vitis Unified IDE
在 Vitis Unified IDE 中将外部 IP 添加到 SDT
In Vitis 2024.1, there is an Advanced option while creating the Platform Component that users can use to unlock the potential of the SDT.
在 Vitis 2024.1 中,创建平台组件时有一个高级选项,用户可以使用该选项来释放 SDT 的潜力。
For example, here I have an external IP (axi_gpio) connected to the processor via an external AXI interface connected to the LPD CIPS interface.
例如,这里我有一个外部IP(axi_gpio)通过连接到LPD CIPS接口的外部AXI接口连接到处理器。
I can append this node onto the amba_pl node using a custom DTSI file. Here, I have created the axi_gpio_0 node.
我可以使用自定义 DTSI 文件将此节点附加到 amba_pl 节点上。在这里,我创建了 axi_gpio_0 节点。
I then added this node to the CPU address map.
然后我将此节点添加到 CPU 地址映射中。
/ {
};
&amba_pl {
axi_gpio_0: axi_gpio@80000000 {
compatible = "xlnx,axi-gpio-2.0" , "xlnx,xps-gpio-1.00.a";
xlnx,ip-name = "axi_gpio";
status = "okay";
reg = <0x0 0x80000000 0x0 0x10000>;
xlnx,name = "axi_gpio_0";
};
};
&cpus_a72 {
/delete-property/ address-map;
address-map = <0x0 0xf0000000 &amba 0x0 0xf0000000 0x0 0x10000000>,
<0x0 0xf9000000 &amba_apu 0x0 0xf9000000 0x0 0x80000>,
<0x0 0x00000000 &axi_noc_0_memory 0x0 0x00000000 0x0 0x80000000>,
<0x0 0x80000000 &axi_gpio_0 0x0 0x80000000 0x0 0x10000>,
.....
};
I can then pass this to the SDT as a User DTS file.
然后我可以将其作为用户 DTS 文件传递给 SDT。
Note: The repo is not needed here. Only the DTSI passed as a User DTS file is needed for this use case.
注意:这里不需要 repo。此用例仅需要作为用户 DTS 文件传递的 DTSI。
If I then build (or Regenerate the BSP), I will see the AXI GPIO driver added to the BSP.
如果我随后构建(或重新生成 BSP),我将看到 AXI GPIO 驱动程序添加到 BSP。
Also, as discussed above, if a user is using a development board such as the Versal VCK190, or the Zynq UltraScale+ ZCU102 board, they can simply make the SDT "board aware" by adding the Board DTS to the SDT.
此外,如上所述,如果用户使用 Versal VCK190 或 Zynq UltraScale+ ZCU102 板等开发板,他们只需将板 DTS 添加到 SDT 即可使 SDT “板感知”。
Note: The repo is not needed here. Only the Board DTS file is needed for this use case.
注意:这里不需要 repo。此用例仅需要 Board DTS 文件。
We can see the resulting SDT file-set including the board files below:
我们可以看到生成的 SDT 文件集,包括以下板文件:
Summary
In summary, we have learned what metadata is contained in the XSA file, and how this metadata is extracted and maintained in the Vitis Unified IDE via the System Device Tree.
总之,我们了解了 XSA 文件中包含哪些元数据,以及如何通过系统设备树在 Vitis Unified IDE 中提取和维护这些元数据。
We learned where the Lopper utility is used to extract this metadata when needed. Finally, we discussed how to manipulate the SDT to unlock some use cases such as using external IP and making an SDT "board aware".
我们了解了 Lopper 实用程序用于在需要时提取此元数据的位置。最后,我们讨论了如何操纵 SDT 来解锁一些用例,例如使用外部 IP 并使 SDT “板感知”。