Contenu principal

Build PetaLinux Image for AMD RFSoC Devices

Since R2026a

This example shows how to build a PetaLinux 2023.1 image for an AMD® Zynq® UltraScale+™ ZCU216 RFSoC evaluation kit. You set up the build environment and build the PetaLinux image by using a MathWorks® Yocto layer, also known as a meta-mathworks layer. You can use these steps to build PetaLinux image for other AMD RFSoC devices.

The meta-mathworks layer provides the dependencies, libraries, and utilities to integrate and communicate between the embedded Linux® system and MathWorks tools, and generates a Linux environment optimized for MathWorks applications and supported AMD hardware platforms.

Requirements

To run this example, you must:

  • Set up a build environment on the host machine. For more information on how to configure your host machine for the PetaLinux tool, see Setting Up Your Environment on AMD website.

  • Download and install the required third-party tools for the RFSoC device by using the Hardware Setup app. For more information, see hdlHardwareSetup.

Overview of the PetaLinux Image Build Process

You can use the PetaLinux tools to build, customize, and deploy embedded Linux distributions on AMD SoC and FPGA platforms. You can use PetaLinux to generate Linux images, including custom device trees, kernel configurations, and root file-system contents. This figure outlines the steps to create a custom Linux image for AMD SoC platforms.

To develop a custom Linux image, you:

  1. Create the PetaLinux project — Create a new PetaLinux project. You download a Board Support Package (BSP) from the hardware vendor website. The BSP includes board-specific configurations, boot files, and reference hardware designs.

  2. Import the hardware design — Integrate your hardware design and ensure the Linux image recognizes the connected peripherals and custom IP blocks.

  3. Configure the project — Set up the kernel, device tree, and root file-system options to match the target application requirements.

  4. Integrate Yocto layer — Add Yocto layers, such as the meta-mathworks layer, to extend the image with additional software, drivers, and tools.

  5. Build the image — Compile the kernel, device tree, and root file system into a deployable image.

  6. Package and deploy the image — Create a bootable image and copy it to an SD card or other boot media for use on the target board.

Clone GitHub Repositories

To build a Linux image for the ZCU216 RFSoC board, first clone the PetaLinux repository and a pre-configured MathWorks repository.

To clone the PetaLinux repository from GitHub®, run this command:

>> git clone https://github.com/mathworks/Petalinux.git

To clone the meta-mathworks layer from the main branch, run this command:

>> git clone -b main https://github.com/mathworks/meta-mathworks.git

To build the Linux image, follow the steps to configure the project with the necessary files and integrate the meta-mathworks layer. To use the pre-configured MathWorks repository, use this command to check out the latest branch from the PetaLinux repository:

>> git checkout mathworks_R2026a

Configure Project with Required Files

To configure the project with your hardware system architecture XSA file and root file system, follow these steps:

1. Source the PetaLinux tool by using this command. Enter the path to your PetaLinux installation path in the source command.

>> source <petalinux_installed_directory>/settings.sh

2. Configure the project with your XSA file. Provide the path to your XSA file. A sample XSA file is available in the PetaLinux repository under the mw_zcu216 folder.

>> petalinux-config --get-hw-description=<path_to_XSA_file>

To modify the hardware configuration settings, see Importing a Hardware Configuration on AMD website.

3. To add the required packages for the root file system, copy the below code in the user-rootfsconfig file located in the mw_zcu216/project-spec/meta-user/conf folder.

CONFIG_libserialport
CONFIG_libiio
CONFIG_boost
CONFIG_boost-dev
CONFIG_lttng-ust
CONFIG_lttng-ust-bin
CONFIG_mw-fs-overlay
CONFIG_rfdc
CONFIG_rfdc-read-write
CONFIG_rfdc-selftest
CONFIG_libsdfecusrintf
CONFIG_sdfec-demo
CONFIG_mw-rf-init
CONFIG_rftool-zcu216

4. Open the rootfs_config file in the mw_zcu216/project-spec/configs folder and apply these configuration settings in the file.

CONFIG_libserialport=y
CONFIG_libiio=y
CONFIG_boost=y
CONFIG_lttng-ust=y
CONFIG_lttng-ust-bin=y
CONFIG_mw-fs-overlay=y

To check whether you have initialized the root file system configuration settings and updated the PetaLinux project, run these commands:

>> cd petalinux-rfsoc/mw_zcu216/
>> petalinux-config -p . --silentconfig
>> petalinux-config -c rootfs -p . --silentconfig

Add meta-mathworks Layer

To add the meta-mathworks layer in the PetaLinux tool, open the configuration menu and, in the Yocto Settings menu**,** select User Layers. Then, select User Layer 0 and enter the path to the meta-mathworks layer.

Build Linux Image

Build the Linux image by running this command:

>> petalinux-build -p

After the build is successful, the Linux binaries are available in the folder build/tmp/deploy/images.

To update the device tree files, run this script:

>> remove_usp_rf_data_converter.sh /images/linux/system.dtb

Package Linux Image

After you build the Linux image, package the Linux image by running this command:

>>petalinux-package --boot --uboot -p --force

Copy these files from the /images/linux/ folder to your SD card:

  • BOOT.BIN

  • boot.scr

  • Image

  • rootfs.cpio.gz.u-boot

  • system.bit

  • system.dtb

You can now deploy the Linux image to the ZCU216 RFSoC board and boot the hardware from the SD card.

Build Linux Image by Using Preconfigured Script

You can also build the Linux image by using a script that automates the setup and building process. To use this script to generate a Linux image:

1. Navigate to the mw_zcu216 folder in PetaLinux directory.

>>cd mw_zcu216

2. Configure the project by using your XSA file.

>>petalinux-config --get-hw-description=<path_to_XSA_file>

3. To generate Linux image, run this build script.

>>./configure_and_build.sh <petalinux-installation> mw_zcu216/ <Meta-MW Layer folder>

See Also

Topics