Versal - ChipScoPy + XSDB + Python CLI

目录

1. 简介

1.1 ChipScoPy

1.2 XSDB

1.3 Python CLI

2. 安装 ChipScoPy

2.1 Python 环境

2.2 设置虚拟环境

2.3 安装 ChipScoPy

2.4 安装依赖

2.5 安装示例

2.6 打开 JupyterLab

2.7 启动 hw/cs 服务

2.8 更新 ChipScoPy

2.9 参考资料

3. ChipScoPy 示例

3.1 Programming

3.2 Memory 读写

3.2.1 通用内容

3.2.2 清空设备

3.2.3 简单读写示例

3.2.4 指定字大小

3.2.5 在循环中读写

4. XSDB 示例

4.1 Basic

4.1.1 参考资料

4.1.2 进入 XSDB

 4.1.3 帮助信息

4.1.4 基本操作

4.2 控制 AXI GPIO

4.2.1 Bock Desgin

4.2.2 Address Editor

4.2.3 操作寄存器

4.2.4 报错提示

5. Python CLI

5.1 参考资料

5.2 基本命令

5.2.1 启动方式

5.2.2 导入 xsdb 包

5.2.3 建立对话和连接

5.2.4 选择 target

5.2.5 下载 PDI

5.2.6 设置存储器映射

5.2.7 Momory 读写

5.3 控制 AXI GPIO

5.3.1 Block Design

5.3.2 主要代码

6. 总结


1. 简介

1.1 ChipScoPy

Target Communication Framework 

ChipScoPy 是一个开源 Python 项目,用于与 Xilinx Versal 硬件调试解决方案进行通信和控制。客户端 Python 脚本可以访问丰富的硬件交互 API。ChipScoPy 包的主要功能包括:

  •   Device detection, programming, and status
  • Memory subsystems support
  • Fabric Debug Core support
    •  Integrated Logic Analyzer (ILA)
    • Virtual Input Output (VIO) 
  • Hardened Core support
    •  DDR Memory Controller (DDRMC)
    • Integrated Bit Error Ratio Tester (IBERT)
    • System Monitor (SysMon)
    • Network on Chip Performance Monitor (NoC PerfMon)
    • PCI Express (PCIe)  

1.2 XSDB

XSDB(Xilinx System Debugger,系统调试器)使用 HW Server 作为底层调试引擎,提供了一种通过 JTAG 接口与 Xilinx 硬件系统进行交互的命令行调试工具。可以将用户界面操作转换为一系列目标通信框架 (TCF) 命令。

关于 XSCT:

XSCT (Xilinx Software Command-Line Tool) 是一个更高级的命令行工具,它包含了 XSDB 的所有功能,并且还提供了一些额外的功能,例如工程管理、构建和下载等。

如果在 bash 中启动 xsct,会出现如下提示:

Warning: XSCT is deprecated and will be removed in future releases.

We recommend using the new Python command-line tool for project management and debugging:
- Run "vitis -i" for interactive mode.
- Run "vitis -s <script>" for script mode.

XSCT 已经被标记为 “deprecated”(不推荐使用),并且在未来的版本中会被移除。

1.3 Python CLI

Python CLI 实际上指的是在新的 Vitis 命令行工具中使用 Python 脚本来执行以前通过 XSCT 和 XSDB 完成的调试任务。由于 XSCT 正在被弃用,Xilinx 转向了基于 Python 的方法。

核心概念:

  • Vitis 命令行工具: 这是取代 XSCT 的新工具,使用 vitis 命令启动。
  • Python API: Vitis 命令行工具基于 Python API 构建,也就是需要使用 Python 语法来编写脚本,而不是之前的 Tcl。
  • xsdb 模块: 在 Vitis Python API 中,有一个 xsdb 模块,它提供了与 XSDB 功能相对应的 Python 函数。这个模块让你能够通过 Python 脚本执行各种调试操作。

2. 安装 ChipScoPy

2.1 Python 环境

官方建议使用的版本 Python 3.8、3.9、3.10、3.11、3.12。

有多种方法可以配置使用 ChipScoPy API。

