简介
当前项目需要同时调试两个ZCU102开发板,当两个板子都上电连接时,需要分别对两个板子下载不同的.bit和.elf,直接用vitis常规方法下载会报错。
网上在这方面的资料不多,我自己折腾了很久,现在把解决方法记录一下,供大家参考。
参考
https://docs.amd.com/v/u/en-US/ug1208-xsct-reference-guide
https://www.origin.xilinx.com/htmldocs/xilinx2019_1/SDK_Doc/SDK_tasks/sdk_t_debugconfig_multicable.html
系统环境
Windows
Vitis2021.2
开发板:Xilinx ZCU102(ZYNQ Ultrascale+ MPSoC)
实现需求
当两个ZYNQ开发板都上电并JTAG连接到同一台电脑,若使用Vitis常规下载方法会因为两个器件冲突而报错:
比较笨的方法是:先对一个开发板下载程序后,拔出它的JTAG,再连上另一个开发板的JTAG,然后下载…… 但是要知道JTAG是不支持热插拔的,这样操作有损坏芯片的风险,所以这方法不靠谱!
折腾了好几天,总结一下,目前大致有以下两个解决方法:
- 在XSCT终端通过命令行下载
- 在Vitis GUI界面下载
解决方法1:在XSCT终端通过命令行下载
这个方法在网上的资料比较多,Xilinx提供的XSCT(Xilinx Software Command Line Tool)命令行工具,可以通过命令选择不同的器件,因此可以指定器件进行下载。
(很遗憾的是,我使用这个方法下载完程序后并没有成功跑起来,目前不知道问题出在哪,若有懂的大佬,也欢迎指教指教!)
先把方法记录一下:
看了很多这方面的资料,主要参考UG1208手册的Debugging Applications on Zynq UltraScale+ MPSoC章节,总结完整的下载指令如下:
connect
targets
#选择"PSU"对应的ID
targets 4
#进入workspace
cd F:/FPGA/PolarCode/fpga/board_enc/zcu102/vitis/polar_enc_tcp/
fpga polar_enc_tcp_platform/hw/polar_enc_tcp.bit
source polar_enc_tcp_platform/hw/psu_init.tcl
psu_init
after 1000
psu_ps_pl_isolation_removal
after 1000
psu_ps_pl_reset_config
#选择APU中"Cortex-A53 #0"对应的ID
targets 9
rst -processor
dow polar_enc_tcp_platform/export/polar_enc_tcp_platform/sw/polar_enc_tcp_platform/boot/fsbl.elf
dow polar_enc_tcp_multi/Debug/polar_enc_tcp_multi.elf
bpadd -addr &main
con
附上我的XSCT终端的完整运行log:
xsct% XSDB Server URL: TCP:localhost:60078
xsct% XSDB Server Channel: tcfchan#0
INFO: [Hsi 55-2053] elapsed time for repository (D:/Xilinx/Vitis/2021.2/data/embeddedsw) loading 4 seconds
connect
tcfchan#1
xsct% targets
1 PS TAP
2 PMU
3 PL
4 PSU
5 RPU (Reset)
6 Cortex-R5 #0 (RPU Reset)
7 Cortex-R5 #1 (RPU Reset)
8 APU (L2 Cache Reset)
9 Cortex-A53 #0 (APU Reset)
10 Cortex-A53 #1 (APU Reset)
11 Cortex-A53 #2 (APU Reset)
12 Cortex-A53 #3 (APU Reset)
xsct% targets 4
xsct% cd F:/FPGA/PolarCode/fpga/board_enc/zcu102/vitis/polar_enc_tcp
xsct% fpga polar_enc_tcp_platform/hw/polar_enc_tcp.bit
initializing
0% 0MB 0.0MB/s ??:?? ETA
4% 1MB 2.2MB/s ??:?? ETA
7% 1MB 1.9MB/s ??:?? ETA
10% 2MB 1.8MB/s ??:?? ETA
14% 3MB 1.8MB/s ??:?? ETA
17% 4MB 1.7MB/s ??:?? ETA
21% 5MB 1.7MB/s 00:11 ETA
25% 6MB 1.7MB/s 00:10 ETA
28% 7MB 1.7MB/s 00:10 ETA
32% 8MB 1.7MB/s 00:09 ETA
35% 8MB 1.7MB/s 00:09 ETA
38% 9MB 1.7MB/s 00:08 ETA
42% 10MB 1.7MB/s 00:08 ETA
46% 11MB 1.7MB/s 00:08 ETA
49% 12MB 1.7MB/s 00:07 ETA
52% 13MB 1.7MB/s 00:07 ETA
56% 14MB 1.7MB/s 00:06 ETA
59% 15MB 1.7MB/s 00:05 ETA
63% 16MB 1.7MB/s 00:05 ETA
66% 16MB 1.7MB/s 00:04 ETA
70% 17MB 1.7MB/s 00:04 ETA
73% 18MB 1.7MB/s 00:03 ETA
77% 19MB 1.7MB/s 00:03 ETA
81% 20MB 1.7MB/s 00:02 ETA
84% 21MB 1.7MB/s 00:02 ETA
88% 22MB 1.7MB/s 00:01 ETA
91% 23MB 1.7MB/s 00:01 ETA
95% 24MB 1.7MB/s 00:00 ETA
98% 25MB 1.7MB/s 00:00 ETA
100% 25MB 1.7MB/s 00:14
xsct% source polar_enc_tcp_platform/hw/psu_init.tcl
xsct% psu_init
xsct% after 1000
xsct% psu_ps_pl_isolation_removal
xsct% after 1000
xsct% psu_ps_pl_reset_config
xsct% targets
1 PS TAP
2 PMU
3 PL
4* PSU
5 RPU (Reset)
6 Cortex-R5 #0 (RPU Reset)
7 Cortex-R5 #1 (RPU Reset)
8 APU (L2 Cache Reset)
9 Cortex-A53 #0 (APU Reset)
10 Cortex-A53 #1 (APU Reset)
11 Cortex-A53 #2 (APU Reset)
12 Cortex-A53 #3 (APU Reset)
xsct% targets 9
xsct% rst -processor
WARNING: If the reset is being triggered after powering on the device,
write bootloop at reset vector address (0xffff0000), or use
-clear-registers option, to avoid unpredictable behavior.
Further warnings will be suppressed
Info: Cortex-A53 #0 (target 9) Stopped at 0xffff0000 (Reset Catch)
xsct% dow polar_enc_tcp_platform/export/polar_enc_tcp_platform/sw/polar_enc_tcp_platform/boot/fsbl.elf
Downloading Program -- F:/FPGA/PolarCode/fpga/board_enc/zcu102/vitis/polar_enc_tcp/polar_enc_tcp_platform/export/polar_enc_tcp_platform/sw/polar_enc_tcp_platform/boot/fsbl.elf
section, .text: 0xfffc0000 - 0xfffd5f13
section, .note.gnu.build-id: 0xfffd5f14 - 0xfffd5f37
section, .init: 0xfffd5f40 - 0xfffd5f73
section, .fini: 0xfffd5f80 - 0xfffd5fb3
section, .rodata: 0xfffd5fc0 - 0xfffd653f
section, .sys_cfg_data: 0xfffd6540 - 0xfffd6d2f
section, .mmu_tbl0: 0xfffd7000 - 0xfffd700f
section, .mmu_tbl1: 0xfffd8000 - 0xfffd9fff
section, .mmu_tbl2: 0xfffda000 - 0xfffddfff
section, .data: 0xfffde000 - 0xfffdf257
section, .sbss: 0xfffdf258 - 0xfffdf27f
section, .bss: 0xfffdf280 - 0xfffe183f
section, .heap: 0xfffe1840 - 0xfffe1c3f
section, .stack: 0xfffe1c40 - 0xfffe3c3f
section, .dup_data: 0xfffe3c40 - 0xfffe4e97
section, .handoff_params: 0xfffe9e00 - 0xfffe9e87
section, .bitstream_buffer: 0xffff0040 - 0xfffffc3f
0% 0MB 0.0MB/s ??:?? ETA
77% 0MB 0.1MB/s ??:?? ETA
100% 0MB 0.2MB/s 00:00
Setting PC to Program Start Address 0xfffc0000
Successfully downloaded F:/FPGA/PolarCode/fpga/board_enc/zcu102/vitis/polar_enc_tcp/polar_enc_tcp_platform/export/polar_enc_tcp_platform/sw/polar_enc_tcp_platform/boot/fsbl.elf
xsct% dow polar_enc_tcp_multi/Debug/polar_enc_tcp_multi.elf
Downloading Program -- F:/FPGA/PolarCode/fpga/board_enc/zcu102/vitis/polar_enc_tcp/polar_enc_tcp_multi/Debug/polar_enc_tcp_multi.elf
section, .text: 0x00000000 - 0x0001e377
section, .init: 0x0001e380 - 0x0001e3b3
section, .fini: 0x0001e3c0 - 0x0001e3f3
section, .rodata: 0x0001e3f8 - 0x0001f9b6
section, .rodata1: 0x0001f9b7 - 0x0001f9bf
section, .sdata2: 0x0001f9c0 - 0x0001f9bf
section, .sbss2: 0x0001f9c0 - 0x0001f9bf
section, .data: 0x0001f9c0 - 0x000305f7
section, .data1: 0x000305f8 - 0x000305ff
section, .note.gnu.build-id: 0x00030600 - 0x00030623
section, .ctors: 0x00030624 - 0x0003063f
section, .dtors: 0x00030640 - 0x0003063f
section, .eh_frame: 0x00030640 - 0x00030643
section, .mmu_tbl0: 0x00031000 - 0x0003100f
section, .mmu_tbl1: 0x00032000 - 0x00033fff
section, .mmu_tbl2: 0x00034000 - 0x00037fff
section, .preinit_array: 0x00038000 - 0x00037fff
section, .init_array: 0x00038000 - 0x00038007
section, .fini_array: 0x00038008 - 0x00038047
section, .sdata: 0x00038048 - 0x0003807f
section, .sbss: 0x00038080 - 0x0003807f
section, .tdata: 0x00038080 - 0x0003807f
section, .tbss: 0x00038080 - 0x0003807f
section, .bss: 0x00200000 - 0x0241807f
section, .heap: 0x02418080 - 0x0241a07f
section, .stack: 0x0241a080 - 0x0241d07f
0% 0MB 0.0MB/s ??:?? ETA
28% 0MB 0.1MB/s ??:?? ETA
85% 0MB 0.2MB/s ??:?? ETA
100% 0MB 0.2MB/s 00:01
Setting PC to Program Start Address 0x00000000
Successfully downloaded F:/FPGA/PolarCode/fpga/board_enc/zcu102/vitis/polar_enc_tcp/polar_enc_tcp_multi/Debug/polar_enc_tcp_multi.elf
xsct% bpadd -addr &main
0
xsct% Info: Breakpoint 0 status:
target 9: {Address: 0x1970 Type: Hardware}
xsct% con
Info: Cortex-A53 #0 (target 9) Running
xsct% rrd
r0: N/A r1: N/A
r2: N/A r3: N/A
r4: N/A r5: N/A
r6: N/A r7: N/A
r8: N/A r9: N/A
r10: N/A r11: N/A
r12: N/A r13: N/A
r14: N/A r15: N/A
r16: N/A r17: N/A
r18: N/A r19: N/A
r20: N/A r21: N/A
r22: N/A r23: N/A
r24: N/A r25: N/A
r26: N/A r27: N/A
r28: N/A r29: N/A
r30: N/A sp: N/A
pc: 0000000000000200 cpsr: N/A
vfp sys
dbg acpu_gic
xsct%
指令运行一切正常,程序也烧进去了,但串口没有打印任何信息,读取到的寄存器值也是N/A,看起来程序没有正确跑起来,后面如果解决的话再更新吧!
解决方法2:在Vitis GUI界面下载
这个方法特别简单,是偶然间翻到Xilinx古老的SDK使用教程时发现的,就是在Run Configuration界面手动指定下载的目标PS器件和PL器件。
具体流程如下:
在Target Setup中,看到PL Device和PS Device这两项默认是Auto Detect,将两个都改为手动指定器件即可:
对开发板A,分别选择PL Device和PS Device,然后点击“Run”,下载程序
同理,对开发板B,分别选择PL Device和PS Device,然后点击“Run”下载程序
通过以上步骤,便可以成功给开发板A和开发板B下载不同的程序,并正确运行。
问题解决!