Getting Started With PetaLinux (2022)

Introduction: Getting Started With PetaLinux

By NAEastland

More by the author:

Interested in learning a little about embedded Linux? Have you worked with Xilinx FPGAs and want to explore some of the software related to their implementation? If you answered yes, then welcome! If you answered no (to at least the first question) then you should read through anyway, because this is pretty cool stuff.

Welcome to this Getting Started Guide (GSG) to PetaLinux!

PetaLinux is an embedded Linux development solution for Xilinx Zynq chips (an ARM processor with FPGA material, like the ones used here and here) as well as for MicroBlaze designs implemented in fully FPGA chips. This GSG will be using the 2015.4 versions of PetaLinux, SDK, and Vivado and will be targeting the Zybo from Digilent, so we will be implementing a project on a Zynq target rather than the soft processor core of a MicroBlaze design. For some more info on MicroBlaze, check out this guide.

(Video) PetaLinux 101 - Getting Started Quickly

For this Instructable, the following prerequisites apply:

  • Some familiarity with Linux
  • A Zybo or Zedboard to deploy the project onto
  • A Linux machine (VM or dual boot setup) of supported OS: Ubuntu 14.04, CentOS 7, SUSE Enterprise 12, RHEL 6.5/6.6/7. *These are for PetaLinux 2015.4. Newer versions may support more recent OS versions.
  • At least 20GB of free hard drive space
  • Have Vivado and Xilinx SDK installed (the version you have installed should be the version of PetaLinux you will download)

*Note: While I was able to get PetaLinux 2015.4 running within Ubuntu 16.04, this is not a supported version and is not recommended.

This guide will walk you through the steps of initial setup for PetaLinux on your Linux machine and the implementation of a pre-built design on the Zybo. By the end of this Instructable, you will be able to begin tinkering with the design from either the hardware description language (HDL) side, or create custom applications you can run within the Linux system running on your board. Lets get started!

Step 1: Download Installer

You will need to download the installer for PetaLinux of the same version as the Vivado and SDK installation you should have on your system. Meaning if you have Vivado and SDK 2015.4 installed, you should download PetaLinux 2015.4. The download may take a while.

Once the download has completed, make a directory in which you would like the PetaLinux tools to be installed in. From your terminal, change directory (cd) into the directory the installer was downloaded into (likely Downloads) and run the installer with a specified path to the directory you just created.

Step 2: Install PetaLinux

Once the download has completed, make a directory in which you would like the PetaLinux tools to be installed in. In your terminal, change directory (cd) into the directory the installer was downloaded into (likely Downloads) and run the installer with a specified path to the directory you just created. Starting from your home directory, enter the following commands (also in screenshot above).

mkdir PetaLinux

cd Downloads

./petalinux-v2015.4-final-installer-dec.run ../PetaLinux

This is just one option of installation location. You can install PetaLinux into any (typical) directory and it will work fine, as long as you have the tools sourced correctly, which we will cover. The PetaLinux tools have an end user licence agreement (EULA) as part of the tool usage, however PetaLinux does not require a license from Xilinx to run.

Step 3: Download Dependencies

As with many software development tools, there are a variety of dependencies that you will need to have in order for PetaLinux to operate. Many of the packages may already be installed on your computer, but some may not. A full list of the dependencies is included below (for Ubuntu).

  • tofrodos
  • iproute
  • gawk
  • gcc
  • git-core
  • make
  • net-tools
  • ncurses-dev
  • libncurses5-dev
  • tftpd*
  • zlib1g-dev
  • flex
  • bison
  • lib32z1
  • lib32ncurses5
  • lib32bz2-1.0
  • ia32gcc1
  • lib32stdc++6
  • libselinux1

PetaLinux operates using dependencies on 32-bit libraries, so including those specific libraries indicated is required in order for it to operate correctly (even if some may seem redundant). In addition, PetaLinux can utilize a tftp server to streamline the development process, but it is not a requirement for it to function. The specified server package to use is tftpd, however I used tftpd-hpa and would suggest you do the same. If you are unfamiliar with the process of setting it up, you can take a look at this quick Instructable.

Downloading these is the same as any other module that you can get through apt-get, but when you make the following function call (or see image above) you can simply enter each module's name in the same line with spaces between.

sudo apt-get install tofrodos iproute gawk (etc)

The list of dependencies for other Linux distributions can also be found in the PetaLinux documentation, starting on page 10.

(Video) Xilinx Embedded Linux Build flows: PetaLinux Tools

Step 4: Set Up Bash and Source Settings

The PetaLinux tools require you to use 'bash' as your shell rather than 'dash', which is likely your default shell if you're running Ubuntu. To change this, just enter the following command, which will set your default from 'dash' to 'bash'.

sudo dpkg-reconfigure dash

