MicroZed Chronicles: PetaLinux Edition

Adam Taylor
4 min readFeb 21, 2020

--

Over the years we have looked a lot at how we can use PetaLinux to create embedded Linux solutions for our Zynq, Zynq MPSoC and MicroBlaze solutions.

Example Zynq configuration for the Digilent Cora

I thought it would be a good idea to dedicate a special series of blogs looking at PetaLinux, what it is and how we use it.

As such over this PetaLinux edition in addition to this introduction to PetaLinux, we are going to be looking at :-

  • PetaLinux Build Environment — How to get started and what tools we need to create a complete PetaLinux deployment.
  • PetaLinux Build Components — What are the different elements of the build e.g. Root File System, Image, Device Tree.
  • PetaLinux Build Flow — How do we customize the OS.
  • PetaLinux Interfacing — How do we interface from the PetaLinux OS to our programmable logic design.

Lets start at the beginning and understand what is PetaLinux? Simply put PetaLinux is a set of build tools which allow us to create an Embedded Linux solution for Xilinx processors (A9, A53 & MicroBlaze) using a x86 Linux host.

At the highest level PetaLinux consists of only seven commands, these commands are used to create projects, applications, boot and deploy the embedded Linux OS.

These commands are

petalinux-create — this command is used to create projects, apps & modules. When creating projects we need to define either a template which can be zynq, zynqMP or microblaze. Alternatively we can define a source which contains a existing PetaLinux board support package.

Most custom projects will start with targeting a processor type, before creating a board support package later in the development.

Example Command for project creation

petalinux-config — this allows configuration of a specific element of the OS e.g. the kernel or the root file system. This also enables configuration of the OS for a new hardware definition using the get-hw-description option.

The get-hardware-description option is a key stage in the development of the embedded Linux solution. This option configures the PetaLinux project for a specific hardware design created in Vivado, this includes configuring U-Boot, the Kernel and the Device Tree.

Example command for loading in the hardware definition
System Configuration Dialog

petalinux-build — this command builds the embedded Linux project, a component of the project or the Yocto e-SDK.

This command builds the PetaLinux project include the Bootloader, Kernel, PMUFW, Arm TrustZone, UBoot, Kernel and the root FS. If desired we can also use this command to build elements of the project e.g. kernel

PetaLinux-Build Command Example

petalinux-boot — this command enables us to boot the project on our target board using JTAG or to boot the project in the simulation environment in QEMU.

Using QEMU we can emulate the Arm or MicroBlaze cores to run the PetaLinux project. This is great for debugging and ensuring the project actually boots as desired, it is especially useful if modules or kernel drivers have been included in the project.

Downloading the Bit file to the Cora Board
Downloading the Kernel to the Cora Board
Cora Board Terminal Output

petalinux-package — at the end of the project build we may desire to package the project to create a boot.bin which can be used in conjunction with the Kernel and RootFS to boot the system. This command can also be used to package the project as a Board Support Package.

Packaging the project as a BSP enables the same settings to be quickly and easily applied to new projects going forward. This is very useful if the same development or custom board is to be used going forward for development.

Packaging a boot file

petalinux-upgrade — this commands provides for the upgrading between different versions of PetaLinux

Using the upgrade command we can take BSPs or projects created in earlier versions and update them to the current release. This can save considerable time when it comes to changing existing project between versions of Vivado.

petalinux-util — this command provides a number of services which are used in development and debugging

This command provides the dfu-util for downloading and uploading over USB along with debugging via GDB, XSDB and JTAG.

Using these commands over the next few special editions of this blog we are going to create and work with PetaLinux solutions running on Zynq and Zynq MPSoC cores.

See My FPGA / SoC Projects: Adam Taylor on Hackster.io

Get the Code: ATaylorCEngFIET (Adam Taylor)

Access the MicroZed Chronicles Archives with over 300 articles on the FPGA / Zynq / Zynq MpSoC updated weekly at MicroZed Chronicles.

--

--

Adam Taylor

Adam Taylor is an expert in design and development of embedded systems and FPGA's for several end applications. He is the founder of Adiuvo Engineering Ltd