Petalinux Document
Petalinux Document
of this document
PetaLinux Tools
Documentation
Reference Guide
UG1144 (v2020.1) June 3, 2020
Revision History
Revision History
The following table shows the revision history for this document.
Section Revision Summary
06/03/2020 Version 2020.1
Chapter 2: Setting Up Your Environment Added the Installing a Preferred eSDK as part of the
PetaLinux Tool section.
Chapter 4: Configuring and Building Added the PetaLinux Commands with Equivalent devtool
Commands section.
Chapter 6: Upgrading the Workspace Added new sections: petalinux-upgrade Options, Upgrading
Between Minor Releases (2020.1 Tool with 2020.2 Tool) ,
Upgrading the Installed Tool with More Platforms, and
Upgrading the Installed Tool with your Customized
Platform.
Chapter 7: Customizing the Project Added new sections: Creating Partitioned Images Using Wic
and Configuring SD Card ext File System Boot.
Chapter 8: Customizing the Root File System Added the Appending Root File System Packages section.
Chapter 10: Advanced Configurations Updated PetaLinux Menuconfig System.
Chapter 11: Yocto Features Added the Adding Extra Users to the PetaLinux System
section.
Appendix A: Migration Added Tool/Project Directory Structure.
Chapter 1: Overview.................................................................................................... 7
Introduction................................................................................................................................. 7
Chapter 1
Overview
Introduction
PetaLinux is an embedded Linux Software Development Kit (SDK) targeting FPGA-based System-
on-Chip designs. This guide helps the reader to familiarize with the tool enabling overall usage of
PetaLinux.
You are assumed to have basic Linux knowledge, such as how to run Linux commands. You
should be aware of OS and host system features, such as OS version, Linux distribution, security
privileges, and basic Yocto concepts.
Note: Vitis™ unified software platform is the integrated design environment (IDE) for creating embedded
applications on Xilinx microprocessors. Refer to Vitis Unified Software Platform Documentation: Embedded
Software Development (UG1400) for more details.
PetaLinux SDK is a Xilinx development tool that contains everything necessary to build, develop, test, and
deploy embedded Linux systems.
Path Architecture
$PETALINUX/components/yocto/source/aarch64 Zynq® UltraScale+™ MPSoC
$PETALINUX/components/yocto/source/arm Zynq-7000 devices
$PETALINUX/components/yocto/source/ MicroBlaze™ platform full designs
microblaze_full
$PETALINUX/components/yocto/source/ MicroBlaze platform lite designs
microblaze_lite
Note: Earlier, the eSDKs were extracted in the specified path but now they are in tar. For 2020.1 and future
releases, your eSDK scripts have the same name and are extracted into <plnx-proj-root>/
components/yocto when you run the petalinux-config or the petalinux-build command in
the PetaLinux project. The project extracts the corresponding eSDK, for example, if you create a Zynq
UltraScale+ MPSoC project, then only the aarch64 eSDK is extracted into the <plnx-proj-root>/
components/yocto project.
For all embedded software applications (non-Linux), the PetaLinux tool uses XSCT underneath.
The Linux toolchain for all three architectures is from Yocto.
This contains all the PetaLinux commands that you require. The CLI command tools are:
• petalinux-create
• petalinux-config
• petalinux-build
• petalinux-util
• petalinux-package
• petalinux-upgrade
Chapter 2
Installation Steps
Installation Requirements
The PetaLinux tools installation requirements are:
○ Supported OS:
- Red Hat Enterprise Workstation/Server 7.4, 7.5, 7.6, 7.7, 8.1 (64-bit)
- CentOS Workstation/Server 7.4, 7.5, 7.6, 7.7, 8.1 (64-bit)
- Ubuntu Linux Workstation/Server 16.04.5, 16.04.6, 18.04.1, 18.04.2, 18.04.3, 18.04.4
(64-bit)
• You need to have root access to install the required packages mentioned in the following
table. The PetaLinux tools need to be installed as a non-root user.
• PetaLinux requires a number of standard development tools and libraries to be installed on
your Linux host workstation. Install the libraries and tools listed in the following table on the
host Linux.
• PetaLinux tools require that your host system /bin/sh is 'bash'. If you are using Ubuntu
distribution and your /bin/sh is 'dash', consult your system administrator to change your
default system shell /bin/sh with the sudo dpkg-reconfigure dash command.
Ubuntu Linux
CentOS Workstation/ Red Hat Enterprise Workstation/Server
Tool / Library Server 7.4, 7.5, 7.6, 7.7, 8.1 Workstation/Server 7.4, 16.04.5, 16.04.6, 18.04.1,
(64-bit) 7.5, 7.6, 7.7, 8.1 (64-bit) 18.04.2, 18.04.3, 18.04.4
(64-bit)
ip iproute iproute iproute
gcc gcc gcc gcc
g++ (gcc-c++) gcc-c++ gcc-c++ gcc-c++
netstat net-tools net-tools net-tools
ncurses ncurses ncurses libncurses5
devel -devel -devel -dev
zlib devel (also, zlib-devel zlib-devel zlib1g:i386
install 32-bit of
this version)
openssl openssl openssl libssl
devel -devel -devel 1.0 -dev
flex flex flex flex
bison bison bison bison
libselinux libselinux libselinux libselinux1
xterm xterm xterm xterm
autoconf autoconf autoconf autoconf
libtool libtool libtool libtool
texinfo texinfo texinfo texinfo
zlib1g-dev - - zlib1g-dev
gcc-multilib - - gcc-multilib
build-essential - - build-essential
SDL-devel SDL-devel SDL-devel -
glibc-devel glibc-devel glibc-devel -
32-bit glibc glibc glibc -
glib2-devel glib2-devel glib2-devel -
automake automake automake -
screen screen screen screen
pax pax pax pax
libstdc++ libstdc++ libstdc++ -
gawk gawk gawk gawk
python python python python
Note: For the exact package versions, refer to the PetaLinux 2020.1 Release Notes and Master Answer
Record: 73296.
CAUTION! Consult your system administrator if you are not sure about the correct procedures for host system
package management.
IMPORTANT! PetaLinux 2020.1 works only with hardware designs exported from Vivado® Design Suite
2020.1.
Prerequisites
• The PetaLinux tools installation requirements are met. See the Installation Requirements for
more information.
• The PetaLinux installer is downloaded. You can download PetaLinux installer from PetaLinux
Downloads.
./petalinux-v<petalinux-version>-final-installer.run
Options Description
--log <LOGFILE> Specifies where the logfile should be created. By default, it is
petalinux_installation_log in your working directory.
-d|--dir [INSTALL_DIR] Specifies the directory where you want to install the tool kit.
If not specified, the tool kit is installed in your working
directory.
-p|--platform <arch_name> Specifies the architecture:
$ mkdir -p /opt/pkg/petalinux/<petalinux-version>
$ ./petalinux-v<petalinux-version>-final-installer.run --dir /opt/pkg/
petalinux/<petalinux-version>
Note: Do not change the install directory permissions to CHMOD 775 as it might cause BitBake errors.
IMPORTANT! Once installed, you cannot move or copy the installed directory. In the above example, you
cannot move or copy /opt/pkg/petalinux/<petalinux-version> because the full path is stored in
the Yocto e-SDK environment file.
Note: You cannot install the tool as a root user. Ensure that /opt/pkg/petalinux is writeable. You can
change the permissions after installation to make it globally read-execute (0755). It is not mandatory to
install the tool in /opt/pkg/petalinux directory. You can install it at any location that has the 755
permissions.
Reading and agreeing to the PetaLinux End User License Agreement (EULA) is a required and
integral part of the PetaLinux tools installation process. You can read the license agreement prior
to running the installation. If you wish to keep the license for your records, the licenses are
available in plain ASCII text in the following files:
• $PETALINUX/etc/license/Third_Party_Software_End_User_License_Agree
ment.txt: This third party license agreement details the licenses of the distributable and
non-distributable components in PetaLinux tools.
By default, the WebTalk option is disabled to send tools usage statistics back to Xilinx. You can
turn on the WebTalk feature by running the petalinux-util --webtalk command after the
installation is complete.
IMPORTANT! Before running the PetaLinux command, you need to source PetaLinux settings. For more
information, see PetaLinux Working Environment Setup.
$ petalinux-util --webtalk on
• To install eSDKs for all Xilinx supported architectures like Zynq, Zynq UltraScale+ MPSoC,
microblaze_lite, and microblaze_full:
$ ./petalinux-v<petalinux-version>-final-installer.run --dir
<INSTALL_DIR>
• To install the Zynq and Zynq UltraScale+ MPSoC eSDKs for arm and aarch64 architecture
$ ./petalinux-v<petalinux-version>-final-installer.run --dir
<INSTALL_DIR> --platform "arm aarch64"
Troubleshooting
This section describes some common issues you may experience while installing the PetaLinux
tool. If the PetaLinux tool installation fails, the file petalinux_installation_log is
generated in your PetaLinux installation directory.
Prerequisites
This section assumes that the PetaLinux tools installation is complete. For more information, see
Installation Steps.
Below is an example of the output when sourcing the setup script for the first time:
PetaLinux environment set to '/opt/pkg/petalinux'
INFO: Checking free disk space
INFO: Checking installed tools
INFO: Checking installed development libraries
INFO: Checking network and other services
WARNING: No tftp server found - please refer to "UG1144 2020.1
PetaLinux Tools Documentation Reference Guide" for its impact and
solution
Environment variable $PETALINUX should point to the installed PetaLinux path. The output
may be different from this example based on the PetaLinux installation path.
Troubleshooting
This section describes some common issues that you may experience while setting up PetaLinux
Working Environment.
• The Linux Kernel that is running has SELinux configured. This can cause issues
with regards to security context and loading libraries.
Solution:
1. Source the settings.sh script from the top-level PetaLinux directory. For more
information, see PetaLinux Working Environment Setup.
$ cd $PETALINUX/tools/xsct/lib/lnx64.o
Chapter 3
Creating a Project
BSPs are not included in the PetaLinux tools installer and need to be downloaded and installed
separately. PetaLinux BSP packages are available on the Xilinx.com Download Center. There is a
README in each BSP which explains the details of the BSP.
Prerequisites
This section assumes that the following prerequisites have been satisfied:
• PetaLinux BSP is downloaded. You can download PetaLinux BSP from PetaLinux Downloads.
• PetaLinux Working Environment Setup is completed. For more details, see PetaLinux Working
Environment Setup.
The board being referenced is based on the BSP installed. The output is similar to the
following output:
INFO: Create project:
INFO: Projects:
INFO: * xilinx-zcu102-v<petalinux-version>
INFO: has been successfully installed to /home/user/
INFO: New project successfully created in /home/user/
In the above example, when the command runs, it tells you the projects that are extracted
and installed from the BSP. If the specified location is on the Network File System (NFS), it
changes the TMPDIR to /tmp/<projname-timestamp-id>; otherwise, it is set to
$PROOT/build/tmp.
If /tmp/<projname_timestamp> is also on NFS, then it throws an error. You can change
TMPDIR anytime through petalinux-config → Yocto-settings. Do not configure the same
location as TMPDIR for two different PetaLinux projects as it can cause build errors.
Run ls from /home/user to see the created project(s). For more details on the structure of
a PetaLinux project, see Appendix B: PetaLinux Project Structure.
CAUTION! Do not create PetaLinux projects in the install area and do not use the install area as a tmp build
area.
Troubleshooting
This section describes some common issues you may experience while installing PetaLinux BSP.
Prerequisites
This section assumes that the following prerequisites have been satisfied:
• Vivado® Design Suite is installed. You can download Vivado Design Suite from Vivado Design
Tool Downloads.
• You have set up the Vivado tools working environment. If you have not, source the
appropriate settings scripts as follows:
$ source <path-to-installed-Xilinx-Vivado>/settings64.sh
Note: You can have Vivado tools set up on a different machine; it is not necessary to have PetaLinux
and Vivado tools set up on the same machine.
• You are familiar with the Vivado Design Suite and the Vitis™ software development platform.
For more information, see the Vitis Unified Software Platform Documentation: Embedded
Software Development (UG1400).
The following is a list of hardware requirements for a Zynq® UltraScale+™ MPSoC hardware
project to boot Linux:
IMPORTANT! If soft IP with interrupt or external PHY device with interrupt is used, ensure the interrupt signal
is connected.
Zynq-7000 Devices
The following is a list of hardware requirements for a Zynq-7000 hardware project to boot Linux:
IMPORTANT! If multiple TTCs are enabled, the Zynq-7000 Linux kernel uses the first TTC block from the
device tree. Please make sure the TTC is not used by others.
IMPORTANT! If soft IP is used, ensure the interrupt signal is connected. If soft IP with interrupt or external
PHY device with interrupt is used, ensure the interrupt signal is connected.
The following is a list of requirements for a MicroBlaze™ hardware project to boot Linux:
• MicroBlaze processor initial boot loader fs-boot needs minimum 4 KB of BRAM for parallel
flash and 8 KB for SPI flash when the system boots from non-volatile memory.
Prerequisites
This section assumes that a hardware platform is created with the Vivado Design Suite. For more
information, see Configuring Hardware Platform with Vivado Design Suite.
During project initialization (or update), PetaLinux generates a device tree source file, U-Boot
configuration header files (if auto config enabled for U-Boot), and enables the Linux kernel
drivers (if auto config enabled for Linux) based on the hardware description file. These details are
discussed in Appendix B: PetaLinux Project Structure.
For Zynq® UltraScale+™ MPSoC platform, you need to boot with the Platform Management Unit
(PMU) firmware and ATF. See Appendix C: Generating Boot Components for building PMU
firmware and ATF. If you want a first stage boot loader (FSBL) built for Cortex™-R5F boot, you
have to build it with the Vitis™ software platform because the FSBL built with PetaLinux tools is
for Cortex-A53 boot. For details on how to build the FSBL for Cortex-R5F with the Vitis software
platform, see the Zynq UltraScale+ MPSoC: Software Developers Guide (UG1137).
Prerequisites
This section assumes that the PetaLinux working environment setup is complete. For more
information, see PetaLinux Working Environment Setup.
Note: The MicroBlaze option cannot be used along with Zynq-7000 devices or Zynq UltraScale+
designs in the Programmable Logic (PL).
This command creates a new PetaLinux project folder from a default template. The following
steps customize these settings to match the hardware project created previously.
If --template option is used instead of a BSP, you can use the petalinux-config command
to choose default board configs that are close to your board design, as shown below:
Note: Changing the XSA file in the <PATH-TO-XSA directory> later gives an INFO: Seems like your
hardware design:<PATH-TO_XSA Directory>/system.xsa has changed warning for all subsequent
executions of the petalinux-config/petalinux-build commands. This means that your xsa
has changed. To use the latest XSA, run petalinux-config --get-hw-description <PATH-
TO-XSA> again.
TIP: For details on the PetaLinux project structure, see Appendix B: PetaLinux Project Structure.
CAUTION! When a PetaLinux project is created on NFS, petalinux-create automatically changes the
TMPDIR to /tmp/<projname-timestamp-id> . If /tmp is on NFS, it throws an error. To change the
TMPDIR to a local storage, select petalinux-config → Yocto-settings → TMPDIR. Do not configure the same
location as TMPDIR for two different PetaLinux projects. This can cause build errors. If TMPDIR is at /tmp/..,
deleting the project does not work. To delete the project, run petalinux-build -x mrproper.
Chapter 4
Version Control
This section details about version management/control in PetaLinux project.
Prerequisites
This section assumes that you have created a new PetaLinux project or have an existing
PetaLinux project. See Creating an Empty Project from a Template for more information on
creating a PetaLinux project.
Version Control
You can have version control over your PetaLinux project directory <plnx-proj-root>,
excluding the following:
• <plnx-proj-root>/.petalinux
• <plnx-proj-root>/!.petalinux/metadata
• <plnx-proj-root>/build/
• <plnx-proj-root>/images/linux
• <plnx-proj-root>/pre-built/linux
• <plnx-proj-root>/components/plnx-workspace/
• <plnx-proj-root>/components/yocto/
• <plnx-proj-root>/*/*/config.old
• <plnx-proj-root>/*/*/rootfs_config.old
• <plnx-proj-root>/*.o
• <plnx-proj-root>/*.log
• <plnx-proj-root>/*.jou
By default, these files are added into .gitignore while creating the project.
Note: A PetaLinux project should be cleaned using petalinux-build -x mrproper before submitting
to the source control.
Note: In concurrent development, TMPDIR in petalinux-config should be unique for each user.
Prerequisites
This section assumes that the following prerequisites have been satisfied:
• You have exported the hardware platform and .xsa file is generated. For more information, see
Exporting Hardware Platform.
• You have created a new PetaLinux project or have an existing PetaLinux project. For more
information on creating a PetaLinux project, see Creating an Empty Project from a Template.
2. Import the hardware description with petalinux-config command by giving the path of
the directory containing the .xsa file as follows:
$ petalinux-config --get-hw-description <PATH-TO-XSA Directory>
Note: Changing the XSA file in the <PATH-TO-XSA directory> later gives an INFO: Seems like your
hardware design:<PATH-TO_XSA Directory>/system.xsa has changed warning for all subsequent
executions of the petalinux-config/petalinux-build commands. This means that your xsa
has changed. To use the latest XSA, run petalinux-config --get-hw-description <PATH-
TO-XSA> again.
This launches the top system configuration menu. When the petalinux-config --get-hw-
description command runs for the PetaLinux project, the tool detects changes in the system
primary hardware candidates:
Ensure Subsystem AUTO Hardware Settings is selected, and go into the menu which is similar to
the following:
The Subsystem AUTO Hardware Settings → menu allows customizing system wide hardware
settings.
This step can take a few minutes to complete because the tool parses the hardware description
file for hardware information required to update the device tree, PetaLinux U-Boot configuration
files and the kernel config files based on the “Auto Config Settings --->” and “Subsystem AUTO
Hardware Settings --->” settings.
For example, if ps7_ethernet_0 as the Primary Ethernet is selected and you enable the auto
update for kernel config and U-Boot config, the tool automatically enables its kernel driver and
also updates the U-Boot configuration headers for U-Boot to use the selected Ethernet
controller.
Note: For more details on Auto Config Settings menu, see the Auto Config Settings.
The --silentconfig option allows you to reuse a prior configuration. Old configurations have
the file name CONFIG.old within the directory containing the specified component for
unattended updates.
This step generates a device tree DTB file, a first stage boot loader (for Zynq devices, Zynq
UltraScale+ MPSoC, and MicroBlaze), and ATF (for Zynq UltraScale+ MPSoC), U-Boot, the
Linux kernel, and a root file system image. Finally, it generates the necessary boot images.
3. The compilation progress shows on the console. Wait until the compilation finishes.
When the build finishes, the generated images are stored in the <plnx-proj-root>/images/
linux or /tftpboot directories.
petalinux-build
INFO: sourcing build tools
[INFO] building project
[INFO] generating Kconfig for project
[INFO] silentconfig project
[INFO] extracting yocto SDK to components/yocto
[INFO] sourcing build environment
[INFO] generating kconfig for Rootfs
[INFO] silentconfig rootfs
[INFO] generating plnxtool conf
[INFO] generating user layers
[INFO] generating workspace directory
INFO: bitbake petalinux-image-minimal
Default Image
When you run petalinux-build, it generates FIT images for Zynq® UltraScale+™ MPSoC,
Zynq-7000 devices, and MicroBlaze™ platforms. The RAM disk image rootfs.cpio.gz.u-
boot is also generated.
The full compilation log build.log is stored in the build sub-directory of your PetaLinux
project. The final image, <plnx-proj-root>/images/linux/image.ub, is a FIT image. The
kernel image (including RootFS) is Image for Zynq® UltraScale+™ MPSoC, zImage for
Zynq-7000 devices, and image.elf for MicroBlaze processors. The build images are located in
the <plnx-proj-root>/images/linux directory. A copy is also placed in the /tftpboot
directory if the option is enabled in the system-level configuration for the PetaLinux project.
IMPORTANT! By default, besides the kernel, RootFS, and U-Boot, the PetaLinux project is configured to
generate and build the first stage boot loader. For more details on the auto generated first stage boot loader, see
Appendix C: Generating Boot Components.
Troubleshooting
This section describes some common issues/warnings you may experience while building a
PetaLinux image.
Warnings/Errors
• WARNING: Skipping recipe linux-xlnx as it does not produce a package with the same name
• Description: It appears if the provided recipe name does not match with the packages
provided by it, for example, if linux-xlnx provides kernel-image, kernel-base, kernel-dev, and
kernel-modules packages and these does not match with the name linux-xlnx which was in
workspace directory.
• Solution: You can ignore this warning message.
• <package-name> do_package: Could not copy license file <plnx-proj-root>/
components/yocto/layers/core/meta/files/common-licenses/ to /opt/pkg/
petalinux/build/tmp/work/<machine-name>-xilinx-linux/image/usr/
share/licenses/<package-name>/COPYING.MIT [Errno 1] Operation not permitted:
• Description: When the tool is installed, all license files in <plnx-proj-root>/
components/yocto//layers/core/meta/files/common-licenses/ have 644
permissions. Therefore, they are readable by others but not writable.
• Solution:
• Method 1: Manually modify permissions of the license files coming from the layers
$ chmod 666 <proj-root-dir>/components/yocto/layers/core/meta/files/
common-licenses/*
When creating the hard link, you have write permissions to the source of the link.
• Method 2: Disable hard linking protection on the kernel
$ sysctl fs.protected_hardlinks=0
The kernel does not allows the source to be writable by the current user when creating
the hard link.
• Method 3: Set the following Yocto variables in <plnx-proj>/meta-user/conf/
petalinuxbsp.conf
LICENSE_CREATE_PACKAGE_forcevariable = "0"
SIGGEN_LOCKEDSIGS_TASKSIG_CHECK = "none"
The build system does not try to create the link and the license is not on the final image.
Prerequisites
This section assumes that you have built the PetaLinux system image. For more information, see
Build System Image.
Execute the following command to generate the boot image in .BIN format.
For detailed usage, see the --help option or PetaLinux Tools Documentation: PetaLinux Command
Line Reference (UG1157).
Prerequisites
This section assumes that you have built the PetaLinux system image. For more information, see
Build System Image.
Follow the step below to generate the boot image in .BIN format.
For detailed usage, see the --help option or PetaLinux Tools Documentation: PetaLinux Command
Line Reference (UG1157) .
Prerequisites
This section assumes that you have built the PetaLinux system image. For more information, see
Build System Image.
• To generate an MCS boot file, you must install the Vivado® Design Suite. You can download
the Vivado Design Suite from Vivado Design Tool Downloads.
• You have set up the Vivado tools working environment. If you have not, source the
appropriate settings scripts as follows:
$ source /settings64.sh
Command to generate the MCS file with fs-boot and FPGA bitstream only:
Command to generate the MCS file with FPGA bitstream, fs-boot, and U-Boot:
For detailed usage, see the --help option or PetaLinux Tools Documentation: PetaLinux Command
Line Reference (UG1157).
Modify Bitstream
Execute the following command to modify the bitstream file for MicroBlaze™ processor.
Build Optimizations
This section describes the build optimization techniques with the PetaLinux tools.
You can deselect default components, if they are not needed. To disable the FSBL and PMU
firmware for Zynq® UltraScale+™ MPSoC, deselect the following options in petalinux-config →
Linux Components Selection.
Deselecting these components removes these components from the default build flow.
Note: If the FSBL and PMU firmware are not built with PetaLinux, they must be built in the Vitis™ software
platform.
You can set internal mirrors on the NFS or web server which can speed up the builds. By default,
PetaLinux uses sstate-cache and download mirrors from petalinux.xilinx.com. Follow these steps
to work with local, NFS, or the internal webserver copy of sstate in PetaLinux. You can download
the sstate from the download area along with PetaLinux.
Server Description
downloads Source of download files are available in http://petalinux.xilinx.com/sswreleases/
rel-v2020/downloads
aarch64 sstate mirrors for Zynq UltraScale+ MPSoC
arm sstate mirrors for Zynq-7000
mb-full sstate mirrors for MicroBlaze™ processors (full)
mb-lite sstate mirrors for MicroBlaze processors (lite)
Source Mirrors
You can set source mirrors through petalinux-config → Yocto-settings → Add pre-mirror URL.
Select file://<local downloads path> for all projects. Save the configuration to use the
download mirrors and verify the changes in build/conf/plnxtool.conf.
To reduce the build time by disabling the network sstate feeds, de-select the petalinux-config →
Yocto Settings → Enable Network sstate feeds.
Sstate Feeds
• sstate feeds on NFS: Go to petalinux-config → Yocto Settings → Local sstate feeds settings
and enter the full path of the sstate directory. By enabling this option, you can point to your
own shared state which is available at a NFS/local mount point.
For example, to enable, use /opt/petalinux/sstate-cache_2020/aarch64.
• sstate feeds on webserver: Go to petalinux-config → Yocto Settings → Enable Network sstate
feeds → Network sstate feeds URL and enter the URL for sstate feeds.
Chapter 5
This step is typically done when you want to distribute your project as a BSP to other users.
Prerequisites
This section assumes that the following prerequisites have been satisfied:
• For Zynq® UltraScale+™ MPSoC and Zynq-7000 devices, you have generated the boot image.
For more information, see Generate Boot Image for Zynq UltraScale+ MPSoC.
• For MicroBlaze™ processors, you have generated the system image. For more information, see
Build System Image.
For detailed usage, see the --help option or the PetaLinux Tools Documentation: PetaLinux
Command Line Reference (UG1157).
Prerequisites
This section assumes that you have packaged prebuilt images. For more information, see
Packaging Prebuilt Images.
• Level 2: Download the prebuilt FPGA bitstream and boot the prebuilt U-Boot.
○ For Zynq-7000 devices: It boots FSBL before booting U-Boot.
○ For Zynq UltraScale+ MPSoC: It boots PMU firmware, FSBL, and ATF before booting U-
Boot.
• Level 3:
○ For MicroBlaze™ processors: Downloads the prebuilt FPGA bitstream and boots the
prebuilt kernel image on target.
○ For Zynq-7000 devices: Downloads the prebuilt FPGA bitstream and FSBL, boots the
prebuilt U-Boot, and boots the prebuilt kernel on target.
○ For Zynq UltraScale+ MPSoC: Downloads PMU firmware, prebuilt FSBL, prebuilt kernel,
prebuilt FPGA bitstream, linux-boot.elf, DTB, and the prebuilt ATF on target.
For details on Xilinx® IP Models supported by QEMU, see Appendix E: Xilinx IP Models
Supported by QEMU.
Prerequisites
This section assumes that the following prerequisites have been satisfied:
• You have a PetaLinux system image by either installing a PetaLinux BSP (see PetaLinux BSP
Installation) or by building your own PetaLinux project (see Build System Image).
• If you are going to use --prebuilt option for QEMU boot, you need to have prebuilt
images packaged. For more information, see Packaging Prebuilt Images.
IMPORTANT! Unless otherwise indicated, the PetaLinux tool command must be run within a project directory
(<plnx-proj-root>).
Use the following steps to test the PetaLinux reference design with QEMU:
1. Change to your project directory and boot the prebuilt Linux kernel image:
$ petalinux-boot --qemu --prebuilt 3
If you do not wish to use prebuilt capability for QEMU boot, see the Additional Options for
Booting on QEMU.
The --qemu option tells petalinux-boot to boot QEMU instead of real hardware.
• The --prebuilt 1 performs a Level 1 (FPGA bitstream) boot. This option is not valid for
QEMU.
Starting udev
[ 6.231116] udevd[171]: starting version 3.2.8
[ 6.239333] random: udevd: uninitialized urandom read (16 bytes read)
[ 6.245844] random: udevd: uninitialized urandom read (16 bytes read)
[ 6.252367] random: udevd: uninitialized urandom read (16 bytes read)
[ 6.287438] udevd[172]: starting eudev-3.2.8
[ 6.658640] EXT4-fs (sda): ext4_check_descriptors: Block bitmap for
group 880 not in group (block 1838176491)!
[ 6.668737] EXT4-fs (sda): group descriptors corrupted!
[ 6.684560] scsi 2:0:0:0: Direct-Access Sony Storage Media
PMAP PQ: 0 ANSI: 6
[ 6.728123] FAT-fs (mmcblk0p1): Volume was not properly unmounted.
Some data may be corrupt. Please run fsck.
[ 6.835063] cramfs: Unknown parameter 'umask'
[ 6.847623] FAT-fs (sda1): Volume was not properly unmounted. Some
data may be corrupt. Please run fsck.
[ 6.881627] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)
Wed May 27 01:23:03 UTC 2020
(This may take several minutes. Please do not power off the machine.)
source ptp0
[ 7.349678] macb ff0e0000.ethernet: gem-ptp-timer ptp clock
registered.
udhcpc: started, v1.31.0
udhcpc: sending discover
done.
haveged: haveged: ver: 1.9.5; arch: generic; vend: ; build: (gcc 9.2.0
CTV); collect: 128K
haveged: haveged: cpu: (VC); data: 16K (D); inst: 16K (D); idx: 11/40;
sz: 15456/64452
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCobZGi0OV/
ajCzeowFZ6TeEcJERNytVMWW2+F/
cHeqKnAQWrBrU4Wd7VxS4i5er5CVCUs59isTG9WidFUaVuBYJGLsC6lK/
lkHBojGuAa4Tsll4CkcpemSC2ERknqvOctRWEGJUJCKTc3lxmsYg9qklG/
dpUltXte5xedFQjt9DX4QRbgcHuslMXNGa9ARzqOz5oYPKTU6ZOAOoWdQcPHkCfnCPnMfURWj
zgeFH73MnMkJfxrnr+5c6n/H69mL/btzXUEtN4IZYQodkZrx/XMn33Ac/
d6Dg2JuvUOr4BivpEUpwS0Sw+jPi0vrFPQMYSg52Evm+Weie25t5uFA6xkh root@xilinx-
zcu102-2020_1
Fingerprint: sha1!!
e6:30:61:30:67:11:cf:5a:92:48:64:ca:ed:e5:02:f0:a1:ed:35:4f
dropbear.
Starting tcf-agent: OK
Password:
root
root@xilinx-zcu102-2020_1:~#
root@xilinx-zcu102-2020_1:~#
2. Log in to target with the default user name root and password root.
Note: For Zynq UltraScale+ MPSoC kernel boot, create a pre-built/linux/images/ folder and copy
pmu_rom_qemu_sha3.elf from any Zynq UltraScale+ MPSoC BSP project. You can also pass
pmu_rom_qemu_sha3.elf using --pmu-qemu-args.
cd <plnx-proj-root>
mkdir -p pre-built/linux/images
cp <zynq UltraScale+ bsp project
directory>/pre-built/linux/images/pmu_rom_qemu_sha3.elf pre-built/linux/
images/
or
During start up, the normal Linux boot process ending with a login prompt is displayed as shown
below:
SerialNumber=1
[ 4.952526] usb usb1: Product: xHCI Host Controller
[ 4.957396] usb usb1: Manufacturer: Linux 5.4.0-xilinx-v2020.1 xhci-hcd
[ 4.964001] usb usb1: SerialNumber: xhci-hcd.0.auto
[ 4.969138] hub 1-0:1.0: USB hub found
[ 4.972904] hub 1-0:1.0: 1 port detected
[ 4.977017] xhci-hcd xhci-hcd.0.auto: xHCI Host Controller
[ 4.982500] xhci-hcd xhci-hcd.0.auto: new USB bus registered, assigned
bus number 2
[ 4.990157] xhci-hcd xhci-hcd.0.auto: Host supports USB 3.0 SuperSpeed
[ 4.996882] usb usb2: New USB device found, idVendor=1d6b,
idProduct=0003, bcdDevice= 5.04
[ 5.005145] usb usb2: New USB device strings: Mfr=3, Product=2,
SerialNumber=1
[ 5.012362] usb usb2: Product: xHCI Host Controller
[ 5.017231] usb usb2: Manufacturer: Linux 5.4.0-xilinx-v2020.1 xhci-hcd
[ 5.023839] usb usb2: SerialNumber: xhci-hcd.0.auto
[ 5.028941] hub 2-0:1.0: USB hub found
[ 5.032703] hub 2-0:1.0: 1 port detected
[ 5.037687] pca953x 0-0020: 0-0020 supply vcc not found, using dummy
regulator
[ 5.045615] pca953x 0-0021: 0-0021 supply vcc not found, using dummy
regulator
[ 5.061251] i2c i2c-0: Added multiplexed i2c bus 3
[ 5.072158] i2c i2c-0: Added multiplexed i2c bus 4
[ 5.088893] random: fast init done
[ 5.097250] ata1: SATA link down (SStatus 0 SControl 330)
[ 5.123459] i2c i2c-0: Added multiplexed i2c bus 5
[ 5.128360] i2c i2c-0: Added multiplexed i2c bus 6
[ 5.133154] pca954x 0-0075: registered 4 multiplexed busses for I2C mux
pca9544
[ 5.140480] cdns-i2c ff020000.i2c: 400 kHz mmio ff020000 irq 32
[ 5.148171] at24 7-0054: 1024 byte 24c08 EEPROM, writable, 1 bytes/write
[ 5.154899] i2c i2c-1: Added multiplexed i2c bus 7
[ 5.159894] i2c i2c-1: Added multiplexed i2c bus 8
[ 5.167399] si570 9-005d: registered, current frequency 300000000 Hz
[ 5.173780] i2c i2c-1: Added multiplexed i2c bus 9
[ 5.193293] si570 10-005d: registered, current frequency 148500000 Hz
[ 5.199762] i2c i2c-1: Added multiplexed i2c bus 10
[ 5.204837] si5324 11-0069: si5328 probed
[ 5.263052] ata2: SATA link up 3.0 Gbps (SStatus 123 SControl 330)
[ 5.268669] si5324 11-0069: si5328 probe successful
[ 5.274124] i2c i2c-1: Added multiplexed i2c bus 11
[ 5.279126] i2c i2c-1: Added multiplexed i2c bus 12
[ 5.284115] i2c i2c-1: Added multiplexed i2c bus 13
[ 5.289112] i2c i2c-1: Added multiplexed i2c bus 14
[ 5.293993] pca954x 1-0074: registered 8 multiplexed busses for I2C
switch pca9548
[ 5.301875] i2c i2c-1: Added multiplexed i2c bus 15
[ 5.306869] i2c i2c-1: Added multiplexed i2c bus 16
[ 5.307741] ata2.00: ATA-7: ST3160812AS, 3.ADH, max UDMA/133
[ 5.311866] i2c i2c-1: Added multiplexed i2c bus 17
[ 5.317389] ata2.00: 312500000 sectors, multi 0: LBA48 NCQ (depth 32)
[ 5.328880] i2c i2c-1: Added multiplexed i2c bus 18
[ 5.333886] i2c i2c-1: Added multiplexed i2c bus 19
[ 5.338881] i2c i2c-1: Added multiplexed i2c bus 20
[ 5.343880] i2c i2c-1: Added multiplexed i2c bus 21
[ 5.348874] i2c i2c-1: Added multiplexed i2c bus 22
[ 5.353752] pca954x 1-0075: registered 8 multiplexed busses for I2C
switch pca9548
[ 5.361338] cdns-i2c ff030000.i2c: 400 kHz mmio ff030000 irq 33
[ 5.366050] ata2.00: configured for UDMA/133
[ 5.370930] cdns-wdt fd4d0000.watchdog: Xilinx Watchdog Timer with
timeout 60s
[ 5.371767] scsi 1:0:0:0: Direct-Access ATA ST3160812AS
H PQ: 0 ANSI: 5
[ 5.378957] cdns-wdt ff150000.watchdog: Xilinx Watchdog Timer with
timeout 10s
[ 5.387232] sd 1:0:0:0: [sda] 312500000 512-byte logical blocks: (160 GB/
149 GiB)
[ 5.394415] cpufreq: cpufreq_online: CPU0: Running at unlisted freq:
1199880 KHz
[ 5.401532] sd 1:0:0:0: [sda] Write Protect is off
[ 5.408945] cpufreq: cpufreq_online: CPU0: Unlisted initial frequency
changed to: 1199999 KHz
[ 5.422230] sd 1:0:0:0: [sda] Write cache: enabled, read cache: enabled,
doesn't support DPO or FUA
[ 5.431292] usb 2-1: new SuperSpeed Gen 1 USB device number 2 using xhci-
hcd
[ 5.464062] sda: sda1
[ 5.467101] sd 1:0:0:0: [sda] Attached SCSI disk
[ 5.467629] mmc0: SDHCI controller on ff170000.mmc [ff170000.mmc] using
ADMA 64-bit
[ 5.482267] input: gpio-keys as /devices/platform/gpio-keys/input/input0
[ 5.489346] rtc_zynqmp ffa60000.rtc: setting system clock to
2020-05-27T01:17:28 UTC (1590542248)
[ 5.498217] of_cfs_init
[ 5.500678] of_cfs_init: OK
[ 5.503618] cfg80211: Loading compiled-in X.509 certificates for
regulatory database
[ 5.551387] mmc0: new high speed SDHC card at address aaaa
[ 5.557013] usb 2-1: New USB device found, idVendor=054c,
idProduct=09c2, bcdDevice= 1.00
[ 5.565192] usb 2-1: New USB device strings: Mfr=1, Product=2,
SerialNumber=3
[ 5.572322] usb 2-1: Product: Storage Media
[ 5.576496] usb 2-1: Manufacturer: Sony
[ 5.580325] usb 2-1: SerialNumber: 5C07104BE28C15CF00
[ 5.585676] mmcblk0: mmc0:aaaa SL16G 14.8 GiB
[ 5.592325] usb-storage 2-1:1.0: USB Mass Storage device detected
[ 5.598452] mmcblk0: p1 p2
[ 5.601833] scsi host2: usb-storage 2-1:1.0
[ 5.640394] cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'
[ 5.646922] clk: Not disabling unused clocks
[ 5.651189] ALSA device list:
[ 5.654141] #0: DisplayPort monitor
[ 5.658099] platform regulatory.0: Direct firmware load for
regulatory.db failed with error -2
[ 5.666706] cfg80211: failed to load regulatory.db
[ 5.841844] EXT4-fs (mmcblk0p2): recovery complete
[ 5.850361] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data
mode. Opts: (null)
[ 5.855064] [drm] Cannot find any crtc or sizes
[ 5.858490] VFS: Mounted root (ext4 filesystem) on device 179:2.
[ 5.869011] devtmpfs: mounted
[ 5.872150] Freeing unused kernel memory: 704K
[ 5.876626] Run /sbin/init as init process
Starting udev
[ 6.231116] udevd[171]: starting version 3.2.8
[ 6.239333] random: udevd: uninitialized urandom read (16 bytes read)
[ 6.245844] random: udevd: uninitialized urandom read (16 bytes read)
[ 6.252367] random: udevd: uninitialized urandom read (16 bytes read)
[ 6.287438] udevd[172]: starting eudev-3.2.8
(This may take several minutes. Please do not power off the machine.)
done.
haveged: haveged: ver: 1.9.5; arch: generic; vend: ; build: (gcc 9.2.0
CTV); collect: 128K
haveged: haveged: cpu: (VC); data: 16K (D); inst: 16K (D); idx: 11/40; sz:
15456/64452
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCobZGi0OV/ajCzeowFZ6TeEcJERNytVMWW2+F/
cHeqKnAQWrBrU4Wd7VxS4i5er5CVCUs59isTG9WidFUaVuBYJGLsC6lK/
lkHBojGuAa4Tsll4CkcpemSC2ERknqvOctRWEGJUJCKTc3lxmsYg9qklG/
dpUltXte5xedFQjt9DX4QRbgcHuslMXNGa9ARzqOz5oYPKTU6ZOAOoWdQcPHkCfnCPnMfURWjzge
FH73MnMkJfxrnr+5c6n/H69mL/btzXUEtN4IZYQodkZrx/XMn33Ac/
d6Dg2JuvUOr4BivpEUpwS0Sw+jPi0vrFPQMYSg52Evm+Weie25t5uFA6xkh root@xilinx-
zcu102-2020_1
Fingerprint: sha1!!
e6:30:61:30:67:11:cf:5a:92:48:64:ca:ed:e5:02:f0:a1:ed:35:4f
dropbear.
Starting tcf-agent: OK
Password:
root
root@xilinx-zcu102-2020_1:~#
root@xilinx-zcu102-2020_1:~#
You may see slightly different output from the above example depending on the Linux image you
test and its configuration.
Login to the virtual system when you see the login prompt on the emulator console with the
login root and password root. Try Linux commands such as ls, ifconfig, cat/proc/
cpuinfo and so on. They behave the same as on real hardware. To exit the emulator when you
are finished, press Ctrl + A, release, and then press X.
The petalinux-boot tool can also boot a specific Linux image using the image option (-i or
--image):
For example:
Device Trees (DTB files) are used to describe the hardware architecture and address map to the
Linux kernel. The PetaLinux system emulator also uses DTB files to dynamically configure the
emulation environment to match your hardware platform.
If no DTB file option is provided, petalinux-boot extracts the DTB file from the given
image.elf for MicroBlaze processors and from <plnx-proj-root>/images/linux/
system.dtb for Zynq-7000 devices and Zynq UltraScale+ MPSoC. Alternatively, you can use
the --dtb option as follows:
Note: QEMU version has been upgraded to 4.2. The old options are deprecated in the new version but
remain functionally operational. Since PetaLinux tools still use the old options, warning messages are
displayed. You can ignore them.
This section is for Zynq® UltraScale+™ MPSoC and Zynq-7000 devices only because they allow
you to boot from SD cards.
Prerequisites
This section assumes that the following prerequisites have been satisfied:
• You have installed PetaLinux Tools on the Linux workstation. If you have not installed, see the
Installation Steps.
• You have installed PetaLinux BSP on the Linux workstation. If you have not installed, see the
PetaLinux BSP Installation.
• A serial communication program such as minicom/kermit/gtkterm has been installed; the baud
rate of the serial communication program has been set to 115200 bps.
9. You should see a boot messages similar to the following message on the serial console:
[ 7.741083] cfg80211: Loading compiled-in X.509 certificates for
regulatory database
[ 7.882290] cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'
[ 7.888818] clk: Not disabling unused clocks
[ 7.893083] ALSA device list:
[ 7.896040] #0: DisplayPort monitor
[ 7.899994] platform regulatory.0: Direct firmware load for
regulatory.db failed with error -2
[ 7.908610] cfg80211: failed to load regulatory.db
[ 7.913597] Freeing unused kernel memory: 704K
[ 7.931199] Run /init as init process
Starting udev
[ 8.026549] mmc0: new high speed SDHC card at address aaaa
[ 8.032550] mmcblk0: mmc0:aaaa SP32G 29.7 GiB
[ 8.038229] udevd[167]: starting version 3.2.8
[ 8.039893] mmcblk0: p1
[ 8.042979] random: udevd: uninitialized urandom read (16 bytes read)
[ 8.051695] random: udevd: uninitialized urandom read (16 bytes read)
[ 8.058197] random: udevd: uninitialized urandom read (16 bytes read)
[ 8.067225] usb 2-1: new SuperSpeed Gen 1 USB device number 2 using
xhci-hcd
[ 8.069110] udevd[169]: starting eudev-3.2.8
[ 8.075194] [drm] Cannot find any crtc or sizes
[ 8.091909] usb 2-1: New USB device found, idVendor=0781,
idProduct=5580, bcdDevice= 0.10
[ 8.100109] usb 2-1: New USB device strings: Mfr=1, Product=2,
SerialNumber=3
[ 8.107248] usb 2-1: Product: Extreme
[ 8.110900] usb 2-1: Manufacturer: SanDisk
[ 8.114988] usb 2-1: SerialNumber: AA010104131512483744
[ 8.121414] usb-storage 2-1:1.0: USB Mass Storage device detected
[ 8.128190] scsi host2: usb-storage 2-1:1.0
[ 8.152664] zynqmp_r5_remoteproc ff9a0000.zynqmp-rpu: RPU core_conf:
split
[ 8.162198] remoteproc remoteproc0: r5@0 is available
[ 8.455632] mali: loading out-of-tree module taints kernel.
[ 8.960540] cramfs: Unknown parameter 'umask'
[ 8.971664] FAT-fs (sda1): Volume was not properly unmounted. Some
data may be corrupt. Please run fsck.
[ 8.981200] vfat filesystem being mounted at /run/media/sda1 supports
timestamps until 2107 (0x10391447e)
[ 9.139803] scsi 2:0:0:0: Direct-Access SanDisk Extreme
0001 PQ: 0 ANSI: 6
[ 9.149297] sd 2:0:0:0: [sdb] 62533296 512-byte logical blocks: (32.0
GB/29.8 GiB)
[ 9.157860] sd 2:0:0:0: [sdb] Write Protect is off
[ 9.163586] sd 2:0:0:0: [sdb] Write cache: disabled, read cache:
enabled, doesn't support DPO or FUA
[ 9.198380] sdb: sdb1
[ 9.204317] sd 2:0:0:0: [sdb] Attached SCSI removable disk
Configuring packages on first boot....
(This may take several minutes. Please do not power off the machine.)
done.
Starting Dropbear SSH server: Generating 2048 bit rsa key, this may take
a while...
haveged: haveged: ver: 1.9.5; arch: generic; vend: ; build: (gcc 9.2.0
CTV); collect: 128K
haveged: haveged: cpu: (VC); data: 16K (D); inst: 16K (D); idx: 11/40;
sz: 15456/64452
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCq0ua7bEdUb0PHmF3f8HVbpcLq/
ahhMCFrQZsgK2UpDmkoMAMMsYRwna2Qog1WlFmaBmIhUT8OI3nVApVc21I7q35Yd2PcAmyeVX
ZqCnYUriaae7hGrwpRgMNq48ixiWqcf7OXCnLSQ5GI8eJjeV5JMHwvlpuU0mnSkFFbx46UnL1
N7b+qMxz9FTTLQBIWS/PUZTTewZs+hKExv8OGZE1T46YdmrY89zc
+6of9c5NMdhGtD5fy7RRKY28fnUQ3wkN7ensLcJhVkWfrUyDVOoh2Th/
gh2D6RBAkMwxdnLUmdMrP8tbyGOxY0stM+9pO2t7qn6cvT9wHx7ekUaS/zqaR
root@xilinx-zcu102-2020_1
Fingerprint: sha1!!
c7:b9:cd:c4:a8:0a:b9:a8:ec:7b:a6:b1:55:a8:29:79:68:15:00:05
dropbear.
Starting tcf-agent: OK
root
root@xilinx-zcu102-2020_1:~#
TIP: If you wish to stop auto-boot, hit any key when you see the messages similar to the following on the
console: Hit any key to stop autoboot:
10. Type user name root and password root on the serial console to log into the PetaLinux
system.
Troubleshooting
This section describes some common issues you may experience while booting a PetaLinux
image on hardware with SD card.
TIP: To know more about U-Boot options, use the command: $ U-Boot-PetaLinux> printenv.
JTAG boot communicates with XSDB which in turn communicates with hw_server. The TCP port
used is 3121; ensure that the firewall is disabled for this port.
Prerequisites
This section assumes that the following prerequisites have been satisfied:
• You have a PetaLinux system image by either installing a PetaLinux BSP (see PetaLinux BSP
Installation) or by building your own PetaLinux project (see Build System Image).
• If you wish to make use of prebuilt capability for JTAG boot. You need to have packaged
prebuilt images (see Packaging Prebuilt Images).
• A serial communication program such as minicom/kermit/gtkterm has been installed; the baud
rate of the serial communication program has been set to 115200 bps.
• Appropriate JTAG cable drivers have been installed.
The --jtag option tells petalinux-boot to boot on hardware via JTAG, and the --
prebuilt 3 option boots the Linux kernel. Wait for the appearance of the shell prompt on
the command console to indicate completion of the command.
Note: To know more about different boot levels for prebuilt option, see Using petalinux-boot
Command with Prebuilt Images.
The example of the message on the workstation command console for successful
petalinux-boot is:
NOTICE: ATF running on XCZU9EG/silicon v4/RTL5.1 at 0xfffea000
NOTICE: BL31: v2.2(release):v1.1-5588-g5918e656e
NOTICE: BL31: Built : 22:53:26, May 26 2020
NAND: 0 MiB
MMC: mmc@ff170000: 0
In: serial@ff000000
Out: serial@ff000000
Err: serial@ff000000
Bootmode: JTAG_MODE
Reset reason: SRST
Net:
ZYNQ GEM: ff0e0000, mdio bus ff0e0000, phyaddr 12, interface rgmii-id
By default, network settings for PetaLinux reference designs are configured using DHCP. The
output you see may be slightly different from the above example, depending on the
PetaLinux reference design being tested.
9. Type user name: root and password: root on the serial console to log into the PetaLinux
system.
10. Determine the IP address of the PetaLinux system by running ifconfig on the system console.
The above command downloads the bitstream and then download the U-Boot image.
• To see the verbose output of JTAG boot with -v option:
$ petalinux-boot --jtag --u-boot -v
$ cd <plnx-proj-root>
$ petalinux-boot --jtag --prebuilt 3 --tcl test.txt
Troubleshooting
This section describes some common issues you may experience while booting a PetaLinux
image on hardware with JTAG.
TFTP boot saves a lot of time because it is much faster than booting through JTAG and you do
not have to flash the image for every change in kernel source.
Prerequisites
This section assumes that the following prerequisites have been satisfied:
• Host environment with TFTP server is setup and PetaLinux Image is built for TFTP boot. For
more information, see Configure TFTP Boot.
• You have packaged prebuilt images. For more information, see Packaging Prebuilt Images.
• A serial communication program such as minicom/kermit/gtkterm has been installed; the baud
rate of the serial communication program has been set to 115200 bps.
• Ethernet connection is setup properly between Host and Linux Target.
• Appropriate JTAG cable drivers have been installed.
The --jtag option tells petalinux-boot to boot on hardware via JTAG, and the
--prebuilt 2 option downloads the prebuilt bitstream (FSBL for Zynq UltraScale+
MPSoCs and Zynq-7000 devices) to target board, and then boot prebuilt U-Boot on target
board.
9. When autoboot starts, hit any key to stop it.
The example of a workstation console output for successful U-Boot download is:
Xilinx Zynq MP First Stage Boot Loader
Release 2020.1 Apr 27 2020 - 08:55:54
NOTICE: ATF running on XCZU9EG/silicon v4/RTL5.1 at 0xfffea000
NOTICE: BL31: v2.2(release):xilinx-v2019.2-1739-gbf72e4d49
NOTICE: BL31: Built : 10:12:17, Apr 27 2020
0
ZynqMP>
ZynqMP>
10. Check whether the TFTP server IP address is set to the IP Address of the host where the
image resides. This can be done using the following command:
ZynqMP> print serverip
11. Set the server IP address to the host IP address using the following commands:
ZynqMP> set serverip <HOST IP ADDRESS>; saveenv
Troubleshooting
Table 12: PetaLinux Image on Hardware with TFTP
BSP Packaging
BSPs are useful for distribution between teams and customers. Customized PetaLinux project
can be shipped to next level teams or external customers through BSPs. This section explains,
with an example, how to package a BSP with PetaLinux project.
Prerequisites
This section assumes that you have PetaLinux Tools software platform ready for building a Linux
system customized to your hardware platform. For more information, see Importing Hardware
Configuration.
1. You can go outside the PetaLinux project directory to run petalinux-package command.
2. Use the following commands to package the BSP.
$ petalinux-package --bsp -p <plnx-proj-root> --output MY.BSP
This generates MY.BSP, including the following elements from the specified project:
• <plnx-proj-root>/project-spec/
• <plnx-proj-root>/config.project
• <plnx-proj-root>/.petalinux/
• <plnx-proj-root>/pre-built/
• <plnx-proj-root>/.gitignore
• <plnx-proj-root>/components
It does not modify the specified PetaLinux project <plnx-proj-root>. It puts the specified
hardware project source to <plnx-proj-root>/hardware/ inside MY.BSP archive.
2. Exclude workspace changes
The default petalinux-package --bsp command checks for sources in components/
plnx-workspace/sources directory and applies those changes to the meta-user layer. To
skip this, use --exclude-workspace as shown in the following code snippet:
$ petalinux-packge --bsp -p <plnx-proj-root> --exclude-workspace
Alternatively, you can clean the project before executing the petalinux-package --bsp
command as shown below.
$ petalinux-build -x mrproper -f
The support for search path is obsolete. It is your responsibility to copy the external sources
under <plnx-proj-root>/components/ext_sources. For more information, see Using
External Kernel and U-Boot with PetaLinux.
Chapter 6
petalinux-upgrade Options
Table 13: petalinux-upgrade Options
The petalinux-upgrade command resolves this issue by upgrading the system software
components without changing the host tool components. The system software components are
upgraded in two steps: first, by upgrading the installed PetaLinux tool, and then by upgrading
existing PetaLinux projects. This allows you to upgrade without having to install the latest
version of the Vivado hardware project or Vitis software platform.
2. Change into the directory of your installed PetaLinux tool using cd <plnx-tool>.
3. Type: source settings.sh.
4. Enter command: petalinux-upgrade -f <downloaded sdkupdate path>.
Example:
petalinux-upgrade -f “/scratch/ws/upgrade-workspace/sdkupdate”
2. Go to installed tool.
3. Type: source settings.sh.
4. Enter command: petalinux-upgrade -u <url>.
Example:
petalinux-upgrade -u “http://petalinux.xilinx.com/sswreleases/rel-v2020/
sdkupdate/”
To upgrade the eSDKs for all (Zynq devices, Zynq UltraScale+ MPSoC, microblaze_lite,
microblaze_full).
1. Run petalinux-build -x mrproper in the existing project before upgrading the tool.
2. Upgrade the tool. To upgrade from local file, see Upgrade from Local File. To upgrade from
remote server, see Upgrade from Remote Server.
3. Go to the PetaLinux project you want to upgrade.
4. Enter either petalinux-build or petalinux-config to upgrade the project with all
new system components.
5. When asked to upgrade the eSDK, please select y to extract the new eSDK as shown below.
WARNING: Your Yocto SDK was changed in tool.
Please input "y" to proceed the installing SDK into project, "n" to
exit:y
Use Cases
Chapter 7
Prerequisites
This section assumes that you have PetaLinux Tools software platform ready for building a Linux
system customized to your hardware platform. For more information, see the Importing
Hardware Configuration.
Prerequisites
This section assumes that you have PetaLinux Tools software platform ready for building a Linux
system customized to your hardware platform. For more information, see the Importing
Hardware Configuration.
Prerequisites
This section assumes that you have PetaLinux Tools software platform ready for building a Linux
system customized to your hardware platform. For more information, see the Importing
Hardware Configuration.
3. Select Subsystem AUTO Hardware Settings → Advanced Bootable Images Storage Settings.
4. In the Advanced Bootable Images Storage Settings submenu, you have the following options:
• Boot image settings (BOOT.BIN which includes FSBL, PMU, and ATF for Zynq®
UltraScale+™ MPSoC)
Select boot device as per requirement.
○ To set flash as the boot device, select primary flash.
• Image name
The default kernel image is fitimage (image.ub).
You can change the kernel image (Image) using this menuconfig option.
• jffs2 RootFS image settings
• DTB settings
Troubleshooting
This section describes some common issues you may experience while working with boot device
configuration.
The PetaLinux tools uses the start address for parallel flash or start offset for SPI flash and the
size of the above partitions to generate the following U-Boot commands:
• update_boot if the boot image, which is a U-Boot image for MicroBlaze™ processors and a
BOOT.BIN image for Zynq®-7000 devices, is selected to be stored in the primary flash.
• update_kernel and load_kernel if the kernel image, which is the FIT image image.ub,
is selected to be stored in the flash.
By default, the FIT image is composed of kernel image, DTB, and RootFS image.
Prerequisites
This section assumes that you have PetaLinux Tools software platform ready for building a Linux
system customized to your hardware platform. For more information, see the Importing
Hardware Configuration.
1. Launch the root file system configuration menu using the following command:
$ cd <plnx-proj-root>
$ petalinux-config -c rootfs
Inclusion of extra configuration items and file system packages lead to increase in the kernel
image size and the root file system size respectively.
If kernel or the root file system size increases and is greater than 128 MB, you need to do the
following:
a. Mention the Bootm length in <plnx-proj-root>/project-spec/meta-user/
recipes-bsp/u-boot/files/platform-top.h.
#define CONFIG_SYS_BOOTM_LEN <value greater than image size>
Prerequisites
This section assumes that you have created a new PetaLinux project (see Creating an Empty
Project from a Template) and imported the hardware platform (see Importing Hardware
Configuration).
Prerequisites
This section assumes that you have created a new PetaLinux project (see Creating an Empty
Project from a Template) and imported the hardware platform (see Importing Hardware
Configuration).
IMPORTANT! The default mode in the PetaLinux BSP is the INITRD mode.
TFTP boot saves a lot of time because it is much faster than booting through JTAG and you do
not have to flash the image for every change in kernel source.
Prerequisites
This section assumes that the following prerequisites have been satisfied:
• You have created a new PetaLinux project (see Creating an Empty Project from a Template)
and imported the hardware platform (see Importing Hardware Configuration).
• You have TFTP server running on your host.
The most convenient thing is to mount the entire root file system from the network allowing the
host system and the target to share the same files. The root file system can be modified quickly
and also on the fly (meaning that the file system can be modified while the system is running).
The most common way to setup a system like the one described is through NFS.
Prerequisites
This section assumes that the following prerequisites have been satisfied:
• You have created a new PetaLinux project (see Creating an Empty Project from a Template)
and imported the hardware platform (see Importing Hardware Configuration).
• You have Linux file and directory permissions.
• You have an NFS server setup on your host. Assuming it is set up as /home/NFSshare in this
example.
11. You can see the updated boot arguments only after building.
1. JTAG: In this case, bootloader and kernel is downloaded on to the target through JTAG. For
more information, see Boot a PetaLinux Image on Hardware with JTAG.
TIP: If you want to make use of prebuilt capability to boot with JTAG, package images into prebuilt directory.
For more information, see Packaging Prebuilt Images.
1. tftpboot: In this case, bootloader is downloaded through JTAG and kernel is downloaded on
to the target through tftpboot. For more information, see Boot a PetaLinux Image on
Hardware with TFTP.
2. SD card: In this case, bootloader (BOOT.BIN), bootscript (boot.scr) and kernel image
(image.ub) is copied to the SD card downloaded from the SD card. For more information,
see Boot a PetaLinux Image on Hardware with an SD Card.
Prerequisites
This section assumes that you have created a new PetaLinux project (see Creating an Empty
Project from a Template) and imported the hardware platform (see Importing Hardware
Configuration).
• Write BOOT.BIN.
ZynqMP> sf write 0x80000 0 <size of boot.bin>
• Write image.ub.
ZynqMP>sf write 0x80000 <loading address of kernel> <size of
image.ub>
• Write rootfs.jffs2.
ZynqMP> sf write 0x80000 <loading address of rootfs.jffs2> <size of
rootfs.jffs2>
• Read boot.scr
ZynqMP> tftpboot 0x80000 boot.scr
• Write boot.scr
ZynqMP> sf write 0x80000 <loading address of boot.scr> < size of
boot.scr>
• You have created a new PetaLinux project (see Creating an Empty Project from a Template)
and imported the hardware platform (see Importing Hardware Configuration).
• An SD memory card with at least 4 GB of storage space. It is recommended to use a card with
speed-grade 6 or higher to achieve optimal file transfer performance.
1. The SD card is formatted with two partitions using a partition editor such as gparted.
2. The first partition should be at least 500 MB in size and formatted as a FAT32 file system.
Ensure that there is 4 MB of free space preceding the partition. The first partition contains
the boot loader, device tree, and kernel images. Label this partition as BOOT.
3. The second partition should be formatted as an ext4 files system and can take up the
remaining space on the SD card. This partition stores the system root file system. Label this
partition as RootFS.
4. Copy the files as follows:
FAT partition:BOOT.BIN, boot.scr, and Image
EXT partition: rootfs.tar.gz/rootfs.cpio.gz
For optimal performance ensure that the SD card partitions are 4 MB aligned.
Note: Choose this setting to configure your PetaLinux build for EXT root. By default, it adds the SD/
eMMC device name in bootargs. For other devices (SATA/USB), you must change the ext4 device
name, as shown in the following examples:
6. Build PetaLinux images. For more information, see Build System Image.
7. Generate boot image. For more information, see Generate Boot Image for Zynq UltraScale+
MPSoC.
8. The generated rootfs.tar.gz file is present in images/linux directory. To extract, use
tar xvf rootfs.tar.gz.
2. Copy BOOT.BIN and image.ub to BOOT partition of SD card. The image.ub file has
device tree and kernel image files.
$ cp images/linux/BOOT.BIN /media/BOOT/
$ cp images/linux/image.ub /media/BOOT/
$ cp images/linux/boot.scr /media/BOOT/
3. Copy rootfs.tar.gz file to the root file system partition of the SD card and extract the
file system.
$ sudo tar xvf rootfs.tar.gz -C /media/rootfs
In order to boot this SD card ext image, see Boot a PetaLinux Image on Hardware with an SD
Card.
Troubleshooting
Table 15: Configuring SD Card ext Filesystem Boot
$ petalinux-package --wic
The following command generates the wic image, petalinux-sdimage.wic, in the images/
linux folder with the default images from the images/linux directory.
$ petalinux-package --wic
The following command packs all bootfiles from the custom-imagespath/ directory.
This generates the wic image with specified files copied into the /boot directory.
Note: Ensure that these files are part of the images directory.
• To copy the uImage file named kernel to the /boot directory, use the following command:
$ petalinux-package --wic --extra-bootfiles "uImage:kernel"
• To copy the default bootfiles and specified bootfiles by user files into the /boot directory, use
the following command:
$ petalinux-package --wic --bootfiles "userfiles/*"
• To copy all the files in the userfiles/ directory to the /boot/user_boot directory, use
the following command:
$ petalinux-package --wic --extra-bootfiles "userfiles/*:user_boot"
Note: Ensure that these files are part of the images directory.
The following command unpacks your custom-rootfs.tar.gz file and copies it to the /
rootfs directory.
The following command copies the image SD card to the EXT4 partition. Alternatively, you can
use the etcher tool or Win32Diskimager from Windows to flash this image.
Chapter 8
If a library is developed outside PetaLinux, you may just want to add the library in the PetaLinux
root file system. In this case, an application template is created to allow copying of the existing
content to target file system.
If the application, library, or module name has ‘_’, see Recipe Name Having ' _ '.
Prerequisites
This section assumes that you have PetaLinux Tools software platform ready for building a Linux
system customized to your hardware platform. For more information, see Importing Hardware
Configuration.
1. Ensure that the pre-compiled code has been compiled for your PetaLinux target architecture,
for example, MicroBlaze™ processors, Arm® cores, etc.
2. Create an application with the following command.
$ petalinux-create -t apps --template install --name mylib --enable
4. Remove existing mylib file, and copy the prebuilt mylib.so into mylib/files directory.
$ rm mylib
$ cp <path-to-prebuilt-mylib.so> ./
5. Create an application and include a prebuilt library into the root file system with a single
command instead of following steps 2, 3, and 4. The following command creates mylib app
and copies mylib.so from <path-to-dir> to mylib/files directory.
$ petalinux-create -t apps --template install --name mylib --srcuri
<path-to-dir>/mylib.so --enable
7. Create an app with remote sources. The following examples will create applications with
specified git/http/https pointing to the srcuri.
$ petalinux-create -t apps -n myapp --enable --srcuri http://
example.tar.gz
8. Edit <plnx-proj-root>/project-spec/meta-user/recipes-apps/mylib/
mylib.bb.
The file should look like the following.
# This file is the libs recipe.
#
SRC_URI = "file://mylib.so \
"
S = "${WORKDIR}"
TARGET_CC_ARCH += "${LDFLAGS}"
do_install() {
install -d ${D}${libdir}
install -m 0655 ${S}/mylib.so ${D}${libdir}
}
FILES_${PN} += "${libdir}"
FILES_SOLIBSDEV = ""
IMPORTANT! You need to ensure that the binary data being installed into the target file system by an install
template application is compatible with the underlying hardware implementation of your system.
This section explains how to include pre-compiled applications to PetaLinux root file system.
Prerequisites
This section assumes that you have PetaLinux tools software platform ready for building a Linux
system customized for your hardware platform. For more information, see Importing Hardware
Configuration.
1. Ensure that the pre-compiled code has been compiled for your PetaLinux target architecture,
for example, MicroBlaze™ processors, Arm® cores etc.
2. Create an application with the following command.
$ petalinux-create -t apps --template install --name myapp --enable
4. Remove existing myapp app and copy the prebuilt myapp into myapp/files directory.
$ rm myapp
$ cp <path-to-prebuilt-app> ./
IMPORTANT! You need to ensure that the binary data being installed into the target file system by an install
template application is compatible with the underlying hardware implementation of your system.
Prerequisites
This section assumes that you have PetaLinux Tools software platform ready for building a Linux
system customized to your hardware platform. For more information, see Importing Hardware
Configuration.
For example:
$ petalinux-create -t apps --template c --name libsample --enable
Note: If the application name has '_', see Recipe Name Having ' _ '.
#
# This file is the libsample recipe.
#
SUMMARY = "Simple libsample application"
SECTION = "libs"
LICENSE = "MIT"
LIC_FILES_CHKSUM ="file://${COMMON_LICENSE_DIR}/
MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRC_URI = "file://libsample.c \
file://libsample.h \
file://Makefile \
"
S = "${WORKDIR}"
PACKAGE_ARCH = "${MACHINE_ARCH}"
PROVIDES = "sample"TARGET_CC_ARCH += "${LDFLAGS}"
do_install() {
install -d ${D}${libdir}
install -d ${D}${includedir}
oe_libinstall -so libsample ${D}${libdir} install -d -m 0655 ${D}$
{includedir}/SAMPLE
install -m 0644 ${S}/*.h ${D}${includedir}/SAMPLE/
}
int function()
{
printf("Hello World!\n");
return 0;
}
void samplelib()
{
printf("Hello, Welcome to PetaLinux -- samplelib !\n");
}
SRC_URI = "file://sampleapp.c \
"
S = "${WORKDIR}"
do_compile() {
${CC} ${CFLAGS} ${LDFLAGS} -o testsamplelib testsamplelib.c -
lsample
}
do_install() {
install -d ${D}${bindir}
install -m 0755 sampleapp ${D}${bindir}
}
FILES_${PN} += "sampleapp"
Prerequisites
This section assumes that you have PetaLinux tools software platform ready for building a Linux
system customized to your hardware platform. For more information, see Importing Hardware
Configuration.
or:
$ petalinux-create -t apps --template c --name myapp --enable
To create a C++ application template, pass the --template c++ option, as follows:
$ petalinux-create -t apps --template c++ --name myapp --enable
Template Description
<plnx-proj-root>/project- spec/meta-user/ Configuration file template - This file controls the
conf/user-rootfsconfig integration of your application into the PetaLinux RootFS
menu configuration. It also allows you select or de-select
the app and its dev, dbg packages into the target root file
system
Makefile Compilation file template - This is a basic Makefile
containing targets to build and install your application
into the root file system. This file needs to be modified
when you add additional source code files to your project.
README A file to introduce how to build the user application.
myapp.c for C; Simple application program in either C or C++, depending
myapp.cpp for C++ upon your choice.
Note: If you want to use the build artifacts for debugging with the third party utilities, add the
following line in <plnx-proj-root>/project-spec/meta-user/conf/petalinuxbsp.conf:
RM_WORK_EXCLUDE += "myapp"
Note: Applications created using the petalinux-create -t apps command have debug symbols
by default in the following path if you comment out rm_work: <plnx-proj>/build/conf/
local.conf.<plnx-proj>/build/tmp/work/aarch64-xilinx-linux/<app-name>/1.0-
r0/packages-split/<app-name>-dbg/usr/bin/.debug/<app-name>.
TIP: Mapping of Make file clean with do_clean in recipe is not recommended. This is because Yocto
maintains its own do_clean.
3. myapp.c/myapp.cpp file can be edited or replaced with the real source code for your
application. If you want to modify your custom user application later, this file should be
edited.
CAUTION! You can delete the app directory if it is no longer required. You must also remove the line:
CONFIG_myapp from <plnx-proj-root>/project-spec/meta-user/conf/user-
rootfsconfig. Deleting the directory by keeping the mentioned line throws an error.
Prerequisites
This section assumes that you have PetaLinux Tools software platform ready for building a Linux
system customized to your hardware platform. For more information, see Importing Hardware
Configuration for more information.
You can use -h or --help to see the usage of the petalinux-create -t modules. The
new module recipe you created can be found in the <plnx-proj-root>/project-spec/
meta-user/recipes-modules/mymodule directory.
Note: If the module name has ‘_’, see Recipe Name Having ' _ '.
Template Description
Makefile Compilation file template - This is a basic Makefile
containing targets to build and install your module into
the root file system. This file needs to be modified when
you add additional source code files to your project. Click
here to customize the make file.
README A file to introduce how to build the user module.
mymodule.c Simple kernel module in C.
<plnx-proj-root>/project- spec/meta-user/ Configuration file template - This file controls the
conf/user-rootfsconfig integration of your application/modules/libs into
the PetaLinux RooFS menu configuration system. It also
allows you to select or de-select the app and its dev, dbg
packages into the target root file system.
3. mymodule.c file can be edited or replaced with the real source code for your module. Later
if you want to modify your custom user module, you are required to edit this file.
Note: If you want to use the build artifacts for debugging with the third party utilities, add the
following line in project-spec/meta-user/conf/petalinuxbsp.conf:
RM_WORK_EXCLUDE += "mymodule"
Note: The modules created with petalinux-create -t modules have debug symbols by default.
CAUTION! You can delete the module directory if it is no longer required. Apart from deleting the module
directory, you have to remove the line: CONFIG_mymodule from <plnx-proj-root>/project-spec/
meta-user/conf/user-rootfsconfig . Deleting the directory by keeping the mentioned line in user-
rootfsconfig throws an error.
Prerequisites
This section assumes that you have included or added custom applications to PetaLinux root file
system (see Creating and Adding Custom Applications).
$ petalinux-build
$ cd <plnx-proj-root>
$ petalinux-build -c rootfs
$ petalinux-build -x package
Other petalinux-build options are explained with --help. Some of the build options are:
This compiles the application. The compiled executable files are in the ${TMPDIR}/work/
aarch64-xilinx-linux/myapp/1.0-r0/ directory.
If you want to use the build artifacts for debugging with the third party utilities, add the line:
RM_WORK_EXCLUDE += "myapp" in <plnx-proj-root>/project-spec/meta-
user/conf/petalinuxbsp.conf. Without this line, the BitBake removes all the build
artifacts after building successfully.
• To see all list of tasks for myapp:
petalinux-build -c myapp -x listtasks
This installs the application into the target the root file system host copy: <TMPDIR>/work/
<MACHINE_NAME>-xilinx-linux/petalinux-image-minimal/1.0-r0/rootfs/.
TMPDIR can be found in petalinux-config → Yocto-settings → TMPDIR. If the project is on
local storage, TMPDIR is <plnx-proj-root>/build/tmp/.
If you want to use the build artifacts for debugging with third party utilities, add the following
line in project-spec/meta-user/conf/petalinuxbsp.conf:
RM_WORK_EXCLUDE += "myapp"
Unless you have changed the location of the user application through its Makefile, the user
application is placed into the /usr/bin directory.
3. Run your user application on the target system console. For example, to run the user
application myapp:
# myapp
If the new application is missing from the target file system, ensure that you have completed the
petalinux-build -x package step as described in the previous section. This ensures that
your application binary is copied into the root file system staging area, and that the target system
image is updated with this new file system.
Prerequisites
This section assumes that you have included or added custom modules to PetaLinux root file
system (see Creating and Adding Custom Kernel Modules).
$ petalinux-build
$ cd <plnx-proj-root>
$ petalinux-build -c rootfs
$ petalinux-build -x package
Other petalinux-build options are explained with --help. Some of the build options are:
This compiles the module. The compiled executable files are placed in <TMPDIR>/work/
<MANCHINE_NAME>-xilinx-linux/mymodule/1.0-r0/ directory.
• To see all list of tasks for this module:
$ petalinux-build -c mymodule -x listtasks
This installs the module into the target the root file system host copy: <TMPDIR>/work/
<MACHINE_NAME>-xilinx-linux/petalinux-image-minimal/1.0-r0/rootfs/.
TMPDIR can be found in petalinux-config → Yocto-settings → TMPDIR. If the project is on
local storage, TMPDIR is <${PROOT}>/build/tmp/.
If you want to use the build artifacts for debugging with third party utilities, add the following
line in project-spec/meta-user/conf/petalinuxbsp.conf:
RM_WORK_EXCLUDE += "mymodule"
Prerequisites
This section assumes that you have PetaLinux tools software platform ready for building a Linux
system customized to your hardware platform. For more information, see Importing Hardware
Configuration.
5. Run petalinux-build.
Prerequisites
This section assumes that you have already added and built the PetaLinux application. For more
information, see Creating and Adding Custom Applications and Building User Applications.
If you have prebuilt application and you have not included in PetaLinux Root file system, see
Including Prebuilt Applications. If you want to create custom application and install it in
PetaLinux Root file system, see Creating and Adding Custom Applications. If your auto run
application is a blocking application which never exits, launch this application as a daemon.
SRC_URI = "file://myapp-init \
"
S = "${WORKDIR}"
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
inherit update-rc.d
INITSCRIPT_NAME = "myapp-init"
INITSCRIPT_PARAMS = "start 99 S ."
do_install() {
install -d ${D}${sysconfdir}/init.d
install -m 0755 ${S}/myapp-init ${D}${sysconfdir}/init.d/myapp-
init
}
FILES_${PN} += "${sysconfdir}/*"
case "$1" in
start)
start; ;;
stop)
stop; ;;
restart)
restart; ;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
exit $?
4. Run petalinux-build.
Adding Layers
You can add layers into the PetaLinux project. The upstream layers for ZEUS version can be
found http://layers.openembedded.org/layerindex/branch/zeus/layers/.
The following steps demonstrate adding the meta-my layer into the PetaLinux project.
Note: 2020.1 PetaLinux is on ZEUS base line. The layers/recipes should be chosen from the ZEUS branch
only. Some of the layers/recipes might not be compatible with our architectures. You are responsible for all
additional layers/recipes.
Note: You can also add a layer that is outside your project; such layers can be shared across projects.
Ensure that the added layer has <layer>/conf/layer.conf; otherwise, it causes build errors.
IMPORTANT! If you want to change the layer priority, you can update ${proot}/project-spec/meta-
mylayer/conf/locallayer.conf to set BBFILE_PRIORITY_meta-mylayer = 6 (0 to 10, higher values
have higher priority).
By default, iperf3 is not in the root file system menuconfig. The following example
demonstrates adding the iperf3 into the root file system menuconfig.
Note: The above procedure is applicable only to the recipes from the existing layers.
IMPORTANT! All recipes which are in petalinux-image-full have sstate locked. To unlock you have to
add SIGGEN_UNLOCKED_RECIPES += "my-recipe" in project-spec/meta-user/conf/
petalinuxbsp.conf.
For example, you have changes to be made in mtd-utils package, so you have created a .bbappend for the same
without SIGGEN_UNLOCKED_RECIPES += "mtd-utils" in project-spec/meta-user/conf/
petalinuxbsp.conf. During project build, you should see the following warning. Your changes for the
package are not included in the build.
For example:
<plnx-proj-root>/components/yocto/layers/meta-petalinux/recipes-core/
packagegroups/packagegroup-petalinux-self-hosted.bb
The name of the package group should be unique and should not conflict with the existing recipe
names.
We can create custom package group, for example, an ALSA package group would look like:
inherit packagegroup
ALSA_PACKAGES = " \
alsa-lib \
alsa-plugins \
alsa-tools \
alsa-utils \
alsa-utils-scripts \
pulseaudio \
"
RDEPENDS_${PN}_append = " \
${ALSA_PACKAGES} \
"
IMAGE_INSTALL_APPEND = "opencv"
CONFIG_opencv
Chapter 9
Debugging
Prerequisites
This section assumes that you have built PetaLinux system image. For more information, see
Build System Image.
2. Watch the QEMU console. You should see the details of the QEMU command. Get the GDB
TCP port from -gdb tcp:<TCP_PORT>.
3. Open another command console (ensuring the PetaLinux settings script has been sourced),
and change to the Linux directory:
$ cd "<plnx-proj-root>/images/linux"
5. Attach to the QEMU target in GDB by running the following GDB command:
(gdb) target remote :9000
7. You can use Ctrl+C to interrupt the kernel and get back the GDB prompt.
8. You can set break points and run other GDB commands to debug the kernel.
CAUTION! If another process is using port 9000, petalinux-boot attempts to use a different port. See the
output of petalinux-boot to determine what port was used. In the following example, port 9001 is used:
INFO: qemu-system-arm ... -gdb tcp::9001 ...
TIP: It may be helpful to enable kernel debugging in the kernel configuration menu (petalinux-config --kernel →
Kernel hacking → Kernel debugging), so that kernel debug symbols are present in the image.
Troubleshooting
This section describes some common issues you may experience while debugging the Linux
kernel in QEMU.
Prerequisites
This section assumes that the following prerequisites have been satisfied:
• Working knowledge of the Vitis™ software platform. For more information, see Vitis Unified
Software Platform Documentation: Embedded Software Development (UG1400).
• The PetaLinux Working Environment is properly set. For more information, see PetaLinux
Working Environment Setup.
• You have created a user application and built the system image including the selected user
application. For more information, see Building User Applications.
5. Packages are in alphabetical order. Navigate to the letter ‘t’, as shown below:
serf --->
sysfsutils --->
sysvinit-inittab --->
tbb --->
tcf-agent --->
texi2html --->
tiff --->
trace-cmd --->
util-macros --->
v4l-utils --->
7. Select console/network submenu, and then click into dropbear submenu. Ensure "dropbear-
openssh-sftp-server" is enabled.
[*] dropbear
c. Provide the Linux host name or IP address in the Host Name field.
d. By default, tcf-agent runs on the 1534 port on the Linux. If you are running tcf-agent on a
different port, update the Port field with the correct port number.
e. In the Application Tab, click Browse and select the project name. The Vitis software
platform automatically fills the information in the application.
f. In the Remote File Path field, specify the path where you want to download the
application in Linux.
g. If your application is expecting some arguments, specify them in the Arguments tab.
h. If your application is expecting to set some environment variables, specify them in the
Environments tab.
i. Click the Debug button. A separate console automatically opens for process standard I/O
operations.
8. The remote file path on the target file system should be the location where the application
can be found. For example, /usr/bin/hello-linux.
9. Select Debug to Apply the configuration and begin the Debug session. (If asked to switch to
Debug Perspective, accept).
Prerequisites
This section assumes that the following prerequisites have been satisfied:
• The PetaLinux Working Environment is properly set. For more information, see PetaLinux
Working Environment Setup.
• You have created a user application and built the system image including the selected user
application. For more information, see Building User Applications.
[X] myapp-dbg
[ ] myapp-dev
6. Select myapp-dbg. Exit the myapp sub-menu.
7. Exit the user packages sub-menu, and select Filesystem Packages → misc → gdb.
8. Select gdb, and ensure that the GDB server is enabled:
[ ] gdb
[ ] gdb-dev
[X] gdbserver
[ ] gdb-dbg
9. Exit the menu and select <Yes> to save the configuration.
10. Rebuild the target system image. Add the below line in <plnx-proj-root>/project-
spec/meta-user/conf/petalinuxbsp.conf.
RM_WORK_EXCLUDE += "myapp"
5. In the GDB console, connect to the target machine using the command:
• Use the IP address of the target system, for example: 192.168.0.10. If you are not sure
about the IP address, run ifconfig on the target console to check.
• Use the port 1534. If you select a different GDB server port number in the earlier step,
use that value instead.
IMPORTANT! If debugging on QEMU, refer to the QEMU Virtual Networking Modes for information regarding
IP and port redirection when testing in non-root (default) or root mode. For example, if testing in non-root mode,
you should use localhost as the target IP in the subsequent steps.
The GDB console attaches to the remote target. The GDB server on the target console
displays the following confirmation, where the host IP is displayed:
Remote Debugging from host 192.168.0.9
6. Before starting the execution of the program, create some breakpoints. Using the GDB
console you can create breakpoints throughout your code using function names and line
numbers. For example, create a breakpoint for the main function:
(gdb) break main
Breakpoint 1 at 0x10000444: file myapp.c, line 10.
7. Run the program by executing the continue command in the GDB console. GDB begins the
execution of the program.
(gdb) continue
Continuing.
Breakpoint 1, main (argc=1, argv=0xbffffe64) at myapp.c:10
10 printf("Hello, PetaLinux World!\n");
8. To print a list of the code at current program location, use the list command.
(gdb) list
5 */
6 #include <stdio.h>
7
8 int main(int argc, char *argv[])
9 {
10 printf("Hello, PetaLinux World!\n");
11 printf("cmdline args:\n");
12 while(argc--)
13 printf("%s\n",*argv++);
14
9. Try the step, next and continue commands. Breakpoints can be set and removed using
the break command. More information on the commands can be obtained using the GDB
console help command.
10. The GDB server application on the target system exits when the program has finished
running. Here is an example of messages shown on the console:
Hello, PetaLinux World!
cmdline args:
/usr/bin/myapp
Child exited with status 0
GDBserver exiting
root@plnx_aarch64:~#
TIP: A .gdbinit file is automatically created to setup paths to libraries. You may add your own GDB
initialization commands at the end of this file.
Troubleshooting
This section describes some common issues you may experience while debugging applications
with GDB.
Table 19: Debugging Zynq UltraScale+ MPSoC Applications with GDB Troubleshooting
FSBL
https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18842019/FSBL#FSBL-
WhatarevariouslevelsofdebugprintsinFSBL
U-Boot
https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18842557/Debug+U-boot
Linux
https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/123011167/Linux+Debug+infrastructure
+KProbe+UProbe+LTTng
https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/123011146/Linux+Debug+infrastructure
+Kernel+debugging+using+KGDB
Chapter 10
Advanced Configurations
Menuconfig Usage
To select a menu/submenu which was deselected before, press the down arrow key to scroll
down the menu or the up arrow key to scroll up the menu. Once the cursor is on the menu, then
press y. To deselect a menu/submenu, follow the same process and press n at the end.
For ATF, U-Boot, and kernel there are three available options:
• External source: When you have a component downloaded at any specified location, you can
feed your component instead of the default one through this configuration option.
Note: The external source folder is required to be unique to a project and its user, but the content can
be modified. If the external source is a git repository, its checked out state should be appropriate for
building this project.
• Remote: If you want to build a component which was on a custom git repository, this
configuration option has to be used.
• pl.dtsi
• system-conf.dtsi
• system-top.dts
• <board>.dtsi
• platform-auto.h
System Processor
The System processor menu specifies the CPU processor on which the system runs.
Memory Settings
The configuration in this menu impacts the memory settings in the device tree and U-Boot
automatic configuration (autoconfig) files.
If manual is selected as the primary memory, you are responsible for ensuring proper memory
settings for the system.
Serial Settings
The Serial Settings sub-menu allows you to select which serial device is the system’s primary
STDIN/STDOUT interface. If manual is selected as the primary serial, you are responsible for
ensuring proper serial interface settings for the system.
Ethernet Settings
If MAC address is programmed into EEPROM, keep this empty here. Refer to the U-Boot
documentation for commands to program EEPROM and to configure for the same.
If manual is selected as the primary Ethernet, you are responsible for ensuring proper Ethernet
settings for the system.
Flash Settings
If manual is selected as the primary flash, you are responsible for the flash settings for the
system.
SD/SDIO Settings
The SD/SDIO Settings sub-menu is for Zynq-7000 devices and Zynq UltraScale+ MPSoC only. It
allows you to select which SD controller is the system’s primary SD card interface.
If manual is selected as the primary flash, you are responsible for the flash settings for the
system.
Timer Settings
The Timer Settings sub-menu is for MicroBlaze processors and Zynq UltraScale+ MPSoC. It
allows you to select which timer is the primary timer.
The Reset GPIO Settings sub-menu is for MicroBlaze processors only. It allows you to select
which GPIO is the system reset GPIO.
TIP: MicroBlaze systems use GPIO as a reset input. If a reset GPIO is selected, you can reboot the system from
Linux.
RTC Settings
Select an RTC instance that is used as a primary timer for the Linux kernel. If your preferred RTC
is not on the list, select manual to enable the proper kernel driver for your RTC.
The advanced bootable images storage settings sub-menu allows you to specify where the
bootable images are located. The settings in this sub-menu are used by PetaLinux to configure U-
Boot.
If this sub-menu is disabled, PetaLinux uses the flash partition table specified in the Flash
Settings sub-menu to define the location of the bootable images.
Default
Bootable Image/U-Boot
Partition Description
Environment Partition
Name
Boot Image boot BOOT.BIN for Zynq-7000 devices and Zynq UltraScale+ MPSoC
Relocatable U-Boot BIN file (u-boot-s.bin) for MicroBlaze
processors
U-Boot Environment Partition bootenv U-Boot environment variable partition. When primary sd is
selected, U-Boot environment is stored in the first partition. When
primary flash is selected, U-Boot environment is stored in the
partition mentioned in flash partition name option.
Kernel Image kernel Kernel image image.ub (FIT format)
DTB Image dtb If "Advanced bootable images storage Settings" is disabled and a
DTB partition is found in the flash partition table settings,
PetaLinux configures U-Boot to load the DTB from the partition
table. Else, it assumes a DTB is contained in the kernel image.
DTG Settings
Figure 7: DTG Settings
Machine Name
For custom boards it is template. For Xilinx® evaluation boards the following values are
supported:
Kernel Bootargs
The Kernel Bootargs sub-menu allows you to let PetaLinux automatically generate the kernel
boot command-line settings in DTS, or pass PetaLinux user defined kernel boot command-line
settings. The following are the default bootargs.
Note: In Zynq UltraScale+ MPSoC, if you want to see kernel panic prints on console, add earlycon
console=<device>,<baud rate> clk_ignore_unused root=/dev/ram0 rw. Example:
earlycon console=/dev/ttyPS0,115200 clk_ignore_unused root=/dev/ram0 rw in
system_user.dtsi.
Device Tree Overlay Configuration for Zynq-7000 Devices and Zynq UltraScale+
MPSoC
Select this option to separate pl from base DTB and build the pl.dtsi to generate pl.dtbo.
After creating a PetaLinux project follow the below steps to add overlay support:
FPGA manager overrides all the options. This come into play only when FPGA manager is not
selected.
Note: The bit/bin file name should be same as the firmware name specified in pl.dtsi
(design_1_wrapper.bit.bin).
Select this configuration option to skip PL nodes if the user does not depend on the PL IPs. Also,
if any PL IP in DTG generates an error then you can simply enable this flag and the DTG will not
generate any PL nodes.
Note: FPGA manager overrides all these options. This come into play only when FPGA manager is not
selected.
Note: If you select both device tree overlay and remove PL from device tree, then base DTB has entry for
overlay support but there is no PL DTBO generated.
• FSBL compilation Settings: You can put multiple settings there, separated with space. For
example: -DFSBL_PROT_BYPASS.
After creating a PetaLinux project for Zynq UltraScale+ MPSoC, follow the following steps to
build FPGA manager support:
1. Go to cd <plnx-proj-root>.
2. In the petalinux-config command, select FPGA Manager → [*] Fpga Manager.
Note: PetaLinux FPGA manager configuration when selected:
2. Packs bitstreams in .bin form and dtbos to the /lib/firmware/base directory in the root file
system.
3. The BOOT.BIN generated using petalinux-package command does not have bitstream.
3. Specify extra hardware files in FPGA Manager → Specify hardware directory path.
Note: This step is optional. It is required only if multiple bitstreams for same PS and corresponding
dtbos, need to be packed into the root file system. It generates and pack bitstream in .bin form and its
dtbo in the RootFS at /lib/firmware/<XSA name>. Ensure that PS design is same for XSA at hw
directory path and <plnx-proj-root>/project-spec/hw-description/system<.xsa>.
4. Run petalinux-build.
Time taken to load DTBO is 239.000000 milli seconds. DTBO loaded through
ZynqMP FPGA manager successfully.
Time taken to load BIN is 213.000000 milli seconds. BIN FILE loaded through
zynqMP FPGA manager successfully.
See help section for more option: root@xilinx-zcu102-2020_1:~# fpgautil -h. For
more information, see http://www.wiki.xilinx.com/Solution+ZynqMP+PL+Programming.
Adding Custom dtsi and bit Files to the FPGA Manager for
Zynq-7000 Devices and Zynq UltraScale+ MPSoCs
This section provides the mechanism and infrastructure required to work with readily (hand-
stitched) available dtsi files instead of relying on the XSA to generate them when the FPGA
manager is enabled. This generates the dtbo and bin files and copies them into the
rootfs /lib/firmware directory and loads them when the system boots.
To stop loading the dtbo and .bin files at system boot, add FPGA_INIT = "0" to the
<project-root-dir>/project-spec/meta-user/recipes-apps/can-interface/
can-interface.bb file.
U-Boot Configuration
The U-Boot configuration sub-menu allows you to select a U-Boot automatic configuration
(autoconfig) by PetaLinux or a U-Boot board configuration target.
By default, PetaLinux uses the board configuration "other". If you want configurations from
design, select PetaLinux u-boot config.
TIP: The petalinux-build tool always generates a FIT image as the kernel image.
Note: You can add extra spaces in the root file system by adding value to this variable<project>/
project-spec/meta-user/conf/petalinuxbsp.conf IMAGE_ROOTFS_EXTRA_SPACE.
TIP: The host name does not get updated. Please see Xilinx Answer 69122 for more details.
Yocto Settings
Yocto settings allows you to configure various Yocto features available in a project.
Parameter Description
TMPDIR Location This directory is used by BitBake to store logs and build artifacts
YOCTO_MACHINE_NAME Specifies the Yocto machine name for the project
Parallel thread execution To limit the number of threads of BitBake instances
Add pre-mirror url Adds mirror sites for downloading source code of components
Local sstate feeds settings To use local sstate cache at a specific location
Enable Network sstate feeds Enabled NW sstate feeds
User layers Adds user layers into projects
BB_NO_NETWORK When enabled, internet access is disabled on the build machine
Prerequisites
This section assumes that the following prerequisites have been satisfied:
• You have PetaLinux Tools software platform ready for building a Linux system customized to
your hardware platform. For more information, see Importing Hardware Configuration.
• Internet connection with git access is available.
For U-Boot, select Remote U-Boot settings → Remote u-boot git URL and enter git URL for
U-Boot. For example:
git://github.com/Xilinx/u-boot-xlnx.git;protocol=https
Once a remote git link is provided, you must provide any of the following values for "git TAG/
Commit ID" selection, otherwise an error message is expected.
You have to set any of the following values to this setting, otherwise an error message
appears.
• To point to HEAD of repository of the currently checked out branch:
${AUTOREV}
Once you select git Tag/Commit ID, you can see a prompt to enter a string value as shown
in the following figure. Enter any of the above set values.
Note: When creating a BSP with external sources in project, it is your responsibility to copy the sources
into the project and do the packing. For more information, see BSP Packaging.
IMPORTANT! It is not mandatory to have external sources under components/ . You can specify any
location outside the project as well. However, while packaging the BSP, you are responsible for copying the
external sources into components/ and setting relative path.
Note: If the external source is a git repo, its checked out state must be appropriate for the project that is
being built.
Troubleshooting
This section describes some common issues you may experience while configuring out-of-tree
build.
IMPORTANT! Only Xilinx® drivers or optimizations in the Linux kernel configuration are supported by Xilinx
technical support. For more information on Xilinx drivers for Linux, see https://xilinx-wiki.atlassian.net/wiki/
spaces/A/pages/18841873/Linux+Drivers.
The examples below demonstrate how to use petalinux-config to review or modify your
PetaLinux project configuration.
2. Launch the top level system configuration menu and configure it to meet your requirements:
$ petalinux-config
3. Launch the Linux kernel configuration menu and configure it to meet your requirements:
$ petalinux-config -c kernel
4. Launch the root file system configuration menu and configure it to meet your requirements:
$ petalinux-config -c rootfs
5. Use --silentconfig for the components when you do not have Kconfig/Menuconfig
support or to skip the launching of configuration menu
$ petalinux-config -c <COMPONENT> --silentconfig
The following warning message appears when you run the petalinux-config or
petalinux-build for components (Ex: petalinux-build -c u-boot) and this can be
ignored.
TIP: Set U-Boot target in petalinux-config menuconfig as required, for your custom board. Set $
petalinux-config → U-Boot Configuration → u-boot config target as required.
Possible values for Xilinx evaluation boards which are default set are as follows:
Note: Please make sure board and user specific dtsi entries are added to project-spec/meta-user/
recipes-bsp/device-tree/files/system-user.dtsi.
Using template flow, for zcu102 and zcu106 boards, add the following line to <plnx-proj-
root>/project-spec/meta-user/recipes-bsp/fsbl/fsbl_%.bbappend for FSBL
initializations.
Prerequisites
This section assumes that you have PetaLinux tools software platform ready for building a Linux
system customized to your hardware platform. For more information, see Importing Hardware
Configuration. Knowledge of DTS syntax is required to customize the default DTS.
• system-user.dtsi
• xen.dtsi
• pl-custom.dtsi
• openamp.dtsi
• xen-qemu.dtsi
CAUTION! These dtsi files are auto-generated. Do not edit these files
For more details on device tree files, see Appendix B: PetaLinux Project Structure.
If you wish to add information, like the Ethernet PHY information, this should be included in the
system-user.dtsi file. In this case, device tree should include the information relevant for
your specific platform as information (here, Ethernet PHY information) is board level and board
specific.
The system-user.dtsi is automatically created when you configure your PetaLinux project.
Once created, the tools do not update it automatically.
Note: The need for this manual interaction is because some information is "board level" and the tools do
not have a way of predicting what should be here. Refer to the Linux kernel Device Tree bindings
documents (Documentation/devicetree/bindings from the root of the kernel source) for the
details of bindings of each device.
An example of a well-formed device tree node for the system-user.dtsi is shown below:
/dts-v1/;
/include/ "system-conf.dtsi"
/ {
};
&gem0 {
phy-handle = <&phy0>;
ps7_ethernet_0_mdio: mdio {
phy0: phy@7 {
compatible = "marvell,88e1116r";
device_type = "ethernet-phy";
reg = <7>;
};
};
};
IMPORTANT! Ensure that the device tree node name, MDIO address, and compatible strings correspond to the
naming conventions used in your specific system.
SRC_URI += "file://system-user.dtsi"
SRC_URI += "file://system-user-1.dtsi"
U-Boot Configuration
This section describes which files are safe to modify for the U-Boot configuration and discusses
about the U-Boot CONFIG_ options/settings.
Prerequisites
This section assumes that you have PetaLinux tools software platform ready for building a Linux
system customized to your hardware platform. Refer to section Importing Hardware
Configuration for more information.
Configuring U-Boot
Universal boot loader (U-Boot) configuration is usually done using C pre-processor. It defines:
• Configuration _OPTIONS_:
You can select the configuration options. They have names beginning with CONFIG_.
• Configuration _SETTINGS_:
These depend on the hardware and other factors. They have names beginning with
CONFIG_SYS_.
TIP: Detailed explanation on CONFIG_ options/settings documentation and README on U-Boot can be found
at Denx U-Boot Guide.
CAUTION! config.cfg and platform-auto.h files are automatically generated; edit them with
caution.
PetaLinux does not currently automate U-Boot configuration with respect to CONFIG_ options/
settings. You can add these CONFIG_ options/settings into platform-top.h file.
• If you want to add CONFIG_CMD_MEMTEST option, add the following line to the file. Save
the changes.
#define CONFIG_CMD_MEMTEST
TIP: Defining CONFIG_CMD_MEMTEST enables the Monitor Command "mtest", which is used for simple RAM
test.
• Boot the image either on hardware or QEMU and stop at U-Boot stage.
• Enter the mtest command in the U-Boot console as follows:
ZynqMP mtest
Chapter 11
Yocto Features
Building SDK
The following command builds SDK and copies it at <proj_root>/images/linux/sdk.sh.
petalinux-build --sdk
Installing SDK
The generated SDK has to be installed/extracted to a directory. The following command extracts
the SDK to a specified directory. The default SDK is <proj_proot>/images/linux/sdk.sh
and default installation directory is <proj_proot>/images/linux/sdk/.
Examples
1. Adding a cross compiling qt toolchain
To build SDK with qt toolchain:
a. Create the <proj-root>/project-spec/meta-user/recipes-core/images/
petalinux-image-minimal.bbappend file.
b. Add inherit populate_sdk_qt5 in the newly created file.
c. Run petalinux-config -c rootfs and select packagegroup-petalinux-qt.
The following command builds the eSDK(extensible SDK) and copies it at <proj_root>/
images/linux/esdk.sh.
petalinux-build --esdk
Installing eSDK
1. Create a project.
2. Go to the project.
3. To pack all the components of petalinux-build, issue the following commands.
petalinux-build --archiver
The generated images are placed in the deploy directory. You have to copy the generated
images into <plnx-proj-root>/images/linux directory to work with the other
commands.
For a .bbappend file which you create for any root file system component, you must add
SIGGEN_UNLOCKED_RECIPES += "<recipe-name>" or SIGGEN_UNLOCKED_RECIPES
+= "u-boot-xlnx" in <plnx-proj-root>/project-spec/meta_user/conf/
petalinuxbsp.conf.
As an optimization, the Yocto Project optimizes downloads of the sstate cache items to only the
minimal items required for the current build. This needs to be factored in when sharing your
sstate cache with another user. The second user's configuration may be different causing a
different set of sstate cache items to be required. There are two approaches to optimizing your
downstream user and their usage of the sstate cache. The first approach is that the second user
should include both the sstate cache directory you provided as well as the original Xilinx sstate
cache directory in <plnx-proj-root>/build/conf/plnxtool.conf.
SSTATE_MIRRORS = " \
file://.* file://<your-sstate-cache>/PATH \n \
file://.* http://petalinux.xilinx.com/sswreleases/rel-v2020/aarch64/sstate-
cache/PATH;downloadfilename=PATH \n \
"
The second approach is to fetch all of the sstate cache items that can be required for a particular
build. This is required if you want to share your build sstate with the downstream user. There is
an option called --setscene-only that will fetch all of the sstate objects that might be
needed for a particular target recipe. For example, if you used petalinux-build (bitbake
petalinux-image-minimal), you should run the following command first to fetch all the
required sstate from Xilinx provided sstate.
Downloading Mirrors
Xilinx® hosts all source download tar files for each release at https://www.xilinx.com/support/
download/index.html/content/xilinx/en/downloadNav/embedded-design-tools.html. By default,
PetaLinux points to pre-mirrors usingpetalinux-config command.
If any component is rebuilt from scratch, BitBake or devtool searches for its source in pre-mirrors
and downloads the mirror URL. Later, it searches in SRC_URI of recipes for downloading the
source of that component. If you configure any value through petalinux-config → yocto settings
→ premirrors, it will first search in the configured pre-mirrors, then on petalinux.xilinx.com, and
finally in the SRC_URI in recipes.
For more information on how to set SSTATE and DL_DIR, see How to Reduce Build Time using
SSTATE Cache.
Machine Support
The Yocto machine specifies the target device for which the image is built. The variable
corresponds to a machine configuration file of the same name, through which machine-specific
configurations are set. Currently, PetaLinux supports the user machine configuration file.
You can add your own machine configuration file under <proj_root>/project-spec/
meta-user/conf/machine/ or you can add your machine configuration file in any additional
layers and add it into project through petalinux-config.
Follow these steps to specify the user machine configuration file name in the PetaLinux project:
Template Machine
zynq zynq-generic
zynqmp zynqmp-generic
microblaze microblazeel-v11.0-bs-cmp-mh-div-generic
BSP Machine
zc702 zc702-zynq7
zc706 zc706-zynq7
zcu102 (All variants ) zcu102-zynqmp
zcu106 zcu106-zynqmp
zcu104 zcu104-zynqmp
kc705 microblazeel-v11.0-bs-cmp-mh-div-generic
ac701 microblazeel-v11.0-bs-cmp-mh-div-generic
kcu105 microblazeel-v11.0-bs-cmp-mh-div-generic
zcu111 zcu111-zynqmp
zcu1285 zcu1285-zynqmp
zcu1275 zcu1275-zynqmp
sp701 microblazeel-v11.0-bs-cmp-mh-div-generic
zcu216 zcu216-zynqmp
zcu208 zcu208-zynqmp
BSP Machine
zed zedboard-zynq7
zynqmp-common zynqmp-generic
zynq-common zynq-generic
1. Zynq-7000 devices are distributed under Zynq7000zs and Zynq7000z. The available
SOC_VARIANTs are:
• "7zs" - Zynq-7000 Single A9 Core
"7z" - Zynq-7000 Dual A9 Core
• Default SOC_VARIANT for Zynq-7000 devices is "7z". For 7000zs devices, add the
SOC_VARIANT = "7zs" in petalinuxbsp.conf
There are no additional overrides for Zynq-7000 devices.
2. Zynq UltraScale+ MPSoC is shipped in three device variants. The available SOC_VARIANTs
are:
• "cg" - Zynq UltraScale+ MPSoC CG Devices
• "eg" - Zynq UltraScale+ MPSoC EG Devices
• "ev" - Zynq UltraScale+ MPSoC EV Devices
• "dr" - Zynq UltraScale+ MPSoC RFSoC devices
The default value is "eg". PetaLinux automatically assigns "ev" and "dr" based on the presence
of IP in the XSA.
Note: You have to explicitly set SOC_VARIANT = "cg" in petalinuxbsp.conf for "CG" devices.
Image Features
The contents of images generated by the OpenEmbedded build system can be controlled by the
IMAGE_FEATURES and EXTRA_IMAGE_FEATURES variables that you typically configure in your
image recipes. Through these variables, you can add several different predefined packages such
as development utilities or packages with debug information needed to investigate application
problems or profile applications.
To remove any default feature, add the following code in the petalinuxbsp.conf:
IMAGE_FEATURES_remove = "ssh-server-dropbear"
To add any new feature, add the following command in the petalinuxbsp.conf:
If you want to exclude packages based on license, you can edit the <plnx-proj>/project-
spec/conf/petalinuxbsp.conf file. For example, set INCOMPATBLE_LICENSE = "GPLv3",
then run the petalinux-build command.
1. Select devtool as the build tool: petalinux-config → Yocto settings → Build tool (devtool)
2. Get the source code from git url specified in meta-layers:
petalinux-build -c <recipe-name> -x modify
The above command fetches the sources for the recipe and unpack them to a <plnx-proj-
root>/components/yocto/workspace/sources/<recipe-name> directory and
initialize it as a git repository if it isn't already one.
3. Make the changes you want to make to the source.
4. Run a build to test your changes. You can just petalinux-build -c <recipename> or
even build an entire image using petalinux-build incorporating the changes assuming a
package produced by the recipe is part of an image. There is no need to force anything; the
build system will detect changes to the source and recompile as necessary.
5. Optional: Test your changes on the target.
6. Place your changes in the form of a patch to the PetaLinux project. To commit your changes,
use the following commands.
git add <filename>
git commit -s
Chapter 12
Technical FAQs
Troubleshooting
This section details the common errors that appear, while working with the PetaLinux commands,
and also lists their recovery steps in detail.
TMPDIR on NFS
The error displayed is:
When TMPDIR is on NFS, BitBake throws an error at the time of parsing. You have to change it
from petalinux-config and then provide any local storage. To do this, select Yocto-settings
→ TMPDIR.
Do not configure the same TMPDIR for two different PetaLinux projects. This can cause build
errors.
To recover, you have to sstateclean the app created and then delete it. Also, delete the line in
conf/user-rootfsconfig.
CONFIG_plnx_myapp
After this error, the console is broken and you cannot see the text that you typed. To restore the
console, enter stty sane and press Ctrl+J twice.
Python cannot change the file system locale after loading, therefore, we need a UTF-8 when
Python starts, else it will not work.
ERROR: Failed to build project
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
Xen and openamp are handled through distro features. Adding distro features does not enable
their corresponding configurations in kernel as they are handled in scc file. The solution is to edit
<plnx-project-root>/project-spec/meta-user/recipes-kernel/linux/linux-
xlnx_%.bbappend.
SRC_URI += "file://xilinx-kmeta/bsp/xilinx/xen.cfg"
To work with the scc files, replace their respective cfg files using external source methodology.
Note: Unlike earlier, currently PetaLinux does not generate the global DTS file. Use the following
command to generate the global DTS file:
CAUTION! Do not use the symlinked path to the project directories for any build operations, including simply
"cd"ing into the directory.
Package Management
PetaLinux supports package management system for Zynq UltraScale+ MPSoC. Use the following
steps to configure and use the package management system:
1. Enable DNF through petalinux-config -c rootfs. Enable the following configs to use
DNF.
• Image Features --> [*] package management
• Set the package feed url from Image Features --> http://petalinux.xilinx.com/sswreleases/
rel-v2020/feeds/ultra96-zynqmp) Package feed url.
Check the available package feeds in http://petalinux.xilinx.com/sswreleases/rel-v2020/
feeds.
2. Build the project.
#petalinux-build
"Linux image size is large (${imgsize}). It can cause boot issues. Please
refer to Technical FAQs. Storage based RootFilesystem is recommended for
large images."
Appendix A
Migration
This section describes the migration details of the current release versus the previous release.
• For earlier releases, the tool contained the minimal downloads and sstate-cache. From this
release onwards, those downloads and sstate-cache are no longer a part of the tool. The
project build will use sstate-cache and downloads from the petalinux-xilinx.com.
• The Yocto SDK will be part of each project <plnx-proj-root>/components/yocto.
• <plnx-proj-root>/project-spec/meta-plnx-generated has been removed. The
required Yocto variables are now part of <plnx-proj-root>/build/conf/
plnxtool.conf.
• From this release onwards, there is an option to specify user-specified eSDK/platform while
installing the tool.
plnx.run -d <destination-path> -p <platform>
DT Overlay Support
• The bitstream filename in <plnx-proj>/images/linux/ is system.bit but if you
enable DT Overlay Support, it will be with design name.
• DT Overlay Support has been added for Zynq®-7000 devices.
Note: For MicroBlaze processors, PetaLinux generates configs from the design on top of the default configs
for Linux and U-Boot.
Build Changes
Default PetaLinux images are built as INITRD. Use the following images for boot:
petalinux-build --esdk
From this release onwards, there is an option to pack sources and licenses as tar:
petalinux-build --archiver
petalinux-build --sdk --archiver
Menuconfig Changes
In this release, Image Packaging Configuration → Root Filesytem type → EXT (SD/eMMC/QSPI/
SATA/USB) has changed to Image Packaging Configuration → Root Filesystem type → EXT4
(SD/eMMC/SATA/USB).
• To build open source bootgen and to use on target, select petalinux-config -c rootfs →
Filesystem Packages → bootgen.
• To switch between bitbake and devtool, select petalinux-config → Yocto Settings → Build tool
• To provide any compilation flags for the FSBL application or the BSP, use this menuconfig
option: petalinux-config → FSBL Configuration.
Note: This is only applicable for Zynq and Zynq UltraScale+ MPSoC BSPs.
• To provide any compilation flags for the PMU firmware application or BSP, use this
menuconfig option: petalinux-config → PMUFW Configuration
Note: This is only applicable for Zynq UltraScale+ MPSoC BSPs.
• To specify devtool workspace when you are building a project in NFS and want to execute
petalinux-config -c kernel/u-boot, use this option: petalinux-config → Yocto
settings → workspace location.
• To the enable debug tweaks menu change to root file system configuration, use this option.$
petalinux-config -c rootfs → Image Features → debug-tweaks
Note: This is enabled by default.
• In earlier releases for Zynq UltraScale+ MPSoC and Zynq devices, petalinux-config → Auto
Config Settings → kernel autoconfig/u-boot autoconfig would be enabled by default. From
this release onwards, to support the distro feature by default, kernel autoconfig and u-boot
autoconfig are disabled. Setting that are enabled as part Linux or U-Boot defconfig is built. If
you want read the kernel/U-Boot configs from the design (xsa file), enable the above
configurations.
Appendix B
• Device tree
• First stage boot loader (optional)
• U-Boot
• Linux kernel
• The root file system is composed of the following components:
○ Prebuilt packages
A PetaLinux project directory contains configuration files of the project, the Linux subsystem,
and the components of the subsystem. The petalinux-build command builds the project
with those configuration files. You can run petalinux-config to modify them. Here is an
example of a PetaLinux project:
project-spec
hw-description
configs
meta-user
pre-built
linux
implementation
images
xen
hardware
xilinx-zcu104-2020.1
components
plnx_workspace
device-tree
config.project
README
• pl.dtsi
• system-conf.dtsi
• system-top.dts
• <bsp name>.dtsi
Here is an example:
├── build
│ ├── bitbake-cookerdaemon.log
│ ├── build.log
│ ├── cache
│ ├── conf
│ ├── downloads
│ ├── misc
│ ├── sstate-cache
│ └── tmp
├── components
│ ├── plnx_workspace
│ └── yocto
├── config.project
├── hardware
│ └── project-name
├── images
│ └── linux
├── pre-built
│ └── linux
├── project-spec
│ ├── attributes
│ ├── configs
│ ├── hw-description
│ └── meta-user
└── README
Note: <plnx-proj-root>/build/ are automatically generated. Do not manually edit files in this
directory. Contents in this directory are updated when you run petalinux-config or petalinux-
build. <plnx-proj-root>/images/ are also automatically generated. Files in this directory are
updated when you run petalinux-build.
By default the build artifacts are removed to preserve space after petalinux-build. To
preserve the build artifacts, you have to add the INHERIT_remove = "rm_work" in <plnx-
proj-dor>/project-spec/meta-user/conf/petalinuxbsp.conf, but it increases the
project space.
Project Layers
The PetaLinux project has the following layer under <proj-plnx-root>/project-spec.
meta-user
This layer is a place holder for all user-specific changes. You can add your own bbappend and
configuration files in this layer.
Appendix C
Note: If you do not want the PetaLinux build FSBL/FS-BOOT, then you will need to manually build it on
your own. Else, your system will not boot properly.
If you had disabled first stage boot loader from menuconfig previously, You can configure the
project to build first stage boot loader as follows:
The boot loader ELF file is installed as zynqmp_fsbl.elf for Zynq® UltraScale+™ MPSoC,
zynq_fsbl.elf for Zynq®-7000 devices and fs-boot.elf for MicroBlaze™ processors in
images/linux inside the project root directory.
The ATF ELF file is installed as bl31.elf for Zynq UltraScale+ MPSoC in images/linux
inside the project root directory.
PMU Firmware
This is for Zynq® UltraScale+™ MPSoC only. This is optional. By default, the top level system
settings are set to generate the PMU firmware.
CAUTION! If you do not want PetaLinux to build the PMU firmware, you have to manually build it on your
own. Else, your system will not boot properly.
The PMU firmware ELF file is installed as pmufw.elf for Zynq UltraScale+ MPSoC in
images/linux inside the project root directory.
For more information on PMU Firmware, see http://www.wiki.xilinx.com/PMU+Firmware.
FS-Boot supports parallel flash and SPI flash in standard SPI mode and Quad SPI mode only.
In order for FS-Boot to know where in the flash should get the image, macro
CONFIG_FS_BOOT_START needs to be defined. This is done by the PetaLinux tools. PetaLinux
tools set this macro automatically from the boot partition settings in the menuconfig primary
flash partition table settings. For parallel flash, it is the start address of boot partition. For SPI
flash, it is the start offset of boot partition.
The image in the flash requires a wrapper header followed by a BIN file. FS-Boot gets the target
memory location from wrapper. The wrapper needs to contain the following information:
0×100 FS-Boot bootable image target memory User defined. PetaLinux tools automatically
address calculate it from the u-boot text base address
offset from the Memory Settings from the
menuconfig.
0×10c Where the BIN file start None
The FS-Boot ignores other fields in the wrapper header. The PetaLinux tools generate the
wrapper header to wrap around the U-Boot BIN file.
The FS-Boot supports symmetric multi processing (SMP) from the 2020.1 release onwards. You
can have multiple MicroBlaze processors in your design. A maximum of eight cores is supported.
<pelnx-tool>/tools/xsct/bin/xsdb
xsdb > connect -url <target-url>
xsdb > fpga -f <plnx-proj>/images/linux/system.bit
xsdb > ta (this will list all avaiable cores)
xsdb > ta <core number>
xsdb > dow -f <plnx-proj>/images/linux/fs-boot.elf
the above two steps for all available cores.
xsdb > dow -f <plnx-proj>/images/linux/uboot.elf
xsdb > dow -f <plnx-proj>/images/linux/image.ub
Appendix D
In non-root mode QEMU sets up an internal virtual network which restricts network traffic
passing from the host and the guest. This works similar to a NAT router. You can not access this
network unless you redirect tcp ports.
In root mode QEMU creates a subnet on a virtual Ethernet adapter, and relies on a DHCP server
on the host system.
The following sections detail how to use the modes, including redirecting the non-root mode so
it is accessible from your local host.
-redir tcp:10023: Redirects port 10023 on the host to host> telnet localhost 10023
10.0.2.15:23 port 23 telnet) in the guest
The following example shows the command line used to redirect ports:
This document assumes the use of port 1534 for gdbserver and tcf-agent, but it is possible to
redirect to any free port. The internal emulated port can also be different from the port on the
local machine:
Note: This feature requires sudo access on the local machine, and must be used with the --root option.
Appendix E
For more information on Xilinx® IP models supported by QEMU, see Xilinx Quick Emulator User
Guide: QEMU (UG1169).
Appendix F
Prerequisites
This section assumes that the following prerequisites have been satisfied:
• You have PetaLinux tools software platform ready for building a Linux system customized to
your hardware platform. For more information, see Importing Hardware Configuration.
• You have created a PetaLinux project from the reference BSP.
• There are Xen related prebuilts in the pre-built/linux/xen directory, which are
xen.dtb, xen-openamp.dtb, xen-qemu.dtb, xen-Image, and xen-rootfs.cpio.gz.
2. Boot prebuilt U-Boot image on the board with either JTAG boot or boot from SD card.
Note: For SD card boot, see Boot a PetaLinux Image on Hardware with an SD Card and for JTAG boot,
see Boot a PetaLinux Image on Hardware with JTAG.
Rebuild Xen
After creating a PetaLinux project for Zynq UltraScale+ MPSoC, follow the below steps to build
Xen images:
SRC_URI += "file://system-user.dtsi"
SRC_URI += "file://xen.dtsi"
6. Run petalinux-build.
7. The build artifacts are in images/linux in the project directory.
Note: By default, the petalinux-build command does not build Xen. The default root file system does
not contain the Xen tools. You have to use Xen RootFS.
IMPORTANT! You are required to update dom0 memory in xen-bootargs in the xen.dtsi file based on the
image/RootFS size. Also, adjust the above load addresses based on the image/RootFS size without overlapping.
2. Boot built U-Boot image on the board with either JTAG boot or boot from SD card.
Note: For SD card boot, see Boot a PetaLinux Image on Hardware with an SD Card and for JTAG boot,
see Boot a PetaLinux Image on Hardware with JTAG.
Note: You can also point the dom1 and dom2 to the domU kernels in the configuration itself so that
xen boot files get updated with that pointed images. Edit the configuration file.
$ vi images/linux/xen.cfg
$ export XEN_CONFIG="<Absolute path for xen.cfg>"
$ export XEN_CONFIG_SKIP="1"
$ export BB_ENV_EXTRAWHITE="$BB_ENV_EXTRAWHITE XEN_CONFIG
XEN_CONFIG_SKIP"
$ petalinux-build -c kernel -x do_deploy
Appendix G
To boot prebuilt Linux for Zynq® UltraScale+™ MPSoC, follow these steps:
$ cd <plnx-proj-root>
$ cp pre-built/linux/images/openamp.dtb pre-built/linux/images/system.dtb
$ petalinux-boot --jtag --prebuilt 3 --hw_server-url <hostname:3121>
To load OpenAMP firmware and run OpenAMP test application, run the following command:
For more examples, see Libmetal and OpenAMP for Zynq Devices User Guide (UG1186).
Appendix H
Xilinx Resources
For support resources such as Answers, Documentation, Downloads, and Forums, see Xilinx
Support.
Xilinx Design Hubs provide links to documentation organized by design tasks and other topics,
which you can use to learn key concepts and address frequently asked questions. To access the
Design Hubs:
Note: For more information on DocNav, see the Documentation Navigator page on the Xilinx website.
References
These documents provide supplemental material useful with this guide:
Copyright
© Copyright 2014-2020 Xilinx, Inc. Xilinx, the Xilinx logo, Alveo, Artix, Kintex, Spartan, Versal,
Virtex, Vivado, Zynq, and other designated brands included herein are trademarks of Xilinx in the
United States and other countries. OpenCL and the OpenCL logo are trademarks of Apple Inc.
used by permission by Khronos. PCI, PCIe, and PCI Express are trademarks of PCI-SIG and used
under license. AMBA, AMBA Designer, Arm, ARM1176JZ-S, CoreSight, Cortex, PrimeCell, Mali,
and MPCore are trademarks of Arm Limited in the EU and other countries. All other trademarks
are the property of their respective owners.