Creating the Software Component
A Vitis platform requires software components. For baremetal/standalone applications, the Vitis platform project flow generates the necessary boot components, such as the FSBL and PMU firmware, along with their board support packages (BSPs). For Linux, the PetaLinux tools are invoked outside of the Vitis tools by the developer to create the necessary Linux image,Executable and Linkable Format (ELF) files, and sysroot with XRT support. Yocto or third-party Linux development tools can also be used as long as they produce the same Linux output products as PetaLinux. Software components requirements are listed in Software Component Requirements.
Using PetaLinux for Generating Linux Output Products
For Linux projects, you can create a PetaLinux project, add support for the hardware defined in the XSA, and configure the project to include the software packages needed for the XRT. Follow the steps listed below to generate the Linux software objects and Linux image for the platform. For more information about the PetaLinux tools, refer to PetaLinux Tools Documentation: Reference Guide (UG1144).
To generate the Linux software objects and Linux image:
- Change to the working directory and create a sub-directory to hold the Vitis platform creation workspace and a boot directory to hold
the outputs from running the PetaLinux
tools.
cd zcu102_min_pkg mkdir pfm; cd pfm mkdir wksp1 mkdir boot cd .. - Set up paths to the PetaLinux
tools.
source <PetaLinux_Tool_Install_Directory>/settings.sh - Create a PetaLinux project named petalinux in the zcu102_pkg
directory.
The project name is user-defined, but for this example, adopt the naming convention used here. A PetaLinux project can be based on a board support package (BSP) or a template. If a BSP is available and provides the necessary features, it can be used as the starting point. In this example, we begin with the Zynq® UltraScale+™ MPSoC template.
petalinux-create -t project --template zynqMP -n petalinux - Add the hardware customization into the PetaLinux project by providing a path to
the directory containing the
XSA.
cd petalinux petalinux-config --get-hw-description=../vivado - In the PetaLinux menu, set
CONFIG_SUBSYSTEM_MACHINE_NAMEtozcu102-rev1.0if desired. The PetaLinux tools know about certain Xilinx boards as listed in PetaLinux Tools Documentation: Reference Guide (UG1144).Note: You can typepetalinux-configto bring up a GUI interface where the arrow keys and the Tab key are used to navigate the menus and selection choices.To change the machine name:
- Select and change the template to
zcu102-rev1.0. - Exit and save when prompted.
- Select and change the template to
- Add user packages for XRT support by appending the
CONFIG_xlines below to the petalinux/project-spec/meta-user/conf/user-rootfsconfig file. This step can be skipped if an XSA was created for the Vitis embedded software only flow and does not use the XRT and acceleration kernels.- CONFIG_xrt
- CONFIG_xrt-dev
- CONFIG_zocl
- CONFIG_opencl-clhpp-dev
- CONFIG_opencl-headers-dev
- CONFIG_packagegroup-petalinux-opencv
- Update the Device tree to include the zocl driver by appending the text
below to the petalinux/project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi
file. TIP: This step can be skipped if an XSA was created for the Vitis embedded software development flow and does not use the XRT and acceleration kernels.
&amba { zyxclmm_drm { compatible = “xlnx,zocl”; status = “okay”; }; };TIP: If copying and pasting, ensure the quote marks pasted into the system_user.dtsi file are vertical quotes, otherwise a parsing error will occur during the PetaLinux build. - Enable all the user packages that were added earlier. This step can be
skipped if an XSA was created for the Vitis
embedded software only flow and does not use the XRT and acceleration kernels.
To enable the user packages:
- Type
petalinux-config -c rootfs. - Select user packages.
- Type "y" to enable the user packages for
xrt,xrt-dev,zocl,opencl-hpp-dev,opencl-headers-dev, andpackagegroup-petalinux-opencv. - Save and exit when prompted.
- Type
- Increase the size allocation for CMA memory to 1024 MB (optional), as
follows:
- Type
petalinux-config -c kernel - Select .
- Press the Enter key and change 256 to 1024.
- Ensure the following are turned off by entering 'n' in the [ ] menu
selection for:
- Save and exit when prompted.
- Type
- From within the PetaLinux project (petalinux), start the Linux
build:
petalinux-build - Create a sysroot self-installer for the target Linux
system;
cd images/linux petalinux-build --sdk - Use the sdk.sh self-installer to output and install the
sysroot. Place the generated sysroot files into the pfm
working directory that was created earlier by providing a full pathname to the
output directory when prompted:
- Type ./sdk.sh.
- Provide a full pathname to the output directory (<Full_Pathname_to_zcu102_min_pkg>/pfm) and confirm.
- After the PetaLinux build succeeds, the generated Linux software components are
in the <PetaLinux_Project>/images/linux directory. For
our example, the petalinux/images/linux directory contains
the generated image and ELF files listed below. Copy these files to the
zcu102_min_pkg/pfm/boot directory in preparation for
running the Vitis platform creation flow:
- image.ub
- zynqmp_fsbl.elf
- pmufw.elf
- bl31.elf
- u-boot.elf
- Add a BIF file (linux.bif) to the boot
directory with the contents shown below. The file names should match the
contents of the boot directory. The Vitis
tool expands these pathnames relative to the sw directory of the platform at
v++link time or when generating an SD card. However, if thebootgencommand is used directly to create a BOOT.BIN file from a BIF file, full pathnames in the BIF are necessary. Bootgen does not expand the names between the<>symbols./* 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> }