PetaLinux to Yocto - Command Cross Reference

This reference is a summary of the major commands in PetaLinux and their equivalent functionality in native Yocto. This can be used as a ready reckoner for those who are used to using PetaLinux and are looking to replicate their workflow in Yocto.

The primary source of detail on Yocto commands should be the documentation provided by the project. This can be found at https://docs.yoctoproject.org/dev/ . Select the version of Yocto from the pull down menu for version-specific context of the documentation

Table of Contents

Creating a Project

Create a new empty project from a template

A new “blank project”

PetaLinux Example

With PetaLinux, the architecture is specified as the template given at project creation time.

petalinux-create -t project -n <PROJECT NAME> --template [microblaze,zynq,zynqMP,versal,versal-net]

Yocto Project Example

For Yocto Project, the machine is not defined on project creation. It can be modified in build/conf/local.conf afterwards. By default, the machine is set to zynqmp-generic, however can be changed in local.conf, or on invocation of the bitbake build command, using the MACHINE=[target template] command line override.

mkdir myproject && cd myproject repo init -u https://github.com/Xilinx/yocto-manifests.git -b rel-v2023.1 repo sync source setupsdk ls -l ../sources/meta-xilinx/meta-xilinx-core/conf/machine/*.conf # Show available templates sed -i "/MACHINE ??=/c\MACHINE ??= \"zynqmp-generic\"" conf/local.conf # Set the machine template in conf/local.conf (change as desired) # Alternatively, you could just override with MACHINE=zynqmp-generic on the bitbake command when building to select the appropriate board.

Create a new project and target a specific pre-built BSP

A PetaLinux BSP is a configuration file containing all the necessary settings and artifacts required to build a project with the PetaLinux tools for a given hardware project. The file has a .bsp extension, and can be downloaded from the AMD website for a given board. The meta-xilinx-bsp layer has a number of built-in BSPs in native Yocto that can be used as a starting point for supported boards.

PetaLinux Example

Download a BSP file from the website - for example, xilinx-zcu102-v2023.1-05080224.bsp

petalinux-create --type project -s xilinx-zcu102-v2023.1-05080224.bsp cd xilinx-zcu102-2023.1/

Yocto Project Example

Configuring and Building

Setting up the PetaLinux / Yocto environment

In PetaLinux, the tools need to be made available to the command line, however no project-specific initialization is required. With Yocto, the SDK needs to be set up for the local project prior to running bitbake commands.

For either tool, this setup only needs to be done once per command line session.

PetaLinux Example

Yocto Example

Importing a Hardware Configuration

PetaLinux Example

Yocto Example

This Yocto Example is broken into two pieces. In the first piece, we create a new layer, which allows us to store details about a machine configuration. This layer has a configuration file made, to specify that the hardware is similar to the ZCU102 board, and then we make any necessary changes in that file to override defaults. In our case, we override the XSA file that is being used, to point to our own one. Note - this only needs to be done once per new xsa file. Once the layer is in place and configured, we only need to follow part 2, to change the machine name in local.conf to use the configuration specified.

Understanding and Creating Layers from the Yocto project documentation gives more detail on layers, how to create them and add them and best practices

Part 1 - Setting up a new layer and machine configuration (do once)

Part 2 - Edit the configuration to use the newly created machine configuration

The command below replaces the line in local.conf to specify the new target machine using the command line tools. However in an active project you might prefer to open the file in a text editor, find the line and modify it by hand.

Building a System Image

PetaLinux Example

Yocto Example

Packaging and Booting

Generate the boot Image

This step is used to generate a boot.bin file for booting the target. This would usually contain a PDI file, PLM, PSM firmware, TF-A, U-Boot boot loader and DTB.

PetaLinux Example

Yocto Example

Generate MCS Image

PetaLinux Example

Yocto Example

Details can be found in the meta-xilinx documentation here : https://github.com/Xilinx/meta-xilinx/blob/master/docs/README.booting.flash.md

Boot Image on QEMU

PetaLinux Example

Yocto Example

 

Boot Image on Hardware with an SD card

PetaLinux Example

Yocto Example

To automatically create an SD card raw image WIC file, you can either add IMAGE_FSTYPES:append=" wic" to conf/local.conf:

or if you have a custom machine layer, you can add the IMAGE_FSTYPES += “wic” field to that layer:

The next invocation of bitbake <target filesystem image> will then create the WIC file to be copied to the SD card.

Boot Image on Hardware with JTAG

PetaLinux Example

Yocto Example

Upgrading the Workspace

Upgrade the workspace

PetaLinux Example

Yocto Example

Upgrading the Installed tool with more Platforms

PetaLinux Example

Yocto Example

Yocto does not need a manual install step. If MACHINE is changed to a new architecture, bitbake will perform the necessary steps to build for that platform.

Customizing the Root File System

Including Prebuilt Applications

PetaLinux Example

Yocto Example

Step 1 - Create a new application layer

Only perform this step if you do not already have an application layer created

Step 2 - Add your prebuilt application and Makefile

Step 3 - Make a Bitbake recipe

This points the build system to your Makefile and sources and specifies to use make to build and install them

Step 4 - Change back directory, and build the application

Step 5 - Add the application to all images using your applications layer.conf and test

Creating and Adding Custom Applications

PetaLinux Example

Yocto Example

Step 1 - Create a new application layer

Only perform this step if you do not already have an application layer created

Step 2 - Add your source code and Makefile

Step 3 - Make a Bitbake recipe

This points the build system to your Makefile and sources and specifyies to use make to build and install them

Step 4 - Change back directory, and build the application

Step 5 - Add the application to all images using your applications layer.conf and test

Creating and Adding Custom Kernel Modules

PetaLinux Example

Yocto Example

Step 1 - Create a new application layer

Only perform this step if you do not already have an application layer created

Step 2 - Copy a kernel out-of-tree module example from the poky meta-skeleton sources into the local layer

Step 4 - Enable kernel module build in the layer

Step 5 - Build root file system with the included out-of-tree module

Kernel modules can be found in /lib/modules/<kernel-version> on the running target:

Application Auto Run at Startup

PetaLinux Example

Follow the steps at https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18842475#PetaLinuxYoctoTips-HowtoAutoRunApplicationatStartup

Yocto Example

Follow the steps at https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18842475#PetaLinuxYoctoTips-HowtoAutoRunApplicationatStartup with the following changes:

Instruction Step 1 - Instead of using petalinux-create to create an application, make a new layer if needed, enable it for build, and create an empty folder ready to copy the myapp-init.service and myappinit.bb files:

Create the myappinit.bb, files/myapp-init.service and files/myapp-init files as per the instructions into ../sources/meta-myapplications/recipes-apps/myapp-init

Instruction Step 4 - instead of running petalinux-build, run:

if all builds well, enable it in your layer:

and then build with

Adding Layers

PetaLinux Example

→ Yocto Settings → User Layers

Yocto Example

Enable the new layer using the bitbake-layers command:

Confirm that it is enabled using

Adding an Existing Recipe into the Root File System

PetaLinux Example

Locate the recipe
Add the CONFIG_<recipename> into <plnx-proj-root>/project-spec/meta-user/conf/user-rootfsconfig. Run

Select the package and then run

Yocto Example

Modify either the conf/local.conf or a custom enabled layer’s conf/layer.conf and add the package:

Adding a Package Group

PetaLinux Example

Step by step guide in detail are in UG1144:

Create a bb file
Add the configuration to user-rootfsconfig
Run the following command to select:

Yocto Example

© Copyright 2019 - 2022 Xilinx Inc. Privacy Policy