本文分享使用 conda 来管理虚拟环境,并使用ChipScPy。

conda 安装方法见此博文:Vivado 编译(单核性能对比+高性能迷你主机+Ubuntu20.04/22.04安装与区别+20.04使用远程命令)_ubuntu vivado-优快云博客文章浏览阅读834次,点赞11次,收藏28次。选购一款专用于 Vitis 和 Vivado 开发的主机,Vivado 的编译速度很大程度上取决于 CPU 的单核性能,尤其是在布线和综合阶段,最终选择一款迷你主机,不考虑使用独显,核性数一般即可。按照 Single Thread Performance 对比即可,挑选一款最佳性价比产品。对比 Ubuntu 22.04 和 Ubuntu 20.04 运行 Vivado 的兼容性。_ubuntu vivadohttps://blog.youkuaiyun.com/DongDong314/article/details/144565249https://blog.youkuaiyun.com/DongDong314/article/details/144565249https://blog.youkuaiyun.com/DongDong314/article/details/144565249

启用 conda:

>> cd /opt/anaconda3/bin/
>> ./conda init bash

(base)>> conda --version # 确认已启用conda,并查看conda版本
(base)>> python --version # 查看python版本

区分,在 conda 与 shell 中查看 python 版本并不一致:

>> python3 --version

2.2 设置虚拟环境

1)创建 scopy 虚拟环境:

conda deactivate # 激活 base 环境(如果需要)

conda create -n scopy python=3.12.7 # 创建虚拟环境 scopy

conda activate scopy # 激活虚拟环境 scopy

创建虚拟环境 scopy 时,需要指定 python 版本(当前conda的base环境python=3.12.7),不指定的话,conda 会直接使用最新版本(下载新的python=3.13.1)。

2)查看所有已创建的虚拟环境

conda env list
conda info --envs

conda create -n new_env --clone old_env # 克隆旧环境

2)删除 scopy 虚拟环境,并清除与其关联的所有包:

conda remove --name scopy --all

2.3 安装 ChipScoPy

1)激活 scopy 虚拟环境

(base)>> conda activate scopy
---
(scopy)>>

2)安装 ChipScoPy 包

由于 conda 仓库中并没有 ChipScoPy 包,需要使用 python pip 来安装

(scopy)>> python -m pip install --upgrade pip # 更新 pip

(scopy)>> python -m pip install 'chipscopy==2024.2.*' # 安装指定版本的chipscopy

---
Successfully installed Click-8.1.8 antlr4-python3-runtime-4.13.1 certifi-2024.12.14 charset-normalizer-3.4.1 chipscopy-2024.2.1733027508 idna-3.10 importlib_metadata-6.11.0 loguru-0.7.3 markdown-it-py-3.0.0 mdurl-0.1.2 more-itertools-10.5.0 pygments-2.19.1 requests-2.32.3 rich-13.9.4 typing_extensions-4.12.2 urllib3-2.3.0 zipp-3.21.0

2.4 安装依赖

运行以下命令来安装附加支持包:

(scopy)>> python -m pip install chipscopy[core-addons]
(scopy)>> python -m pip install chipscopy[jupyter]

有如下报错:

  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [6 lines of output]

      Cargo, the Rust package manager, is not installed or is not on PATH.
      This package requires Rust and Cargo to compile extensions. Install it through
      the system's package manager or via https://rustup.rs/

      Checking for Rust toolchain....
      [end of output]

解决办法,安装 rust: 

(scopy)>> curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

直接按 Enter 键接受默认选项即可。

(scopy)>> source ~/.cargo/env

验证 Rust 和 Cargo 是否安装成功:

(scopy)>> rustc --version
(scopy)>> cargo --version

然后再次执行安装:

(scopy)>> python -m pip install chipscopy[jupyter]

2.5 安装示例

有一个脚本可将示例安装到用户选择的特定目录中。

(scopy)>> chipscopy-get-examples
---
 chipscopy-get-examples
No examples available locally, they will be downloaded from Github.
Do you want to proceed? [Y/n] y
Downloading examples from https://github.com/Xilinx/chi
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值