5. Create boot files for ultrascale

The newer versions of the Accelerator Integration Tool (AIT, formerly autoVivado) support the automatic generation of boot files for some boards. This includes the steps in Petalinux (2016.3) build for a custom hdf or Petalinux (2018.3) build for a custom hdf, which are the ones repeated for every BOOT.BIN generation. The steps in Petalinux project setup are needed to setup the petalinux project build environment. Assuming that you have a valid petalinux build, you can use the ait functionality with the following points:

  • Add the option --to_step=boot when calling ait.
  • Provide the Petalinux installation and project directories using the following environment variables:
    • PETALINUX_INSTALL Petalinux installation directory.
    • PETALINUX_BUILD Petalinux project directory.

The following sections explain how to build a petalinux project and how to generate a BOOT.BIN using this project.

5.1. Prerequisites

5.1.1. Petalinux installation

Petalinux is installed running its auto-installer package:

./petalinux-v2016.3-final-installer.run

After installation, you should source the petalinux environment file. Usually, this needs to be done every time you want to run from a new terminal. Note that the petalinux settings may change the ARM cross compilers breaking the OmpSs@FPGA tool-chain.

source <petalinux install dir>/settings.sh

5.2. Petalinux project setup

The following steps should be executed once. After them, you will be able to build different boot files just using the AIT option or executing the steps in any of the following sections: Petalinux (2016.3) build for a custom hdf (for Petalinux 2016.3) or Petalinux (2018.3) build for a custom hdf (for Petalinux 2018.3).

5.2.1. Unpack the bsp

Unpack the bsp to create the petalinux project.

petalinux-create -t project -s <path to petalinux bsp>

5.2.2. [Optional] Fix known problems in AXIOM-ZU9EG-2016.3 project

Here are some patches for known problems:

5.2.3. [Optional] Modify the FSBL to have the Fallback system

We developed a modification of Xilinx First Stage Boot Loader (FSBL) to support a fallback boot to a valid known BOOT.BIN file. More information in:

5.2.4. Configure petalinux

Run petalinux configuration. No changes need to be made to petalinux configuration, but this step has to be run.

export GIT_SSL_NO_VERIFY=1 #Ignore broken certificates
petalinux-config

After configuration this step, petalinux will download any needed files from external repositories.

5.2.5. Configure linux kernel

To enter the kernel configuration utility, run:

petalinux-config -c kernel

5.2.5.1. [Optional] Enable Xilinx DMA driver

Note

This step is only needed when the the use of DMA engines is desired.

Xilinx driver support has to be enabled in order to support Xilinx DMA engine devices. Usually, this is not needed as OmpSs@FPGA does not make use them to send tasks, neither information, between the host and the FPGA device. It can be enabled in: Device drivers DMA Engines Support Xilinx axi DMAS

Fix old kernels

In petalinux <2017, there is a known problem in the Xilinx DMA implementation. To fix it, download xilinx_dma.c and replace it in <project dir>/build/linux/kernel/download/linux-4.6.0-AXIOM-v2016/drivers/dma/xilinx/xilinx_dma.c, when using a remote kernel, otherwise in <petalinux install dir>/components/linux-kernel/xlnx-4.6/drivers/dma/xilinx/xilinx\_dma.c.

5.2.5.2. [Optional] Increase the CMA (Contiguous Memory Area)

You may want to increase the CMA size. It is used by Nanos++ as memory for the FPGA device copies. Its size can be set in: Device drivers Generic Driver Options DMA Contiguous Memory Allocator

5.3. Petalinux (2016.3) build for a custom hdf

Once petalinux project is setup, you can update it to contain a custom bitstream with your hardware. This steps can be repeated several times without executing again the steps in the Petalinux project setup section. Moreover, AIT supports the automatic execution of the following steps as explained in the beginning of this page.

First, you need to import the hardware description file (hdf) in the petalinux project. This is done executing the following command in the root directory of the petalinux project build.

