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

MicroZed Chronicles: Vitis SW Platform

tech-blogs
Xilinx Employee
Xilinx Employee
0 3 1,668

Editor’s Note: This content is republished from the MicroZed Chronicles, with permission from the author and Hackster.io.

 

How to create the software element of the Ultra96 V2 Vitis acceleration platform

325_Fig1.jpg

Last week, we started looking at platform creation for Vitis so we can accelerate algorithms from the processing system to programmable logic.

Creating a platform requires two elements: the hardware element we created last week and a software element we are going to create now.

To get started with the software element, we first need to have PetaLinux 2019.2 installed on our Linux system.

Before we can install PetaLinux, we need to ensure we have necessary prerequisites. For the VM we created a few weeks ago, we can install them using the command:

sudo apt-get install -y gcc git make net-tools libncurses5-dev tftpd zlib1g-dev libssl-dev flex bison libselinux1 gnupg wget diffstat chrpath socat xterm autoconf libtool tar unzip texinfo zlib1g-dev gcc-multilib build-essential libsdl1.2-dev libglib2.0-dev zlib1g:i386 screen pax gzip gawk

Once the required packages have been installed, we can download and install PetaLinux.

 

Installing PetaLinuxInstalling PetaLinuxCompletion of installationCompletion of installation

With PetaLinux available under the directory, we created for the platform previously we need to create three new directories PFM, WKSP1 and BOOT.

cd ultra96_min_pkg
mkdir pfm
cd pfm
mkdir wksp1
mkdir boot
cd ..

In the same terminal window, we need to source the following files:

  • <Vitis Install path>/settings64.sh
  • <PetaLinux Install path>/settings.sh

We are now ready to create the PetaLinux project. Make sure the project name is the same as the hardware in this case ultra96_min.

Creating the new PetaLinux projectCreating the new PetaLinux project

petalinux-create -t project --template zynqMP -n ultra96_min

We then need to configure the new project for the hardware design using the command:

cd ultra96_min
petalinux-config --get-hw-description=../vivado

This will open a configuration dialog, set the boot file system to EXT and stdin/stdout to pus_uart_1.

Configuring the hardwareConfiguring the hardware

Setting the external file systemSetting the external file system
Setting stdin / stdoutSetting stdin / stdout

Once this is completed, save the changes and exit the dialog.

We need to make some changes to the meta-user Yocto layer, under the directory:

<project>/project-spec/meta-user open the conf file and add in the required OpenCL requirements.

CONFIG_xrt
CONFIG_xrt-dev
CONFIG_zocl
CONFIG_opencl-clhpp-dev
CONFIG_opencl-headers-dev
CONFIG_packagegroup-petalinux-opencv

Editing the conf fileEditing the conf file

We also need to make changes to the user device tree, under:

<project>/project-spec/recipes-bsp/device-tree/files

Edit the file system-user.dsti and add in the following:

&amba {
               zyxclmm_drm {
                              compatible = “xlnx,zocl”;
                              status = “okay”;
               };
 };

Updating the device treeUpdating the device tree

Once these edits have been made, open the rootfs configuration and enable the user packages.

petalinux-config -c rootfs

Enabling the user packagesEnabling the user packages

To be able to use the platform for acceleration, we need to make a few changes to the kernel configuration:

petalinux-config -c kernel

Make the following changes:

  • Device Drivers > Generic Driver Options > DMA Contiguous Memory Allocator > Size in Mega Bytes change the size from 256 to 1024 MB
  • Device Drivers -> Staging drivers -> Xilinx APF Accelerator driver
  • Device Drivers -> Staging drivers -> Xilinx APF Accelerator driver -> Xilinx APF DMA engines support

Once this has been completed, we then ready to build the PetaLinux image.

petalinux-build

Building the PetaLinux ImageBuilding the PetaLinux Image

Wait until the build completes and we can then create the sysroot, change directory into the <project>/images/linux/directory.

petalinux-build --sdk

We will use this to install the sysroot in the pfm directory run the command:

./sdk.sh

When prompted, enter the full path to the pfm directory.

Sysroot installerSysroot installer

Finally, copy the following files from the <project>/images/linux directory to the boot directory.

  • image.ub
  • zynqmp_fsbl.elf
  • pmufw.elf
  • bl31.elf
  • u-boot.elf

Copying the boot filesCopying the boot files

We also need to create a linux.bif file under the boot directory this should contain the following.

/* linux */
 the_ROM_image:
 {
               [fsbl_config] a53_x64
               [bootloader] <zynqmp_fsbl.elf>
               [pmufw_image] <pmufw.elf>
               [destination_device=pl] <bitstream>
               [destination_cpu=a53-0, exception_level=el-3, trustzone] <bl31.elf>
               [destination_cpu=a53-0, exception_level=el-2] <u-boot.elf>
 }

With all of this completed, we are now in a position to open Vitis and begin to create the platform. From within the pfm directory, run the following commands:

vitis -workspace wksp1

This will open the Vitis GUI. From under the project column, select Create Platform Project.

Vitis welcome screenVitis welcome screen

This will open a new platform project dialog, enter the project name and click next.

Dialog for project creationDialog for project creation

On the next dialog, select the create from hardware specification.

Selecting the platform definititon sourceSelecting the platform definititon source

On the next dialog, select the XSA which is under the Vivado directory.

Selecting the XSASelecting the XSA

Select the operating system as Linux and Processor as the PSU_Cortexta53.

Defining the SW solutionDefining the SW solution

Completing the dialog will open a platform project in Vitis. To be able to build the application, we need to provide the location of the BIF, boot directory, Linux image and sysroot — all of which are available under the PFM directory.

Platform specificationPlatform specification

With the information provided, we can build the application project. This might take a minute or two.

Building the Ultra96 Vitis acceleration platformBuilding the Ultra96 Vitis acceleration platform

Of course, to test the platform we need to create a test application, select new application project and from the available platforms you should be able to see the newly created Ultra96_min project. This project should be defined as being available for embedded and acceleration flow.

Selecting the new platformSelecting the new platform

For the application, select the demo example, change the target to hardware, and build the application.

This took about 30 minutes on my system.

Acceleration application build completedAcceleration application build completed

We now have a platform which we can use to accelerate our OpenCL applications on for the Ultra96 V2.

 

See My FPGA / SoC Projects: Adam Taylor on Hackster.io

Get the Code: ATaylorCEngFIET (Adam Taylor)

Access the MicroZed Chronicles Archives with over 300 articles on the FPGA / Zynq / Zynq MpSoC updated weekly at MicroZed Chronicles.

 

 

3 Comments
okoto
Newbie
Newbie

I did perform everything step by step, but build failed with message:

...system-user.dtsi:4.1-6 syntax error

FATAL ERROR: Unable to parse input tree

I have checked system-user.dtsi many times, but result is the same. What am I doing wrong?

 

xtech-blogs
Xilinx Employee
Xilinx Employee

@okoto, thank you for reading our blog. If you have any questions, please contact the author adam@adiuvoengineering.com.

baring42read
Adventurer
Adventurer

If you copy any thing and past , make sure you change the type of quotes. That resolved the issue for me.