The next thing to take care of will be to source the tools for PetaLinux to use within the terminal window. This includes the 'settings64.sh' and 'settings.sh' files in your Vivado and PetaLinux installation directories, respectively. To avoid needing to type the source commands into the shell every time, you can add a couple lines to the .bashrc script. To modify this system wide, use a text editor to open your .bashrc file. For Ubuntu, this will be bash.bashrc located in the /etc directory (see following command and/or first image above).

sudo gedit /etc/bash.bashrc

Once you have the script open, add the two commands for sourcing the appropriate files. Note that the path indicated here is simply where my installation directories are, so your specific file path may likely be different.

source /home/nate/Documents/plnx/2015_4/petalinux-v2015.4-final/settings.sh
source /opt/Xilinx/Vivado/2015.4/settings64.sh

With the two lines added, save the changes and close the editor.

Step 5: Create a Project - New Project (optional)

To use PetaLinux, you will need a PetaLinux project directory to work in. This can be done either by creating a totally new project or by using a reference design provided in a board support package (BSP). Creating a fresh project provides you with a basic template from which you can start your development. Just change to a directory you would like to create your project in and enter the following command.

petalinux-create --type project --template zynq --name test_01

The '--type' parameter should remain 'project', the '--template' parameter should be whatever supported architecture you are targeting (either zynq, zynqMP for Ultrascale chips, or microblaze for soft processors implemented in FPGA fabric), and the '--name' parameter can be whatever you want to name your project. Do note that this simply provides a folder structure for PetaLinux to use and requires you to provide pretty much every part of the build, from the first stage boot loader to the file system, and is not suggested for those new to Linux development. New players should instead use a BSP!

Step 6: Create a Project - Board Support Package

Creating a new project from a BSP is the simplest way to get started with PetaLinux, since it provides you with an already functioning and bootable Linux image that you start playing with. There are several BSPs available for download from Xilinx, as well as a Digilent BSP for the Zybo. Once you have the BSP of your choosing downloaded (and extracted if it was a zip file), go to your terminal and change directory to where you would like to create your new PetaLinux project directory and enter the following command.

petalinux-create -t project -s

Here '-t' is equivalent to '--type' described in the previous step (its parameter should remain 'project') and '-s' is for source and should be followed with the absolute file path to the BSP you want to use. (i.e. /home/nate/Downloads/ZyboPmodPack.bsp).

Step 7: Configure, Build, and Package

This step is very straight forward from an end user's perspective, but will require you to accept a bit of 'magic' in the background if you are not intimately familiar with the process of compiling a Linux image from scratch. Suffice it to say that by the end of the configure and build process in PetaLinux, you will have a kernel, file system, first stage and second stage boot loaders, and device tree compiled and ready to be deployed to your hardware target. To run configuration on the BSP project you just created, change directory into the directory that was made with the 'petalinux-create' command, and type in the following.

(Video) Xilinx Zynq & PetaLinux Project Demo

petalinux-config

This will initialize a configuration menu for your PetaLinux project (see first image above).Make sure your terminal window is at least its default dimensions or the menu will fail to launch. There are a variety of boot options available to you depending your application. Since the setup and operation of each of the different boot methods is a bit involved, it will be covered in a separate guide. If you are using the Digilent BSP then the default values in the configuration menu will be fine, so just select the 'Exit' option to leave the config menu. The configuration process will then continue on (this will take some time).

Once the configuration is complete, you will need to build your image by entering the following command.

petalinux-build

The execution of this command will also take a few minutes to complete, depending on your system. Once this is finished (again, running the Digilent BSP), enter the following command.

petalinux-package --boot --force --fsbl ./images/linux/zynq_fsbl.elf --fpga ./images/linux/linux_bd_wrapper.bit --u-boot

After this completes you should have your BOOT.bin and U-boot files ready to go.

Step 8: Load Onto SD Card

The SD you use will need to have two partitions on it. I recommend an 8GB card with the first partition (your BOOT partition) formatted as a File Allocation Table (FAT) of 1GB, and the second partition (your rootfs partition) formatted as an ext4 for the remaining space on the card.The FAT partition will be where your BOOT.bin and image.ub will be stored, while the second partition will be where the file system for your Linux image will be. You can use a utility such as fdisk or gparted in your terminal to do the formatting for your SD card.

Copy these two files into the first partition of your SD card. You can do this from your PetaLinux project root directory with the following commands.

cp images/linux/BOOT.bin /media/BOOT

cp images/linux/image.ub /media/BOOT

Once your boot files have been copied into the BOOT partition of your SD card, copy the root file system into the second partition, your 'rootfs' partition, with the following command.

cp images/linux/rootfs.cpio /media/rootfs