petalinux-config --get-hw-description <path to application hdf file>

5.3.1. Add missing nodes to device tree

Some nodes should be added to the device tree before compiling it.

5.3.1.1. misc_clk_0

Edit the file ./subsystems/linux/configs/device-tree/pl.dtsi to add or edit the node misc_clk_0. It should have the following contents (ensure that clock-frequency is correctly set):

misc_clk_0: misc_clk_0 {
  compatible = "fixed-clock";
  #clock-cells = <0>;
  clock-frequency = <200>;
};

5.3.1.2. pl_bsc.dtsi

AIT will generate a pl_bsc.dtsi file in the main Vivado project folder. This file contains the missing nodes in the amba_pl based on your application build. This file must be copied in ./subsystems/linux/configs/device-tree/ folder and included in ./subsystems/linux/configs/device-tree/system-conf.dtsi file.

For example, it will be located in test_ait/Vivado/test/ folder if the project name is test.

5.3.2. Build the Linux system

When the project is correctly updated, you can build it with the following commands:

petalinux-build

5.3.2.1. Error in fsbl compilation

In some cases, fsbl compilation triggered during the petalinux build can fail. This is due to a bad cleanup from previous compilation. In this cases, a complete fsbl cleanup and a new build must be performed. Note, that this extra cleanup may collision with the steps described in [Optional] Modify the FSBL to have the Fallback system.

petalinux-build -c bootloader -x mrproper
petalinux-build

5.3.3. [Optional] Build PMU Firmware

Run hsi (included in petalinux and Xilinx SDK).

hsi

Inside hsi run

set hwdsgn [open_hw_design <hardware.hdf>]
generate_app -hw $hwdsgn -os standalone -proc psu_pmu_0 -app zynqmp_pmufw -compile -sw pmufw -dir <dir_for_new_app>

Warning

As of vivado 2016.3 pmu firmware breaks Trenz’s TEBF0808 boot

5.3.4. Create BOOT.BIN file

petalinux-package --force --boot --fsbl images/linux/zynqmp_fsbl.elf --fpga <path to application bit file> --u-boot images/linux/u-boot.elf
cp BOOT.BIN images/linux/image.ub <path to boot partition>

When using PMU firmware, pmu binary has to be included in boot.bin file. To do so, add the --pmufw <pmufw.elf> argument to the petalinux-package command.

5.4. Petalinux (2018.3) build for a custom hdf

Once petalinux 2018.3 project is setup, you can update it to contain a custom bitstream with your hardware. This steps can be repeated several times without executing again the steps in the Petalinux project setup section. Moreover, AIT supports the automatic execution of the following steps as explained in the beginning of this page.

First, you need to import the hardware description file (hdf) in the petalinux project. This is done executing the following command in the root directory of the petalinux project build.

petalinux-config --get-hw-description <path to application hdf file>

5.4.1. Add missing nodes to device tree

Some nodes should be added to the device tree before compiling it.

5.4.1.1. pl_bsc.dtsi

AIT will generate a pl_bsc.dtsi file in the main Vivado project folder. This file contains the missing nodes in the amba_pl based on your application build. For example, it will be located in test_ait/Vivado/test/ folder if the project name is test. The contents of such file must be placed at the end of ./project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi file. Note that any remaining contents from a previous build must be removed before. The follwoing commant will append the pl_bsc.dtsi content at the end of system-user.dtsi file:

cat <path to vivado project>/pl_bsc.dtsi >>project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi

5.4.2. Build the Linux system

When the project is correctly updated, you can build it with the following commands:

petalinux-build

5.4.3. Create BOOT.BIN file

petalinux-package --force --boot --fsbl images/linux/zynqmp_fsbl.elf --fpga <path to application bit file> --u-boot images/linux/u-boot.elf
cp BOOT.BIN images/linux/image.ub <path to boot partition>