Run Vitis AI Examples on KV260
Angie An

Use board image provided by Xilinx

Quick Start Guide for Zynq™ UltraScale+™

Vitis-AI/setup/mpsoc/README

To improve the user experience, the Vitis AI Runtime packages, VART samples, Vitis-AI-Library samples and models have been built into the board image.

  1. Installing a Board Image.

    Download the SD card system image files from the following links:

    KV260

  2. (Optional) Running zynqmp_dpu_optimize.sh to optimize the board setting.

    image-20240417112324296

  3. Download the vitis_ai_runtime_r2.5.x_image_video.tar.gz to the target.

  4. Unzip the vitis_ai_runtime_r2.5.x_image_video.tar.gz package on the target.

    1
    tar -xzvf vitis_ai_runtime_r*2.5*_image_video.tar.gz -C Vitis-AI/examples/VART
  5. Enter the directory of samples in the target board. Take resnet50 as an example.

    1
    cd ~/Vitis-AI/examples/VART/resnet50
  6. Run the example.

    1
    ./resnet50 /usr/share/vitis_ai_library/models/resnet50/resnet50.xmodel

    image-20240417155914181

    Launching Commands for VART Samples on edge

    No. Example Name Command
    1 resnet50 ./resnet50 /usr/share/vitis_ai_library/models/resnet50/resnet50.xmodel
    2 resnet50_pt ./resnet50_pt /usr/share/vitis_ai_library/models/resnet50_pt/resnet50_pt.xmodel ../images/001.jpg
    3 resnet50_ext ./resnet50_ext /usr/share/vitis_ai_library/models/resnet50/resnet50.xmodel ../images/001.jpg
    4 resnet50_mt_py python3 resnet50.py 1 /usr/share/vitis_ai_library/models/resnet50/resnet50.xmodel
    5 inception_v1_mt_py python3 inception_v1.py 1 /usr/share/vitis_ai_library/models/inception_v1_tf/inception_v1_tf.xmodel
    6 pose_detection ./pose_detection video/pose.webm /usr/share/vitis_ai_library/models/sp_net/sp_net.xmodel /usr/share/vitis_ai_library/models/ssd_pedestrian_pruned_0_97/ssd_pedestrian_pruned_0_97.xmodel
    7 video_analysis ./video_analysis video/structure.webm /usr/share/vitis_ai_library/models/ssd_traffic_pruned_0_9/ssd_traffic_pruned_0_9.xmodel
    8 adas_detection ./adas_detection video/adas.webm /usr/share/vitis_ai_library/models/yolov3_adas_pruned_0_9/yolov3_adas_pruned_0_9.xmodel
    9 segmentation ./segmentation video/traffic.webm /usr/share/vitis_ai_library/models/fpn/fpn.xmodel
    10 squeezenet_pytorch ./squeezenet_pytorch /usr/share/vitis_ai_library/models/squeezenet_pt/squeezenet_pt.xmodel

2022.1 Vitis™ Platform Creation Tutorials

We’ll introduce the platform creation steps in the following pages. Each page describes one major step in the platform creation process.

Let’s start from step 1: Vivado Design.

When i do step2, there were 1 issue.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
xsct% createdts -hw ./kv260_hardware_platform.xsa -zocl -platform-name mydevice -git-branch xlnx_rel_v2022.1 -overlay -compile -out mydevice
INFO: DTG repo already exists at /mnt/hdd8t/anqi/work/kv260_vitis_platform/mydevice/device-tree-xlnx
INFO: [Hsi 55-2053] elapsed time for repository (/tools/Xilinx/Vitis/2023.2/data/embeddedsw) loading 0 seconds
INFO: Creating platform mydevice at mydevice
Opening the hardware design, this may take few seconds.
INFO: Populating the default qemu data for the domain "device_tree_domain" from the install location /tools/Xilinx/Vitis/2023.2/data/emulation/platforms/zynqmp/sw/a53_standalone/qemu/
zocl:true
ext_platform:
Failed to find overlay2 node !!!

ERROR: [Hsi 55-1545] Problem running tcl command ::sw_device_tree::generate : Failed to find overlay2 node !!!
while executing
"error "Failed to find $lu_node node !!!""
(procedure "get_node_object" line 31)
invoked from within
"get_node_object overlay2 pl.dtsi"
invoked from within
"create_dt_node -name zyxclmm_drm -objects [get_node_object overlay2 pl.dtsi]"
("eval" body line 1)
invoked from within
"eval "create_dt_node ${cmd}""
(procedure "add_or_get_dt_node" line 187)
invoked from within
"add_or_get_dt_node -n "zyxclmm_drm" -d ${default_dts} -p $bus_node"
(procedure "gen_zocl_node" line 21)
invoked from within
"gen_zocl_node"
(procedure "::sw_device_tree::generate" line 23)
invoked from within
"::sw_device_tree::generate device_tree"

