Petalinux Project Creation- Short HOWTO

Getting Linux working on Zynq is very simple, following steps are required

  1. Vivado/SDK/PetaLinux 20xx.x installed (important do not mix versions!)
  2. Create Vivado Project, configure PS, Export HDF (XSA for 19.2 and newer)
  3. Ceate new PetaLinux project
  4. Import HDF(XSA for 19.2 and newer) into project
  5. petalinux-build
  6. copy boot.bin and image.ub to SD Card (only 2 files no more)

This is generic how-to, everything is setup for your by the Vivado->PetaLinux flow. Note, the boot.bin generated by PetaLinux may not always work, in such case it is recommended to make the boot.bin with SDK-GUI or command line tools manually.

There is no need to install anything else, or to fetch anything from any github repos, etc.

PetaLinux 2023.2

Petalinux 2023.2 is under review documentation for 2023.2 can be changed permanently at the moment

PetaLinux Installation

  • (optional) Create new VM with supported Linux OS.

    • Petalinux is evaluated on Windows WSL with Ubuntu, see: AMD Tools and Win10 WSL
      • other VMs or native Linux Distribution is possible, but maybe changes are needed.
  • Download PetaLinux  from Xilinx Website: http://www.xilinx.com/support/download/index.html/content/xilinx/en/downloadNav/embedded-design-tools.html

    • Choose  a PetaLinux Version, that's corresponding to the installed Vivado and SDK Version.

      • Example: Use Vitis (SDK+Vivado) 2023.2 with PetaLinux 2023.2

    • Note Petalinux is also available from Vivado/Vitis Installation setup
  • Use UG1144 "PetaLinux Tools Documentation - Reference Guide" that's corresponding with your PetaLinux Version

    1. Use bash as terminal:

      1. $ sudo dpkg-reconfigure dash 

        1. → press no

    2. Check "PetaLinux Tools Installation Requirements" chapter and install missing tool/libraries

      1. Install packages(see https://support.xilinx.com/s/article/000035572?language=en_US  → PetaLinux_2023.2_OS_Package_List.xlsx)

        1. Note:

          1. From excel  additional to python3 also python was recommended which is not longer possible to install

          2. Additionally bc  and was libtinfo5 added
          3. Add subversion (need only in case svn is used)
          4. Add u-boot-tools (need to generate own boot.scr file instead of petalinux version)
        2. sudo apt-get install iproute2 gawk python3 build-essential gcc git make net-tools libncurses5-dev tftpd zlib1g-dev libssl-dev flex bison libselinux1 gnupg wget git diffstat chrpath socat xterm autoconf libtool tar unzip texinfo zlib1g-dev gcc-multilib automake zlib1g:i386 screen pax gzip cpio python3-pip python3-pexpect xz-utils debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev pylint bc libtinfo5 subversion u-boot-tools -y

    3. Install petalinux (Note: do not start from shared folder, copy installer into home directory)

      1. $ sudo mkdir /tools
      2. $ sudo mkdir /tools/Xilinx
      3. $ sudo chown <owner>:<owner> /tools/Xilinx

      4. $ copy  FPGAs_AdaptiveSoCs_Unified_2023.2_1013_2256.tar.gz into ~/
      5. $ tar -xvf FPGAs_AdaptiveSoCs_Unified_2023.2_1013_2256.tar.gz
      6. $ cd FPGAs_AdaptiveSoCs_Unified_2023.2_1013_2256
      7. $ ./xsetup

    4. source enviroment

      1. $ source /tools/Xilinx/PetaLinux/2023.2/tool/settings.sh

    5. Deactivate Webtalk:

      1. $ petalinux-util --webtalk off

  • Note:

    • There is no need to install anything else, or to fetch anything from any github repos, etc.

    • It is recommended to test the installation by creating a dummy template project and building it.

      • Download one of the BSP Examples from Xilinx Website (Only to test your installation)

      • Install:$ petalinux-create -t project -s <path-to-bsp>

      • Build: $ petalinux-build

Creating a Project from Vivado Project

Some reference designs contains a preconfigured PetaLinux project as template. This can be used instead of creating a new project described on step 2.

Basic Note to TE Petalinux Templates, see: PetaLinux TE-Template#PetaLinux2023.2

New with 2023.2 and newer:

  • ... TBD

New with 2022.2 and newer:

  • Separate Device Tree for U-boot possible
  • Device tree for uboot must be included into the Boot.bin

New with 2020.2 and newer:


  1. PetaLinux Working Environment (see UG1144)
    • PetaLinux Tools Installation is completed.
    • (Note: do not create project from shared folder, use home directory)
    • "/bin/sh" is bash

    • Set Working Environment:
      • $ source <path-to-installed-PetaLinux>/settings.sh
  2. (optional to create project from scretch instead of Trenz Templates) Create a New Project (see UG1144): 
    1. $ petalinux-create --type project --template <CPU_TYPE> --name <PROJECT_NAME>

      • <CPU_TYPE>: zynqMP, zynq, microblaze
      • <PROJECT_NAME>:The name of the project you are building
  3. Import Hardware Configuration (see UG1144):
    • Export Hardware Definition File (*.xsa) from the Vivado Project into the PetaLinux root folder "<plnx-proj-root>":
      • change to PetaLinux root folder:
      • Run:$ petalinux-config --get-hw-description
  4. (optional) Configure your PetaLinux:
    • While anywhere in the project folder tree:
    • Run:$ petalinux-config
    • Run:$ petalinux-config -c u-boot
    • Run:$ petalinux-config -c kernel
    • Run:$ petalinux-config -c rootfs
  5. Build System Image (see UG1144):
    • While anywhere in the project folder tree:
    • Run:$ petalinux-build
  6. Generate Boot.bin with Vitis tools (recommended)
    1. Take u-boot.elf,  image.ub,  bl31.elf (ZynqMP only) from "<plnx-proj-root>/images/linux" for BOOT.BIN generation, also boot.scr is used (put separate on SD or include into Boot.bin for QSPI boot only).  It is recommended to create the FSBL and PMU Firmware (ZynqMP only) with Vitis tools.
  7. Generate Boot.bin with Petalinux
    1. Run:$ petalinux-package --boot <command options>
    2. https://docs.xilinx.com/r/en-US/ug1144-petalinux-tools-reference-guide/petalinux-package-boot

Petalinux Configuration

Use local sstate cache and downlods

  • Download (https://www.xilinx.com/support/download/index.html/content/xilinx/en/downloadNav/embedded-design-tools.html):
    • aarch64 sstate-cache
      • for Versal, U+Zynq, RFSoC projects
    • arm sstate-cache
      • for 7 series Zynq projects
    •  microblaze sstate-cache 
      • for microblaze full projects
    • Downloads 
      • forall types
  • extract files for example in
    • mkdir ~/design/sstate-cache
    • cd ~/design/sstate-cache
    • copy archives into this folder
    • tar -xfv sstate_aarch64_2023.2_10121051.tar.gz
    • tar -xfv sstate_arm_2023.2_10121051.tar.gz
    • tar -xfv sstate_microblaze_2023.2_10121051.tar.gz
    • mkdir ~/design/sstate-cache/downloads_2023.2
    • cd ~/design/sstate-cache/downloads_2023.2
    • copy archives into this folder
    • tar -xfv downloads_2023.2_10121051.tar.gz
    • delete archive files
  • change to the petalinux project
    • petalinux-config
      • for sstate-cache
        • -> Yocto Settings->Local sstate feeds settings->local sstate feeds url
          • ~/design/sstate-cache/sstate_aarch64_2023.2/aarch64
          • ~/design/sstate-cache/sstate_aarch64_2023.2/arm
          • ~/design/sstate-cache/sstate_aarch64_2023.2/mb-full
          • original: http://petalinux.xilinx.com/sswreleases/rel-v${PETALINUX_MAJOR_VER}/aarch64/sstate-cache
      • for downloads
        • -> Yocto Settings-> Add pre-mirror url
          • file://~/design/sstate-cache/downloads_2023.2/downloads
          • orginal:http://petalinux.xilinx.com/sswreleases/rel-v${PETALINUX_MAJOR_VER}/downloads
  • Clear petalinux project
    • petalinux-build -x mrproper

Configuration menues and files

Most settings can be changed with menu-config:

  • petalinux-config
  • petalinux-config -c u-boot
  • petalinux-config -c kernel
  • $  petalinux-config -c rootfs


Manual changes can be done in the subfolder "<plnx-proj-root>/project-spec/meta-user/"

CONFIG
  • project-spec/config/config
  • changes with "petalinux-config" will be saved here
U-Boot
  • recipes-bsp/u-boot/files
  • recipes-bsp/u-boot/files/platform-top.h
  • recipes-bsp/uboot-device-tree/files/ystem-user.dtsi
  • changes with "petalinux-config -c u-boot" will be add to meta-user as recipes
  • optional overwrite, add UBoot settings on platform-top.h
  • Important:: Separate Device tree is disabled on default project generation, it must be enabled on petalinux-config menue under u-boot configuration otherwhise linux device tree will be used
Device Tree
  • recipes-bsp/device-tree/files/system-user.dtsi
  • recipes-bsp/device-tree/files/pl-custom.dtsi
  • overwrite or add device tree attributes
Kernel
  • recipes-kernel/linux/linux-xlnx/
  • changes with "petalinux-config -c kernel" will be add to meta-user as recipes 
Apps
  • project-spec/meta-user/recipes-apps
  • add simple new app with "petalinux-create -t apps -n myapp --enable"
  • enable/disable with "petalinux-config -c rootfs"
ROOTFS
  • project-spec/config/rootfs_config
  • project-spec/meta-user/conf/user-rootfsconfig
  • "petalinux-config -c rootfs" will save changes in the general config spec, only apps will be saved in user-rootfsconfig also
  • user-rootfsconfig must be changed manually and will read after rootfs_config is used
Xilinx  generated configuration
  • project-spec/config/
Note: config and rootfs_config are shared at the moment, they include user and xilinx default changes from XSA import

Additional Descriptions

References

  1. PetaLinux Tools Documentation - Reference Guide (UG1144)
  2. PetaLinux Tools Documentation - PetaLinux Command Line Reference (UG1157)

  3. https://www.devicetree.org/
    1. https://www.devicetree.org/specifications/
  4. https://github.com/Xilinx/linux-xlnx/tree/master/Documentation/devicetree/bindings

PetaLinux Troubleshoot

Petalinux 2023.2

General notes

Xilinx Release Notes available on: https://support.xilinx.com/s/article/000035572?language=en_US

BL31 gets Stuck during booting

Issue

Petalinux 2023.2 seems to have a Problem booting with UART1: It gets stuck on BL31 while trying to print a char to UART1 during booting.

This error happens on Versal and Zynq Ultrascale+ devices. The error is that BL31 built by petalinux does not correctly take into account that UART1 is used, and tries to output on UART0

Workaround

This can be fixed by e.g. overriding yourself with creating arm-trusted-firmware_%.bbappend in meta-user/recipes-bsp/arm-trusted-firmware with content

For Versal: ATF_CONSOLE = "pl011_1" 

For Zynq Ultrascale+: ATF_CONSOLE = "cadence1" 


Modified FSBL is not containing patches

Issue
Trenz modified FSBL for petalinux is not taken into account from petalinux. This is only need on trenz project which has FSBL patch included inside the petalinux template. --><project folder>\os\petalinux\project-spec\meta-user\recipes-bsp\embeddedsw
AMD has changed patch priority and petalinux ignores provided FSBL patch in \os\petalinux\project-spec\meta-user\recipes-bsp\embeddedsw
Workaround

In order for the patches to be used, the existing line BBFILE_PRIORITY_meta-user = "[VALUE]" must be set to 9 instead of the original value 7 in the Petalinux config file project-spec/meta-user/conf/layer.conf

 Error Verifying contents on S15FL127S QSPI flash memory chip

Issue

When writing an S15FL127S QSPI Chip from Linux via flashcp the verification fails. This is a driver issue of Linux  as FL127 needs a page size of 256.

Workaround
  • To solve the programming problem in linux console via "flashcp" command:
    • Add the following patch file in linux kernel files:

      • 0001-fix-for-s25fl127s.patch
        From f3d982f01a0a7112b8d461f450082d502df1a23d Mon Sep 17 00:00:00 2001
        From: OpenEmbedded <oe.patch@oe>
        Date: Thu, 25 Apr 2024 10:43:18 +0000
        Subject: [PATCH] fix for s25fl127s
        
        ---
         drivers/mtd/spi-nor/spansion.c | 3 ++-
         1 file changed, 2 insertions(+), 1 deletion(-)
        
        diff --git a/drivers/mtd/spi-nor/spansion.c b/drivers/mtd/spi-nor/spansion.c
        index 104de1252b04..0ee9ff9627e1 100644
        --- a/drivers/mtd/spi-nor/spansion.c
        +++ b/drivers/mtd/spi-nor/spansion.c
        @@ -383,10 +383,11 @@ static const struct flash_info spansion_nor_parts[] = {
         		NO_SFDP_FLAGS(SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ)
         		MFR_FLAGS(USE_CLSR)
         	},
        -	{ "s25fl128s1", INFO6(0x012018, 0x4d0180, 64 * 1024, 256)
        +	{ "s25fl127s", INFO6(0x012018, 0x4d0180, 64 * 1024, 256) //fl127 need page size of 256
         		FLAGS(SPI_NOR_HAS_LOCK)
         		NO_SFDP_FLAGS(SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ)
         		MFR_FLAGS(USE_CLSR)
        +		.fixups = &s25fs_s_nor_fixups,
         	},
         	{ "s25fl256s0", INFO6(0x010219, 0x4d0080, 256 * 1024, 128)
         		FLAGS(SPI_NOR_HAS_LOCK)
        
        


    • Add the patch file in the linux-xlnx_%.bbappend file as shown:
      • linux-xlnx_%.bbappend
        FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
        
        SRC_URI:append = " file://bsp.cfg \
          file://0001-fix-for-s25fl127s.patch"
        KERNEL_FEATURES:append = " bsp.cfg"



QSPI flash memory chip is not recognized

Issue

In Linux console the QSPI flash memory chip can not be detected. 

dmesg output contains: "Unknown JEDEC ID"

Workaround


  • To solve the detection problem in linux console: 
    • Set the maximum frequency of spi interface in the device tree.
    • The actual speed depends on the design and whether SPI clock feedback is used on the board
    • if you are not speed dependent, 40MHz is a safe value for any setting  
    • e.g. add the following line in the qspi node:
      • spi-max-frequency = <40000000>;



Table of contents


  • No labels