*Note: the paths "/media/BOOT" and "/media/rootfs" may not be where your SD card is mounted, so you should modify the copy command accordingly.

Once the root file system and boot files have been copied to the two partitions of your SD card run the following PetaLinux command, still from the root directory of the PetaLinux project (also in the second image above).

petalinux-util --update-sdcard -d /media/nate/ZYBO_BOOT

With that last command entered in you can now unmount and eject your SD card from your computer and load it into your Zybo. You have now just completed this GSG for PetaLinux, congrats!

(Video) Installation of Petalinux and running its first program in Xilinx Quick Emulator (QEMU)

Be the First to Share

Recommendations

SPECTRUM ANALYZER WITH STEAMPUNK NIXIE LOOK by emdee401 in Audio

94 6.1K

PC Mouse Becomes a Robot (MouseBot) by Tony--K in Robots

102 11K

PS4 Controlled Holonomic Drive by maker_ATOM in Robots

74 4.2K

(Video) PetaLinux 1/3 (Vivado-xsa, zynq Booting, APP Compile)

Tim's Electronic Point Mapper [3D] by Palingenesis in Tools

111 11K

  • Eggs Challenge

  • Sculpt & Carve Challenge

  • Fandom Contest

FAQs

Getting Started With PetaLinux? ›

Lets get started!
  1. Step 1: Download Installer. ...
  2. Step 2: Install PetaLinux. ...
  3. Step 3: Download Dependencies. ...
  4. Step 4: Set Up Bash and Source Settings. ...
  5. Step 5: Create a Project - New Project (optional) ...
  6. Step 6: Create a Project - Board Support Package. ...
  7. Step 7: Configure, Build, and Package. ...
  8. Step 8: Load Onto SD Card.

Does PetaLinux require license? ›

The PetaLinux Tools License is no longer required. Users can install and use PetaLinux tools to deploy royalty free OS images.

What does PetaLinux package do? ›

Overview. PetaLinux is an embedded Linux development solution for Xilinx Zynq chips as well as for MicroBlaze designs.

How do you apply a PetaLinux patch? ›

  1. In PetaLinux 2020, you could patch the kernel by adding a .patch file to project-spec/meta-user/recipes-kernel and updating the .bbappend therein. ...
  2. "petalinux-config → Auto configs → kernel autoconfig and petalinux-config → Auto configs → u-
  3. boot autoconfig have been removed for aarch64 and arm. ...
  4. kernel configs, use bsp.
Oct 4, 2021

How do you make a PetaLinux BSP? ›

Petalinux project creation and build with BSP file
  1. Open a console and source the Petalinux environment script: source /<path-to-petalinux-installation-dir>/settings.sh.
  2. To create a Petalinux project from the provided bsp file use: petalinux-create --type project -s <path-to-bsp-file>.bsp.

Can you run PetaLinux on Windows? ›

Normally, if you want to run PetaLinux on Windows 10 machine, it is required to run Linux in VirtualBox. However, Windows Subsystem Linux 2 (WSL2) has solved this problem, and the performance of running PetaLinux has increase greatly instead of running it on a virtual machine.

Can we install PetaLinux on Windows? ›

On windows, go to the petalinux download page and download petalinux 2019.2.

What is PetaLinux based on? ›

PetaLinux automates creating embedded Linux systems based on your customized hardware in Xilinx FPGAs and SoCs. PetaLinux includes U-Boot, Linux kernel, Device Tree, and Root Filesystem components.

How do I add apps to PetaLinux? ›

Custom Application Creation in PetaLinux on the Zynqberry
  1. Step 1: Create the app.
  2. Step 2: Enable the application in the root filesystem configuration menu.
  3. Step 3: Build the application.
  4. Step 4: Rebuild the entire PetaLinux project.
  5. Step 5: Update the boot image file (BOOT.BIN)

Does PetaLinux use yocto? ›

Petalinux also comes with its own Yocto package on top of which it builds distirbutions.

How do kernel patches work? ›

The patch can be made with a tool like kpatch-build. The outcome is a kernel module, which is then delivered. At the point when this module is loaded, it guarantees that the processes using a specific system call are using its patched form. There are three kernel features that make the way of patching possible.

How do I remove an app from Petalinux? ›

Take a look in <plnx-proj-root>/project-spec/meta-plnx-generated/recipes-core/images/petalinux-image. bbappend. Remove that append entry and then you should be good to go.

What does it mean to patch a kernel? ›

You apply a patch with the patch program. The patch program reads a diff (or patch) file and makes the changes to the source tree described in it. Patches for the Linux kernel are generated relative to the parent directory holding the kernel source dir.

How do I change my root password in Petalinux? ›

Then under -> Petalinux RootFS Settings select Root password and change it. It will then be compiled into the new image.

How do I install PetaLinux 2020? ›

