运行 Tcl 脚本 - 2023.2 简体中文

Vitis 统一软件平台文档 嵌入式软件开发 (UG1400)

Document ID
UG1400
Release Date
2023-12-13
Version
2023.2 简体中文

您可使用 XSCT 命令创建 Tcl 脚本,并以交互模式或非交互模式来运行脚本。在交互模式下,您可以在 XSCT 提示符处使用 source 命令找到脚本。例如:

xsct% source xsct_script.tcl 

在非交互模式下,您可以通过指定脚本作为启动实参来运行该脚本。脚本的实参可遵循脚本名称。例如:

$ xsct xsct_script.tcl [args]

以下脚本提供了 XSCT 的用例。此脚本会创建并构建应用、连接到远程 hw_server、初始化已连接到远程主机的 Zynq PS、在目标上下载并执行应用。这些命令能够通过脚本运行,也可以交互运行。

# Set Vitis workspace
setws /tmp/workspace
# Create application project
app create -name hello -hw /tmp/wrk/system.xsa -proc ps7_cortexa9_0 -os standalone -lang C -template {Hello World}
app build -name hello hw_server
connect -host raptor-host
# Select a target
targets -set -nocase -filter {name =~ “Arm* #0}
# System Reset
rst -system
# PS7 initialization
namespace eval xsdb {source /tmp/workspace/hw1/ps7_init.tcl; ps7_init}
# Download the elf
dow /tmp/workspace/hello/Debug/hello.elf
# Insert a breakpoint @ main
bpadd -addr &main
# Continue execution until the target is suspended
con -block -timeout 500
# Print the target registers
puts [rrd]
# Resume the target
con