ERROR: [Hsi 55-1442] Error(s) while running TCL procedure generate()

Could not create platform for device_tree and null
Failed to generate the bsp sources for domain.device_tree_domain

Details: Failed to find overlay2 node !!!

ERROR: [Hsi 55-1545] Problem running tcl command ::sw_device_tree::generate : Failed to find overlay2 node !!!
while executing
"error "Failed to find $lu_node node !!!""
(procedure "get_node_object" line 31)
invoked from within
"get_node_object overlay2 pl.dtsi"
invoked from within
"create_dt_node -name zyxclmm_drm -objects [get_node_object overlay2 pl.dtsi]"
("eval" body line 1)
invoked from within
"eval "create_dt_node ${cmd}""
(procedure "add_or_get_dt_node" line 187)
invoked from within
"add_or_get_dt_node -n "zyxclmm_drm" -d ${default_dts} -p $bus_node"
(procedure "gen_zocl_node" line 21)
invoked from within
"gen_zocl_node"
(procedure "::sw_device_tree::generate" line 23)
invoked from within
"::sw_device_tree::generate device_tree"

ERROR: [Hsi 55-1442] Error(s) while running TCL procedure generate()

I switched to the xlnx_rel_v2022.2 branch then it succeed.

image-20240530170830787

image-20240530181354042

image-20240530183531292

Use petalinux to build a board image

Install Petalinux SDK and BSP

Get PetaLinux Tools - Installer - 2023.2 Full Product Installation from the following links, and install it:

Xilinx Petalinux Downloads

Download Kria K26 SOM Board Support Package from the following link:

Downloads

image-20240417170035187

Build Board Image

Creating a Project Using PetaLinux BSP

Try to create a project from BSP use the following command:

1
petalinux-create -t project --template zynqMP --force -n kv260 -s ../BSPs/xilinx-kv260-starterkit-v2023.2-10140544.bsp

image-20240417171646566

Building the Linux Image With Petalinux Using recipes-vitis-ai

REF: Integrating the DPU - Rebuilding the Linux Image With Petalinu

  1. Copy the recipes-vitis-ai folder to <petalinux project>/project-spec/meta-user/

    1
    cp -r /home/anq/workspace/Vitis-AI/src/vai_petalinux_recipes/recipes-vitis-ai /home/anq/workspace/kv260/kv260/project-spec/meta-user/

    image-20240418172641480

  2. Delete either recipes-vitis-ai/vart/vart_3.5.bb or recipes-vitis-ai/vart/vart_3.5_vivado.bb depending on workflow that you have selected for your design. If you use recipes-vitis-ai/vart/vart_3.5_vivado.bb please rename it recipes-vitis-ai/vart/vart_3.5.bb.

  3. Edit <petalinux project>/project-spec/meta-user/conf/user-rootfsconfig file, appending the following lines:

    1
    2
    3
    CONFIG_vitis-ai-library
    CONFIG_vitis-ai-library-dev
    CONFIG_vitis-ai-library-dbg

    image-20240418172927993

    image-20240418172954404

  4. Source PetaLinux tool and run petalinux-config -c rootfs command. Select the follo wing option. Save and exit.

    1
    2
    3
    4
    5
    6
    Select user packages --->
    Select [*] vitis-ai-library

    Select [Filesystem packages] ---> [libs]
    Select [*] xrt

    image-20240418173057029

    image-20240418173132238

  5. Run petalinux-build.

    When i was building project, there were 2 issues.

    a. 0001-glog-enable-fatal-throw-exception.patch is already applied.

    image-20240424130711333

    As i checked how many times the patch is used, i found 2 results.

    image-20240424131500405

    Therefore, i commented out one of them in glog_0.5.0.bbappend.

    image-20240424131528466

    Then rebuild project, this issue seems to be resolved.

    b. cpio: cannot seek on output: Invalid argument

    1
    2
    | cpio: cannot seek on output: Invalid argument
    | WARNING: exit code 2 from a shell command.

    image-20240424132120109

    I found the solution in the Petalinux manual:

    「do_image_cpio: Function Failed」というエラー メッセージが表示される

    image-20240424132326769

Generate Boot Image

The boot image can be put into Flash or SD card. When you power on the board, it can boot from the boot image. A boot image usually contains a first stage boot loader image, FPGA bitstream, PMU firmware, TF-A, and U-Boot.

Execute the following command to generate the boot image in .BIN format.

1
petalinux-package --boot --u-boot

image-20240424133208907

Booting PetaLinux Image on Hardware with an SD Card

You can boot a PetaLinux image on hardware using an SD card by copying the required images manually.

Copy the following files from <plnx-proj-root>/images/linux or <plnx-proj-root>/pre-built/linux/images/ into the boot directory of the first partition, which is in FAT32 format in the SD card:

  • BOOT.BIN
  • image.ub
  • boot.scr

Set the boot mode of the board to SD boot.

Plug the SD card into the board.

Power on the board.

 Comments