How to Install PetaLinux 2020.1
  1. Step 1: Create the Virtual Machine. Download, install and launch VirtualBox from here. ...
  2. Step 2: Install Ubuntu 18.04. 4 LTS onto the VM. ...
  3. Step 3: Install Vitis. ...
  4. Step 4: Install PetaLinux dependencies. ...
  5. Step 5: Install PetaLinux. ...
  6. Step 6: Change /bin/sh to bash.
Dec 13, 2020

How do I run ZYNQ on Linux? ›

Start
  1. Step 1 : Install PetaLinux 2016.4. ...
  2. Step 2 : Prepare SD card for booting Linux. ...
  3. Step 3 : Create the Hardware Design. ...
  4. Step 4 : Generating kernel images for the designed hardware using PetaLinux. ...
  5. Step 5 : Downloading Ubuntu 16.04 LTS Root File System for Zynq. ...
  6. Step 6 : Booting Linux on ZC702.

What is image UB in PetaLinux? ›

In the kernel configuration, using Petalinux, you can also point it to a different cpio image for your root filesystem. The kernel build combines the cpio image with the kernel image. The image. ub is a FIT image which is documented in the u-boot tree (doc/uImage.

Does Xilinx run on Linux? ›

Xilinx Linux is an open source Project where key components are made available to users via two mechanisms: The Xilinx Git contains U-Boot, ARM Trusted Firmware, Linux kernel, GDB, GCC, libraries and other system software. This Xilinx wiki contains documentation meant to guide the use of those software components .

How do I upgrade PetaLinux project? ›

PetaLinux
  1. Download and install the PetaLinux release that you intend to use.
  2. Download and install the BSP for the target platform for the release that you intend to use. ...
  3. Update the BSP files for the target platform in the PetaLinux/src/<platform> directory. ...
  4. Apply the required modifications to the updated BSP files.

Does PetaLinux require vivado? ›

*These are for PetaLinux 2015.4. Newer versions may support more recent OS versions. At least 20GB of free hard drive space. Have Vivado and Xilinx SDK installed (the version you have installed should be the version of PetaLinux you will download)

How do I find my PetaLinux version? ›

Execute `uname -a` on a running Petalinux image on the FPGA. Here, the output indicates that the kernel version is 4.19 and that this Petalinux image was built on Thursday October 21 2021, at 22:04:57 UTC.

How do I install PetaLinux 2019.2 on Ubuntu? ›

How to Install PetaLinux 2019.1
  1. Step 1: Create the Virtual Machine. Get VirtualBox from here, then install and launch it. ...
  2. Step 2: Install Ubuntu 18.04. 4 LTS onto the VM. ...
  3. Step 3: Install PetaLinux dependencies. ...
  4. Step 4: Install PetaLinux. ...
  5. Step 5: Change /bin/sh to bash. ...
  6. Step 6: Install Vivado and SDK (optional)
Dec 13, 2019

How install ZYNQ on Linux? ›

Start
  1. Step 1 : Install PetaLinux 2016.4. ...
  2. Step 2 : Prepare SD card for booting Linux. ...
  3. Step 3 : Create the Hardware Design. ...
  4. Step 4 : Generating kernel images for the designed hardware using PetaLinux. ...
  5. Step 5 : Downloading Ubuntu 16.04 LTS Root File System for Zynq. ...
  6. Step 6 : Booting Linux on ZC702.

Videos

1. Zynq Ultrascale+ and Petalinux (part 01): introduction
(Mohammad S. Sadri)
2. Booting Linux on the Xilinx ZCU111 board using the 2018.3 PetaLinux BSP's pre-built images
(Kestrel Omnitech Inc.)
3. Zedboard Tutorial: Using Zynq SPI in Petalinux
(Mohsin Shafiq)
4. petalinux
(masoud hosseini)
5. Trenz TE0726 Zynqberry Petalinux - Getting Started with simple Reference Design Vivado 2020.2
(SoC_Design)
6. Zynq Ultrascale+ and Petalinux (part 02): Software setup and JTAG connectivity (Linux Virtualbox)
(Mohammad S. Sadri)

Top Articles

You might also like

Latest Posts

Article information

Author: Tish Haag

Last Updated: 10/27/2022

Views: 5597

Rating: 4.7 / 5 (67 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Tish Haag

Birthday: 1999-11-18

Address: 30256 Tara Expressway, Kutchburgh, VT 92892-0078

Phone: +4215847628708

Job: Internal Consulting Engineer

Hobby: Roller skating, Roller skating, Kayaking, Flying, Graffiti, Ghost hunting, scrapbook

Introduction: My name is Tish Haag, I am a excited, delightful, curious, beautiful, agreeable, enchanting, fancy person who loves writing and wants to share my knowledge and understanding with you.