cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Creating an Acceleration Platform for Vitis Part Two: Creating the software project for the Acceleration Platform in PetaLinux

Moderator
Moderator
1 0 558

This is the second blog entry in the Acceleration Platform series. Previously, we discussed how to create the hardware and how to pass the metadata to Vitis™ via the XSA.

In this entry we will discuss how to use this XSA and create the software images needed to accelerate your design on your target platform.

You can find the other entries at the links below:

Part One: Creating the hardware project for the Acceleration Platform in Vivado

Part Three: Packaging the Accelerated Platform in Vitis 

Part Four: Testing the Custom Acceleration Platform in Vitis 

Introduction:

Users familiar with OpenCL might be aware of the term "kernel", where a function executing in OpenCL is called a "kernel".

The same nomenclature is used in the Vitis acceleration flows. However, the Xilinx Runtime (XRT) API is used to execute the kernels.

The XRT is Linux based, and will run on the x86, or on the development boards (aarch64 or arm). The XRT is functionality independent from the architecture it is executing on, meaning it does not know if it is executing on an x86 or a development board (aarch64, or arm).

However, for the edge (aarch64, or arm) platforms we need to add the ZOCL driver. The ZOCL driver is used to allocate resources for each kernel. In this blog we will discuss how to add the XRT and ZOCL to a new or existing PetaLinux project.

Adding the XRT to the PetaLinux Project:

petalinux-create -t project --template zynqMP -n zcu104_base_sw
cd zcu104_base_sw
petalinux-config --get-hw-description=<path to XSA>
Select DTG Settings -> (zcu104-revc) MACHINE_NAME

Open the project-spec/meta-user/conf/user-rootfsconfig, and add the following:

CONFIG_xrt
CONFIG_xrt-dev
CONFIG_zocl
CONFIG_opencl-clhpp-dev
CONFIG_opencl-headers-dev
CONFIG_packagegroup-petalinux-opencv
petalinux-config -c rootfs
User Packages, and select all here

Now add the zocl driver node to the system-user.dtsi.

/include/ "system-conf.dtsi"
/{
};

&axi_intc_0 {
	xlnx,kind-of-intr = <0x0>;
	xlnx,num-intr-inputs = <0x20>;
};


&amba {	
	zyxclmm_drm {
		compatible = "xlnx,zocl";
		status = "okay";
		interrupt-parent = <&axi_intc_0>;
		interrupts = <0  4>, <1  4>, <2  4>, <3  4>,
			     <4  4>, <5  4>, <6  4>, <7  4>,
			     <8  4>, <9  4>, <10 4>, <11 4>,
			     <12 4>, <13 4>, <14 4>, <15 4>,
			     <16 4>, <17 4>, <18 4>, <19 4>,
			     <20 4>, <21 4>, <22 4>, <23 4>,
			     <24 4>, <25 4>, <26 4>, <27 4>,
			     <28 4>, <29 4>, <30 4>, <31 4>;
	};
};

Then run the following commands:

petalinux-build
cd images/linux
petalinux-build --sdk
petalinux-package --sysroot

Sanity Check:

Before we package our platform it is worth doing a sanity check to make sure that the XRT is added to the rootfs, and that the ZOCL has also been added.

We can do this by booting the Linux image on our board:

cd images/linux
petalinux-package --boot --fpga --u-boot

Place the following files onto the boot device, and then boot

  • image.ub
  • BOOT.BIN
  • boot.scr
Verify the XRT library:

Do a grep on the XRT lib in the /usr/lib directory:

ls /usr/lib | grep libxrt_core

xrt_core.PNG

 
 

Repeat for libxilinxopencl:

ls /usr/lib | grep libxilinxopencl

ocl.PNG

Verify the ZOCL DT node:

List all of the nodes under amba

ls /sys/devices/platform/amba

stephenm_2-1597657313581.png

And that's it.

We now have a Linux image with XRT support enabled for our development board. We have also generated the sysroot that is needed in Vitis for cross compilation.

If you plan on a series of custom platforms for the same architecture, then you only need to create the one sysroot per version (for example, 2020.1).

For the next steps, see part three of this series: Packaging the Accelerated Platform in Vitis