In this tutorial a Vivado platform was created for the KR260 board using Vivado 24.2 release. Here we will continue creating an accelerated example application with Vitis that will run on the board.
Get Zynq MPSoC common imageThe MPSoC common image (r24.2) can be downloaded from here, registration with AMD is needed.
With the tar file in ~/workspace, I extract it with
tar -xzvf xilinx-zynqmp-common-v2024.2_11110212.tar.gz
That creates a folder xilinx-zynqmp-common-v2024.2
We need to create the sysroot with:
cd xilinx-zynqmp-common-v2024.2/
./sdk.sh -d .
That will create the sysroots folder we will later use.
Create software platformStart Vitis Unified IDE either with the desktop icon or on the terminal. My workspace is on ~/workspace/vitis.
Click on Create Platform Component
I change the name to kr260_pfm
Click Next, leave the Hardware Design option and click on Browse to look for the XSA generated with Vivado. Under Advanced Options, tick the DT ZOCL option.
Next select Linux as the operating system, leave the Generate Boot Artifacts box ticked and also tick the DT Overlay box, then click Next and Finish
After that, the sw platform is created
Now select the linux_psu_cortexa53 on the configuration and:
On the BIF file line, click on the Generate Bif button (on the right)
On the Pre-built Image Directory, browse to the ~/workspace/xilinx-zynqmp-common-v2024.2 extracted before
Rest of lines can be left empty or as default
On the Flow tab below, click the build icon with the platform selected
The platform should build without problems
Click on New Example
And select Simple Vector Addition
Then click on Create System Project from Template
I change the name to app_test_vadd
Next the generated platform is selected
And the component paths updated, for the rootfs browse to ~/workspace/xilinx-zynqmp-common-v2024.2/rootfs.tar.gz and for the sysroot, ~/workspace/xilinx-zynqmp-common-v2024.2/sysroots/cortexa72-cortexa53-xilinx-linux/
This creates a series of components, the system, the application and the kernel
On the Flow panel, select the system component and under LINK, click Build Binary container
When it finishes after some minutes, the xclbin file is created
This is one of the files needed to be run on the board. The other two are the dtbo (device tree blob object) and a trivial json file.
The dtbo has to be compiled with the DTG (device tree generator) as explained below.
In the workspace folder, create a file named shell.json. You can use any other text editor instead of gedit.
gedit shell.json
And copy or paste the following:
{
"shell_type" : "XRT_FLAT",
"num_slots": "1"
}
Save and close gedit.
Compiling the device treeFirst, in the workspace folder, clone the xinlinx device tree repo:
git clone https://github.com/Xilinx/device-tree-xlnx
Create a folder for these operations and move the hardware XSA file into it:
mkdir dtg_work
cd dtg_work
cp ~/workspace/vivado/kr260_pfm/KR260_PFM.xsa ./
Start XSCT:
xsct
And run the following commands:
hsi open_hw_design KR260_PFM.xsa
hsi set_repo_path /home/joan/workspace/device-tree-xlnx/
hsi create_sw_design device-tree -os device_tree -proc psu_cortexa53_0
hsi set_property CONFIG.dt_overlay true [hsi::get_os]
hsi set_property CONFIG.dt_zocl true [hsi get_os]
hsi generate_target -dir ./output
hsi close_hw_design design_1_wrapper
exit
Note that the design name at the end is that from the output after open_hw_design. It can also be obtained by issuing hsi current_hw_design.
Cd to the output folder and run the dtc on the pl.dtsi file there
cd output
dtc -@ -O dtb -o pl.dtbo pl.dtsi
Copy files to the KR260 boardBoot the KR260 board with a serial console connected to it, then log in with th username (ubuntu) and the password (that you had to change)
The three file (xclbin, dtbo and json) are copied with scp. The KR260 IP address is needed (your may be different) and you can obtain it with the ifconfig command:
So I copy the files to the KR260 home folder with following lines on the linux PC (folder changes not shown)
scp pl.dtbo ubuntu@192.168.1.151:/home/ubuntu
scp binary_container_1.xclbin ubuntu@192.168.1.151:/home/ubuntu
scp shell.json ubuntu@192.168.1.151:/home/ubuntu
After that, going back to the Kria board, the files should be there:
Two things are needdeed with xclbin file: one is to change the extension into bin and make it executable:
mv binary_container_1.xclbin binary_container_1.bin
sudo chmod +x binary_container_1.bin
Create a folder for the application under /lib/firmware/xilinx and copy these three files there
sudo mkdir /lib/firmware/xilinx/app_test_vadd
sudo cp pl.dtbo binary_container_1.xclbin shell.json /lib/firmware/xilinx/app_test_vadd/
Run the applicationList the loaded applications with xmutil listapps and unload the default application:
Load the test application:
Comments
Please log in or sign up to comment.