User Tools

Site Tools


xilinx_running_petalinux

Overview

This page steps through using the Vivado-generated artifacts *.hdf (hardware description file) and *.bit (FPGA bitstream file) to build a bootable SD card for the target board, based on the 2018.3 versions of both Vivado and PetaLinux.

Prerequisites

For this example, PetaLinux requires two files generated by an earlier run of the same version of Vivado:

  • the hardware description file *.hdf
  • the FPGA bitstream file *.bit

Depending on how the HDF file was generated, it may in fact contain the bitstream file as one of its components.

Format of the HDF file

Purely for interest's sake, the Vivado-generated HDF file is a Zip-format file, which can be examined and/or unpacked via unzip, as in:

$ unzip -l system.hdf
Archive:  system.hdf
02nWkJ+EVzMl9sp/6/wZQgcY7ZuqXJnPS/fNhuMgTyrp0=
  Length      Date    Time    Name
---------  ---------- -----   ----
      913  05-27-2019 10:21   sysdef.xml
   438549  05-27-2019 10:21   DMA_PCIe_EP.hwh
    84343  05-27-2019 10:21   DMA_PCIe_EP_bd.tcl
   750745  05-27-2019 10:21   psu_init.c
  1425922  05-27-2019 10:21   psu_init.h
   749909  05-27-2019 10:21   psu_init_gpl.c
  1425308  05-27-2019 10:21   psu_init_gpl.h
    48659  05-27-2019 10:21   psu_init.html
   731011  05-27-2019 10:21   psu_init.tcl
 36343237  05-27-2019 10:21   DMA_PCIe_EP_wrapper.bit
---------                     -------
 41998596                     10 files
$

As you can see, if you seem to be missing the FPGA bitstream file, it might already be in the HDF file.

PetaLinux build procedure

Preparing for the build

First, source the appropriate environment file for PetaLinux 2018.3; something like:

$ source .../PetaLinux/2018.3/settings.sh

followed by creating a new (for this discussion, zynqMP-based) PetaLinux project and moving to that new project directory:

$ petalinux-create \
  --type project \
  --name myproj \
  --template zynqMP
$ cd myproj

Incorporating the HDF file

Configure the new project by running petalinux-config and incorporating the aforementioned .hdf file by referring to its directory location:

$ petalinux-config --get-hw-description <dirname of HDF File>

at which time you will be placed in the PetaLinux “System Configuration” utility; if you have nothing to change, simply exit and save your configuration.

Configuring the project kernel

If you want to configure the project's kernel, first ensure that you have some appropriate terminal emulation to support the configuration window. For example, if you're connected to the build host via SSH, and that build host has the screen utility installed, simply set:

$ export TERM=screen

Once that's done, you can configure the kernel with:

$ petalinux-config -c kernel

As a common example of configuration (necessary for the Sidewinder board), you can select the PCI-related kernel feature:

  • Bus Support →
    • PCI host controller drivers →
      • Xilinx XDMA PL PCIe host bridge support

then save and exit.

The build process

Now that all of the project configuration is complete, kick off the PetaLinux build with:

$ petalinux-build

A successful build should generate numerous build artifacts under the project's images/linux/ directory, depending on how the project was configured:

$ ls images/linux/
bl31.bin     rootfs.cpio.bz2        rootfs.its            system.dtb
bl31.elf     rootfs.cpio.gz         rootfs.jffs2          System.map.linux
Image        rootfs.cpio.gz.u-boot  rootfs.manifest       u-boot.bin
image.ub     rootfs.ext3            rootfs.tar.bz2        u-boot.elf
pmufw.elf    rootfs.ext3.bz2        rootfs.tar.gz         vmlinux
rootfs.bin   rootfs.ext4            rootfs.testdata.json  zynqmp_fsbl.elf
rootfs.cpio  rootfs.ext4.gz         system.bit
$

The packaging step

The final step in the PetaLinux build is to “package” the appropriate generated artifacts to copy to a bootable SD card to boot the target system (in this case, a Fidus Sidewinder). The simplest SD card image will contain two files:

  • BOOT.BIN
  • image.ub

The FIT image file image.ub should already have been generated; to complete the process, build the BOOT.BIN file with:

$ petalinux-package \
  --boot \
  --force \
  --format BIN \
  --fsbl images/linux/zynqmp_fsbl.elf \
  --fpga images/linux/system.bit \
  --u-boot
$

whereupon you can see the target boot file BOOT.BIN being constructed, generating output something like:

INFO: File in BOOT BIN: ".../myproj/images/linux/zynqmp_fsbl.elf"
INFO: File in BOOT BIN: ".../myproj/images/linux/pmufw.elf"
INFO: File in BOOT BIN: ".../myproj/images/linux/system.bit"
INFO: File in BOOT BIN: ".../myproj/images/linux/bl31.elf"
INFO: File in BOOT BIN: ".../myproj/images/linux/u-boot.elf"
INFO: Generating ZynqMP binary package BOOT.BIN...

You can optionally create a .bsp file for import into a future PetaLinux project with:

$ petalinux-package \
  --bsp \
  --project . \
  --output myproj.bsp
xilinx_running_petalinux.txt · Last modified: 2019/05/29 11:20 by rpjday