.. index:: double: boot; xilinx .. _xilinx-boot-files: ========================================= Generate boot files for Xilinx SoC boards ========================================= To generate the required files to boot the SoC boards (Zynq and Zynq Ultrascale+ families), Xilinx offers the `PetaLinux `_ set of tools. Additionally, OmpSs\@FPGA toolchain supports the automatic generation of boot files using these tools. The following sections describe how to generate the boot files both manually and automatically. Prerequisites ============= - `PetaLinux installer `_ (2021.2 or newer) - Xilinx support archive (XSA) file from a synthesized Vivado project - Board Support Package (BSP) file for the target board PetaLinux installation ---------------------- PetaLinux is installed running its auto-installer package: .. code-block:: text ./petalinux-v2023.2-10121855-installer.run --dir 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. .. caution:: Sourcing PetaLinux settings file may change the ARM cross-compilers. .. code-block:: text source /settings.sh .. _xilinx-boot-project-setup: PetaLinux project setup ======================= The following steps should be executed once. After that, you will be able to generate boot files for the target board just using the ``ait`` feature or executing the steps in any of the following sections. Unpack the bsp -------------- Unpack the bsp to create the PetaLinux project: .. code-block:: text petalinux-create -t project -s -n Configure PetaLinux ------------------- Run PetaLinux configuration and change the root filesystem type to ``ext4``: .. code-block:: text petalinux-config .. code-block:: text Image Packaging Configuration → Root filesystem type → EXT4 (SD/eMMC/SATA/USB) You might also want to disable automatic copy to tftpboot to avoid a warning message at every build: .. code-block:: text Image Packaging Configuration → Copy final images to tftpboot .. note:: Some boards may fail to build the First Stage Boot Loader (FSBL) due to its size. In order to shrink the FSBL provide the following flags to the compiler (this will disable support for NAND and QSPI boot modes): .. code-block:: text FSBL Configuration → FSBL compiler flags → -DFSBL_NAND_EXCLUDE, -DFSBL_QSPI_EXCLUDE Configure linux kernel ---------------------- To enter the kernel configuration utility, run: .. code-block:: text petalinux-config -c kernel .. note:: You may want to increase the CMA size. It is used by Nanos6 as memory for the FPGA device copies. Its size can be set in: .. code-block:: text Device drivers → Generic Driver Options → DMA Contiguous Memory Allocator .. _xilinx-boot-manual-build: Generate boot files manually ============================ Once PetaLinux project is setup, you can update it to contain a custom bitstream with your hardware. These steps can be repeated several times without executing again the steps in the :ref:`xilinx-boot-project-setup` section. First, you need to import the Xilinx support archive file (xsa) in the PetaLinux project. This is done by executing the following command in the root directory of the PetaLinux project build. .. code-block:: text petalinux-config --silent-config --get-hw-description Add OmpSs\@FPGA node to the device tree --------------------------------------- The OmpSs\@FPGA node must be added to the device-tree before compiling it. Copy the file ``pl_ompss_at_fpga.dtsi`` generated by AIT to ``project-spec/meta-user/recipes-bsp/device-tree/files/``. Edit files ``project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi`` and ``project-spec/meta-user/recipes-bsp/device-tree/device-tree.bbappend`` and add the following lines: .. code:: bash echo '/include/ "pl_ompss_at_fpga.dtsi"' > project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi echo 'SRC_URI:append = " file://pl_ompss_at_fpga.dtsi"' > project-spec/meta-user/recipes-bsp/device-tree/device-tree.bbappend Build the Linux system ---------------------- When the project is correctly updated, you can build it with the following command: .. code-block:: text petalinux-build Create BOOT.BIN file -------------------- Finally, generate the boot files by running the following command: .. code-block:: text petalinux-package --force --boot --fsbl images/linux/zynq*_fsbl.elf --fpga --u-boot images/linux/u-boot.elf Use AIT to generate boot files ============================== The Accelerator Integration Tool (AIT) can automatically and transparently perform the steps described in :ref:`xilinx-boot-manual-build`. To do so, you must: * Add the option ``--to_step=boot`` on the AIT call to enable the ``boot`` step * Set the environment variable ``PETALINUX_BUILD`` with the path to the pre-configured PetaLinux build project of the target board Once the boot files have been correctly generated, AIT will copy them into the project directory at ``/boot``. Copy the files to the SD boot partition ======================================= Finally, mount the boot partition of the board SD into your system and copy the required files (device name and paths might not be the same): .. code:: bash udisksctl mount --block-device /dev/mmcblk0p1 cp /images/linux/BOOT.BIN /media//boot/ cp /images/linux/image.ub /media//boot/ cp /images/linux/boot.scr /media//boot/ udisksctl unmount --block-device /dev/mmcblk0p1