Vector addition is the simplest acceleration PL kernel. Vitis Unified IDE can create this application automatically. Running this test can check the AXI control bus, memory interface, and interrupt setting in platform are working properly.
Create a Vector Addition Application.
Go to
WorkSpace
directory created in step1Run Vitis by typing
vitis -w .
in the console.-w
is to specify the workspace..
means the current workspace directory. Close the welcome tab after Vitis launches.Go to example view by clicking the example button and click Simple Vector Addition.
Click Create Application from Template. The project creation wizard would pop up.
Input the System project name as
vadd
and use the default location for System project location. Then click Next.Select kv260_custom platform, click Next.
Note: If the platform component is not in the current workspace user could click + button to add the platform component.
Set Sysroot to
xilinx-zynqmp-common-v2023.2/sysroots/cortexa72-cortexa53-xilinx-linux
. Then click Next.Review the summary of your
vadd
system project and click Finish.
NOTE: In this step, the addition of the kernel image and rootfs is omitted since it is recommended to use the official sd_card.img from AMD’s download center. Furthermore, V++ does not incorporate the kernel image and rootfs in the generation of the sd_card.img for the SOM.
After seconds the vadd system project, vadd host component and vadd kernel component will be ready in the component view.
Building Vector Addition Application
Vadd system project supports three targets: Software emulation, Hardware emulation and Hardware. User could select the target accordingly following steps below. As SOM has different development flow, we will only generate XCLBIN file and host application for hardware.
Navigate to the Flow Navigator, select vadd system project, then expand the LINK-binary_container_1 under HARDWARE target.
Click Build Binary Container
Note: Once the compilation is complete, users can find the
binary_container_1.xclbin
by expanding the Output directory, which offers a structured view of the output. The actual file path ofbinary_container_1.xclbin
is located in theWorkSpace/vadd/build/hw/hw_link/
directory. Additionally, users can access the full path of thebinary_container_1.xclbin
file by hovering the mouse pointer over the image file.
Navigate to the Flow Navigator, select the vadd_host application component, and then click Build under the HARDWARE target..
Note: Once the compilation is complete, users can find the
vadd_host
executable file by expanding the Output directory, which offers a structured view of the output. The actual file path ofvadd_host
is located in theWorkSpace/vadd_host/build/hw/
directory. Additionally, users can access the full path of thevadd_host
file by hovering the mouse pointer over the image file.
Prepare the files to be transferred to the board.
The AMD Kria™ SOM uses
xmutil
to load applications dynamically. The load process includes downloading binary file and loading device tree overlay.xmutil
requires the application files to be stored in/lib/firmware/xilinx
directory.The files related to this application need to have specified extensions. They are
dtbo
,bin
, andjson
. Therefore, the final content in the directory on the board would look like the following.# On target board ls /lib/firmware/xilinx/vadd pl.dtbo #DTB overlay file binary_container_1.bin #Acceleration binary container for XRT configuration. Also includes system.bit and metadata that describes the kernels. shell.json #Description file
The
dtbo
file is prepared in step 2 in thedtg_output
folder.Binary_container_1.bin
can be renamed frombinary_container_1.xclbin
. Forshell.json
, you can copy it from other applications or create one with the following contents.{ "shell_type" : "XRT_FLAT", "num_slots": "1" }
Transfer the files to the board.
Make sure the Ethernet cable of SOM Starter Kit is connected. Use SCP or SFTP to upload the files from host to target board.
# Running on host machine scp pl.dtbo binary_container_1.bin shell.json vadd_host petalinux@<SOM Starter Kit IP>:/home/petalinux
Load the hardware.
# Running on target board sudo mkdir /lib/firmware/xilinx/vadd cd /home/petalinux cp pl.dtbo binary_container_1.bin shell.json /lib/firmware/xilinx/vadd sudo xmutil listapps sudo xmutil unloadapp sudo xmutil loadapp vadd
If the application required files are loaded successfully, the following log is expected:
Nov 8 06:20:28 xilinx-kv260-starterkit-20232 kernel: OF: overlay: WARNING: memory leak will occur if overlay removed, property: /fpga-full/firmware-name Nov 8 06:20:28 xilinx-kv260-starterkit-20232 kernel: OF: overlay: WARNING: memory leak will occur if overlay removed, property: /fpga-full/pid Nov 8 06:20:28 xilinx-kv260-starterkit-20232 kernel: OF: overlay: WARNING: memory leak will occur if overlay removed, property: /fpga-full/resets Nov 8 06:20:28 xilinx-kv260-starterkit-20232 kernel: OF: overlay: WARNING: memory leak will occur if overlay removed, property: /fpga-full/uid Nov 8 06:20:28 xilinx-kv260-starterkit-20232 kernel: OF: overlay: WARNING: memory leak will occur if overlay removed, property: /__symbols__/afi0 Nov 8 06:20:28 xilinx-kv260-starterkit-20232 kernel: OF: overlay: WARNING: memory leak will occur if overlay removed, property: /__symbols__/clocking0 Nov 8 06:20:28 xilinx-kv260-starterkit-20232 kernel: OF: overlay: WARNING: memory leak will occur if overlay removed, property: /__symbols__/clocking1 Nov 8 06:20:28 xilinx-kv260-starterkit-20232 kernel: OF: overlay: WARNING: memory leak will occur if overlay removed, property: /__symbols__/axi_intc_0 Nov 8 06:20:28 xilinx-kv260-starterkit-20232 kernel: OF: overlay: WARNING: memory leak will occur if overlay removed, property: /__symbols__/misc_clk_0 Nov 8 06:20:28 xilinx-kv260-starterkit-20232 kernel: irq-xilinx: mismatch in kind-of-intr param Nov 8 06:20:28 xilinx-kv260-starterkit-20232 kernel: zocl-drm axi:zyxclmm_drm: error -ENXIO: IRQ index 32 not found vadd: loaded to slot 0
Running vector addition application on the board.
Run vadd application.
chmod +x ./vadd_host ./vadd_host binary_container_1.bin
It should show program prints.
xilinx-k26-starterkit-20232:~$ ./vadd_host binary_container_1.bin INFO: Reading binary_container_1.bin Loading: 'binary_container_1.bin' TEST PASSED
NOTE: If you get errors like “error while loading shared libraries: libxilinxopencl.so.2: cannot open shared object file: No such file or directory”, it is because XRT is not installed in KV260 default rootfs. Run
sudo dnf install xrt
to install XRT.