如何在 Vitis Unified IDE 中启用 SDTGEN 挂钩

作者:Stephen MacMahon,AMD工程师;来源:AMD开发者社区

Vitis Unified IDE 使用“System Device Tree (SDT)”(系统设备树)将硬件元数据从 Vivado 传递到 Vitis。SDT 是由名为 SDTGEN 的实用工具在创建“Platform Component”(平台组件)的过程中生成的。

来自 XSCT 的 SDTGEN

SDTGEN 也可通过 XSCT 在命令行上直接运行。

例如:

sdtgen set_dt_param -dir sdt_out -xsa
sdtgen generate_sdt

此外还有其他选项,如:
-repo
board_dts
include_dts

-repo 选项允许您传入定制版本的 SDTGEN。SDTGEN 可从  github 克隆,并且可将相应分支检出。

例如:

git clone https://github.com/Xilinx/system-device-tree-xlnx
git checkout xlnx_rel_v2023.2

在 Vitis IDE 中测试 SDTGEN 之前,您可以(也应该)先在此处对 SDTGEN 中所作的任何修改进行评估。

您可传入 -board_dts 选项和 -include_dts 选项,以便将 DTSI 文件传递到 SDT 的输出目录 (-dir)。这样即可允许这些文件在 SDT 中添加或修改设备树节点。

如果您需要在 device-tree/data 文件夹中修改 device-tree.tcl 文件,那么还需要执行几个额外步骤,因为启动 SDTGEN 时会通过 source 命令来运行 device-tree.tcl。您需要改为使用 source 命令从定制仓库中运行 device-tree.tcl。为此,请执行以下步骤。

1. 将 scripts 文件夹从 Vitis 安装目录复制到本地目录(例如,/tmp/path/)
2. 利用此路径设置 MYVIVADO 环境变量(例如,#export MYVIVADO=/tmp/path/)
3. 将 VITIS_SDT_REPO 环境变量设置为 system-device-tree-xlnx(例如,#export VITIS_SDT_REPO=/tmp/path/system-device-tree-xlnx)

我对 scripts/xsct/sdtgen/sdtgen.tcl 进行了如下更改。

原始版本:
set sdt_path $env(XILINX_VITIS)
source $sdt_path/data/system-device-tree-xlnx/device_tree/data/device_tree.tcl

更新版本:
set sdt_path $env(XILINX_VITIS)
set custom_sdt_path $env(VITIS_SDT_REPO)
if {$custom_sdt_path != ""} {
puts "Info: Detected Custom SDT path at $custom_sdt_path Verifying..."
set valid_tcl [glob -nocomplain -directory ${custom_sdt_path}/device_tree/data -type f device_tree.tcl]
if {$valid_tcl != ""} {
puts "...Success!!"
source $valid_tcl
} else {
puts "...Failed!!. Fallback to install version"
source $sdt_path/data/system-device-tree-xlnx/device_tree/data/device_tree.tcl
}
} else {
source $sdt_path/data/system-device-tree-xlnx/device_tree/data/device_tree.tcl
}

在 Vitis IDE 中使用定制 SDTGEN 仓库

在 Vitis IDE 中有多个挂钩可供您设置用于将 SDTGEN 选项传递给 Vitis。例如,要传入 -repo 选项,请先按如下方式设置“Environment Variable”(环境变量),然后再启动 Vitis:

export VITIS_SDT_REPO=/path/to/system-device-tree

这样在平台中生成 SDT 时,-repo 选项将设为 /path/to/system-device-tree

此外还有其他选项,如:
. VITIS_SDT_BOARD_DTS
. VITIS_SDT_INCLUDE_DTS
. VITIS_SDT_REPO
. VITIS_SDT_EXTRA_CMD

最新文章

最新文章