Ug1157 Petalinux Tools Command Line Guide
Ug1157 Petalinux Tools Command Line Guide
Documentation
PetaLinux Tools
Introduction
PetaLinux is a development and build environment which automates many of the tasks
required to boot embedded Linux on Xilinx SoC’s and FPGA’s. It uses Yocto Project
underneath for configuring and building various components. This document contains
detailed information about the various tools that comprise the PetaLinux environment.
There are six independent tools that make up the PetaLinux design flow. They are:
• petalinux-create
• petalinux-config
• petalinux-build
• petalinux-boot
• petalinux-package
• petalinux-util
In most cases, the individual PetaLinux tools are flexible such that the specific options
passed to the tools present you with a unique usage model, compared to other options for
the same tool.
For the purposes of this document, command line arguments that behave as a modifier for
a workflow are referred to as "options”. When options can accept user-specified values,
these values are shown in italics. In some cases, omitting the user-specified value may result
in a built-in default behavior. See the "Default Value" column in the tables for details about
relevant default values.
petalinux-create
The petalinux-create tool creates objects that are part of a PetaLinux project. This tool
provides two separate workflows. In the petalinux-create -t project workflow, the
tool creates a new PetaLinux project directory structure. In the petalinux-create -t
COMPONENT workflow, the tool creates a component within the specified project.
Table 1-2 details the command line options that are common to all petalinux-create
workflows.
petalinux-create -t project
The petalinux-create -t project command creates a new PetaLinux project at the
specified location with a specified name. If the specified location is on the Network File
System (NFS), it changes the TMPDIR automatically to /tmp/<projname_timestamp>. If
/tmp/<projname_timestamp> is also on NFS, then it throws an error. You can change
the TMPDIR through petalinux-config. Do not configure the same location as TMPDIR
for two different PetaLinux projects, this may cause build errors. By default, the directory
structure created by this command with template is minimal, and is not useful for building
a complete system until initialized using the petalinux-config
--get-hw-description command. Projects created using a BSP file as their source are
suitable for building immediately.
Options
Table 1-3 details options used specifically when creating a project.
Examples
The following examples demonstrate proper usage of the petalinux-create -t
project command.
petalinux-create -t COMPONENT
The petalinux-create -t COMPONENT command allows you to create various
components within the specified PetaLinux project. These components can then be
selectively included or excluded from the final system by toggling them using the
petalinux-config -c rootfs workflow.
Options
The petalinux-create -t apps command allows you to customize how application
components are initialized during creation. Table 1-4 details options that are common when
creating applications within a PetaLinux project.
Examples
The following examples demonstrate proper usage of the petalinux-create -t
COMPONENT command.
petalinux-config
The petalinux-config tool allows you to customize the specified project. This tool
provides two separate workflows. In the petalinux-config --get-hw-description
workflow, a project is initialized or updated to reflect the specified hardware configuration.
In the petalinux-config -c COMPONENT workflow, the specified component is
customized using a menuconfig interface.
Table 1-5 details the available options for the petalinux-config tool.
Note: Previously, petalinux-config generated the source code for all the embedded software
applications such as fsbl, device-tree, pmufw and fs-boot. Currently, the source code has to be
generated explicitly with -c option, if required. Otherwise, it is automatically generated with the
petalinux-build.
petalinux-config --get-hw-description
The petalinux-config --get-hw-description command allows you to initialize or
update a PetaLinux project with hardware-specific information from the specified Vivado
hardware project. The components affected by this process may include FSBL configuration,
U-Boot options, Linux kernel options, and the Linux device tree configuration. This
workflow should be used carefully to prevent accidental and/or unintended changes to the
hardware configuration for the PetaLinux project. The path used with this workflow is the
directory that contains the HDF/DSA file rather than the full path to the HDF/DSA file itself.
This entire option can be omitted if run from the directory that contains the HDF file.
Examples:
The following examples demonstrate proper usage of the petalinux-config
--get-hw-description command.
• Initialize a PetaLinux project within the project directory with an external HDF/DSA.
$ petalinux-config --get-hw-description=<PATH-TO-HDF/DSA-DIRECTORY>
petalinux-config -c COMPONENT
The petalinux-config -c COMPONENT command allows you to use a standard
menuconfig interface to control how the embedded Linux system is built, and also
generates the source code for embeddedSW apps. When petalinux-config is executed
with no other options, it launches the system-level or "generic" menuconfig. This interface
allows you to specify information such as the desired boot device or metadata about the
system such as default hostname. The petalinux-config -c kernel,
petalinux-config -c u-boot and petalinux-config -c rootfs workflows
launch the menuconfig interfaces for customizing the Linux kernel, u-boot and the root
filesystem, respectively.
The --oldconfig option allows you to parse the edited config file onto Kconfig, so that
it can pull the dependencies.
Examples
The following examples demonstrate proper usage of the petalinux-config -c
COMPONENT command:
• Parse the configuration onto Kconfig without opening the GUI, for the root filesystem:
$ petalinux-config -c rootfs --oldconfig
petalinux-build
The petalinux-build tool builds either the entire embedded Linux system or a
specified component of the Linux system. This tool uses the Yocto Project underneath.
Whenever petalinux-build is invoked, it internally calls bitbake. While the tool
provides a single workflow, the specifics of its operation can be dictated via the
petalinux-build -c and petalinux-build -x options.
Table 1-6 outlines the valid options for the petalinux-build tool.
petalinux-build --component
The petalinux-build -c option builds the specified component of the embedded
system. When no components are specified, the petalinux-build tool operates on the
project as a whole. User-created components for the root filesystem can be built by
targeting those components by name (For example, with -c <APP-NAME>). This is
equivalent to bitbake <COMPONENT>.
Options
Table 1-7 summarizes the available components that can be targeted with this command.
petalinux-build -c base-files
petalinux-build --execute
The petalinux-build -x option allows you to specify a build step to the
petalinux-build tool to control how the specified components are manipulated.
Options
Table 1-8 summarizes the available Makefile commands that can be used with this option.
Examples
The following examples demonstrate proper usage of the petalinux-build command.
• Clear the build area of the PetaLinux project for archiving as a BSP or for revision
control. This example retains the images directory of the project.
$ petalinux-build -x distclean
• Clean all build collaterals from the U-Boot component of the PetaLinux project.
$ petalinux-build -c u-boot -x cleansstate
• Clean all build collaterals. It removes build/, ${TMPDIR} and images. This will bring the
project to its initial state.
$ petalinux-build -x mrproper
• Create an updated FIT image from the current contents of the deploy area.
$ petalinux-build -x package
petalinux-boot
The petalinux-boot tool boots the specified Linux system image files. This tool provides
two distinct workflows. In the petalinux-boot --jtag workflow, the system image files
are downloaded and booted on a physical board via a JTAG cable connection. In the
petalinux-boot --qemu workflow, the system image files are loaded and booted via
the QEMU software emulator. Either the --jtag or the --qemu is mandatory for the
petalinux-boot tool.
Table 1-9 details the command line options that are common to all petalinux-boot
workflows.
Notes:
1. --prebuilt 1 is not a valid option for the QEMU workflow.
petalinux-boot --jtag
The petalinux-boot --jtag command boots the MicroBlaze or Zynq®-7000 or Zynq
UltraScale+ MPSoC system with a PetaLinux image via a JTAG connection.
Note: The petalinux-boot --jtag command may not work as expected when executed within
a virtual machine, since virtual machines often have problems with jtag cable drivers.
Options
Table 1-10 contains details of options specific to the JTAG boot workflow.
Notes:
1. The --fpga option looks for download.bit in <plnx-proj-root>/pre-built/linux/implementation
by default.
Examples
The following examples demonstrate proper usage of the petalinux-boot --jtag
command.
• Download and boot a pre-built bitstream (and FSBL for Zynq-7000 or Zynq UltraScale+
MPSoC) via JTAG to a physical board.
$ petalinux-boot --jtag --prebuilt 1
• Download and boot a pre-built U-Boot elf via JTAG to a physical board.
$ petalinux-boot --jtag --prebuilt 2
petalinux-boot --qemu
The petalinux-boot --qemu command boots the MicroBlaze or Zynq-7000 or Zynq
UltraScale+ MPSoC system with a PetaLinux image via the QEMU emulator. Many QEMU
options require superuser (root) access to operate properly. The --root option enables
ROOT MODE and prompts you for sudo credentials.
Options
Table 1-11 contains details of options specific to the QEMU boot workflow.
Examples
The following examples demonstrate proper usage of the petalinux-boot --qemu
command.
• Load and boot a pre-built U-Boot elf via QEMU in root mode.
$ petalinux-boot --qemu --root --prebuilt 2
petalinux-package
The petalinux-package tool packages a PetaLinux project into a format suitable for
deployment. The tool provides several workflows whose operation varies depending on the
target package format. The supported formats/workflows are boot, bsp and pre-built.
The petalinux-package tool is executed using the package type name to specify a
specific workflow in the format petalinux-package --PACKAGETYPE.
• The boot package type creates a file (.BIN or .MCS) that allows the target device to
boot.
• The bsp package type creates a .bsp file which includes the entire contents of the
target PetaLinux project.
• The pre-built package type creates a new directory within the target PetaLinux
project called "pre-built" and contains pre-built content that is useful for booting
directly on a physical board. This package type is commonly used as a precursor for
creating a bsp package type.
Table 1-12 details the command line options that are common to all of the
petalinux-package workflows.
Petalinux-package --boot
The petalinux-package --boot command generates a bootable image that can be
used directly with a Zynq family device (including both Zynq-7000 and Zynq UltraScale+
MPSoC) or MicroBlaze-based FPGA design. For Zynq family devices, bootable format is
BOOT.BIN which can be booted from an SD card. For MicroBlaze-based designs, the
default format is an MCS PROM file suitable for programming via Vivado or other PROM
programmer.
For Zynq family devices, this workflow is a wrapper around the bootgen utility provided
with Xilinx SDK. For MicroBlaze-based FPGA designs, this workflow is a wrapper around the
corresponding Vivado Tcl commands and generates an MCS formatted programming file.
This MCS file can be programmed directly to a target board and then booted.
Options
Table 1-13 details the options that are valid when creating a bootable image with the
petalinux-package --boot command.
Examples
The following examples demonstrate proper usage of the petalinux-package --boot
command.
• Create a BOOT.BIN file for a Zynq family device (including Zynq-7000 and Zynq
UltraScale+ MPSoC).
$ petalinux-package --boot --format BIN --fsbl <PATH-TO-FSBL> --u-boot -o
<PATH-TO-OUTPUT-WITH-FILE-NAME>
• Create a BOOT.BIN file for a Zynq family device that includes a PL bitstream and FIT
image.
$ petalinux-package --boot --format BIN --fsbl <PATH-TO-FSBL> --u-boot --fpga
<PATH-TO-BITSTREAM> --kernel -o <PATH-TO-OUTPUT>
• Create a BOOT.BIN file for a Zynq UltraScale+ MPSoC device that includes a PMU
firmware.
$ petalinux-package --boot --u-boot --kernel --pmufw <PATH_TO_PMUFW>
petalinux-package --bsp
The petalinux-package --bsp command compiles all contents of the specified
PetaLinux project directory into a BSP file with the provided file name. This .bsp file can be
distributed and later used as a source for creating a new PetaLinux project. This command
is generally used as the last step in producing a project image that can be distributed to
other users. All Xilinx reference BSP’s for PetaLinux are packaged using this workflow.
Options
Table 1-14 details the options that are valid when packaging a PetaLinux BSP file with the
petalinux-package --bsp command.
Examples
The following examples demonstrate proper usage of the petalinux-package --bsp
command.
• Clean the project and then generate the BSP installation image (.BSP file)
$ petalinux-package --bsp --clean -o <PATH-TO-BSP> -p <PATH-TO-PROJECT>
• Generate the BSP installation image that includes a reference hardware definition
$ petalinux-package --bsp --hwsource <PATH-TO-HW-EXPORT> -o <PATH-TO-BSP> -p
<PATH-TO-PROJECT>
petalinux-package --image
The petalinux-package --image command packages an image for a component. You
can use it to generate uImage for kernel.
Options
Table 1-15 details the options that are valid when packaging an image with the
petalinux-package -- image workflow.
Example
The following example demonstrate proper usage of the petalinux-package --image
command.
• Generate uImage.
$ petalinux-package --image -c kernel --format uImage
petalinux-package --prebuilt
The petalinux-package --prebuilt command creates a new directory named
“pre-built” inside the directory hierarchy of the specified PetaLinux project. This directory
contains the required files to facilitate booting a board immediately without completely
rebuilding the project. This workflow is intended for those who will later create a PetaLinux
BSP file for distribution using the petalinux-package --bsp workflow. All Xilinx
reference PetaLinux BSP’s contain a pre-built directory.
Options
Table 1-16 details the options that are valid when including pre-built data in the project
with the petalinux-package --prebuilt workflow.
Examples
The following examples demonstrate proper usage of the petalinux-package
--prebuilt command.
petalinux-package --sysroot
The petalinux-package --sysroot command installs sdk to a specified directory in publish
mode. This directory can be used as sysroot for application development.
Options
Table 1-16 details the options that are valid when installing an SDK with the
petalinux-package --sysroot workflow.
Examples
The following examples demonstrate proper usage of the petalinux-package --sysroot
command.
petalinux-util
The petalinux-util tool provides various support services to the other PetaLinux
workflows. The tool itself provides several workflows depending on the support function
needed.
petalinux-util --gdb
The petalinux-util --gdb command is a wrapper around the standard GNU GDB
debugger and simply launches the GDB debugger in the current terminal. Executing
petalinux-util --gdb --help at the terminal prompt provides verbose GDB options
that can be used.
Example
The following example demonstrates proper usage of the petalinux-util --gdb
command.
petalinux-util --dfu-util
The petalinux-util --dfu-util command is a wrapper around the standard
dfu-util, and simply launches the dfu-util in the current terminal. Executing
petalinux-util --dfu-util --help at the terminal prompt, provides verbose
dfu-util options that can be used.
Example
The following example demonstrates proper usage of the petalinux-util --dfu-util
command.
$ petalinux-util --dfu-util
petalinux-util --xsdb-connect
The petalinux-util --xsdb-connect command provides XSDB connection to QEMU,
this is for Zynq-7000 and Zynq UltraScale+ MPSoC only.
Options
Table 1-18 details the options that are valid when using the petalinux-util
--xsdb-connect command.
petalinux-util --jtag-logbuf
The petalinux-util --jtag-logbuf command logs the Linux kernel printk output
buffer that occurs when booting a Linux kernel image via JTAG. This workflow is intended for
debugging the Linux kernel for review and debug. This workflow may be useful for users
when the Linux kernel is not producing output via a serial terminal. For details on how to
boot a system via JTAG, see the petalinux-boot --jtag command. For MicroBlaze, the image
is <plnx-proj-root>/image/linux/image.elf. For Arm, the image is
<plnx-proj-root>/image/linux/vmlinux.
Options
Table 1-19 details the options that are valid when using the petalinux-util
--jtag-logbuf command.
Examples
The following examples demonstrate proper usage of the petalinux-util
--jtag-logbuf command.
• Launch the JTAG logger from a neutral location. This workflow is for Zynq-7000 devices
only.
$ petalinux-util --jtag-logbuf -i <PATH-TO-IMAGE> -p <PATH-TO-PROJECT>
petalinux-util --find-hdf-bitstream
The petalinux-util --find-hdf-bitstream extracts bitstream from hdf.
Options
Table 1-20 details the options that are valid when using the petalinux-util
--find-hdf-bitstream command.
Example
The following examples demonstrate proper usage of the petalinux-util
--find-hdf-bitstream command:
petalinux-util --webtalk
The petalinux-util --webtalk command toggles the Xilinx WebTalk feature ON or
OFF. Xilinx WebTalk provides anonymous usage data about the various PetaLinux tools to
Xilinx. A working Internet connection is required for this feature.
Options
Table 1-21 details the options that are valid when using the petalinux-util
--webtalk command.
Examples
The following examples demonstrate proper usage of the petalinux-util --webtalk
command.
Xilinx Resources
For support resources such as Answers, Documentation, Downloads, and Forums, see Xilinx
Support.
Solution Centers
See the Xilinx Solution Centers for support on devices, software tools, and intellectual
property at all stages of the design cycle. Topics include design assistance, advisories, and
troubleshooting tips.
• From the Vivado® IDE, select Help > Documentation and Tutorials.
• On Windows, select Start > All Programs > Xilinx Design Tools > DocNav.
• At the Linux command prompt, enter docnav.
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:
• In the Xilinx Documentation Navigator, click the Design Hubs View tab.
• On the Xilinx website, see the Design Hubs page.
Note: For more information on Documentation Navigator, see the Documentation Navigator page
on the Xilinx website.
References
1. PetaLinux Tools Documentation (UG1144).
2. Xilinx Answer Record 55776