har-in-air / EBAZ4205_PETALINUX

Petalinux 2022.2 build for EBAZ4205 board with Zynq 7010 SOC

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Petalinux 2022.2 for EBAZ4205 board with Zynq 7010

Environment

  • Ubuntu 22.04LTS on amdx64 machine
  • Xilinx Unified Installer 2022.2 SFD
    • Select Vitis - this will install Vitis and Vivado Design suite
    • Run again and select Petalinux (install in the same directory)
    • Install updates
    • Download Petalinux sstate-cache and pre-mirror archives to avoid repetitive downloading from network during build process
    • Install cable drivers

Credits

EBAZ4205 hardware modifications

The board has a Zynq 7010 (CLG400 package), 256MByte DDR3 RAM, 128MByte Nand Flash, 100Mbps Ethernet. I made the following changes to my board :

  1. Installed microSD socket (shipped with the board).
  2. Installed 25MHz crystal Y3 and 22pF caps for Ethernet PHY. R1485 not populated.
  3. Installed 25MHz crystal oscillator X5 and associated passive R,C,L components for PL clock, connected to Zynq 7010 pin N18.
  4. Installed SPDT switch for selecting boot via SD card or Nand Flash. For SD boot, Zynq pin U12-IO0_0 is connected to GND via R2584. For SD boot, pin U12-IO0_0 is connected to VCC via R2577. When SD boot is selected and the SD card is not detected on power-on, falls back to JTAG.
  5. Installed push button switch S3 plus associated R, C components.
  6. Installed diode SS810 (D24) to supply power from the ATX connector. The board documentation shows 12V, but that was required for cooling fans in the original bit-mining application. I use a standard 5V 2A adapter to supply power.

Create hardware platform using Vivado

Regenerate the Vivado 2022.2 project using the tcl script provided in the folder /hw.

Start Vivado, then in the TCL console at the bottom, navigate to the directory containing the script

cd <full path to script directory>
source ./ebit_7010_proj_gen.tcl

Once the project has been regenerated, click on Generate Bitstream. When that is complete, run File->Export->Export Hardware. Select Include bitstream. This will finally generate a Vivado hardware description file ebit_7010_top_wrapper.xsa.

Create project using Vivado generated hardware description file (.xsa)

Set environment variables for Petalinux paths. Make sure to set the Petalinux tools path correctly in this script, for your installation.

$ source ./petalinux_env.sh
$ petalinux-create --type project --template zynq --name petalinux_sd

$ cd petalinux_sd

Specify the exported hardware description file from the Vivado project

$ petalinux-config  --get-hw-description=<full path to>/ebit_z7010_top_wrapper.xsa

In the pop-up menuconfig dialog :

  • Check hardware components (DDR, Enet, UART, SDIO) are present

  • Image Packaging Configuration

    • For SD boot, change Root filesystem type from RAM initrd to ext4 (sd/eMMC/SATA/USB)
    • Disable Copy final images to tftpboot
  • Yocto settings : Use pre-downloaded archives during the build process instead of downloading from network

    • change sstate archive from network site http://xxx to local directory file:///home/<path to downloaded archive>/arm/

    • change pre-mirror url from network site http://xxx to local directory file:///home/<path to downloaded archive>/downloads/

    • Disable Network downloads

    • For SD boot : Use EXT4 rootfs during boot

    Method A: PetaLinux config

    Disable DTG settings -> Kernel Bootargs -> generate boot args automatically

    Update User Set Kernel Bootargs to

    earlycon console=ttyPS0,115200 clk_ignore_unused root=/dev/mmcblk0p2 rw rootwait cma=8M 
    

    Method B: device tree

    Update in system-user.dtsi Add chosen node in root in addition to the previous changes to this file.

    / {
       chosen {
          bootargs = "earlycon console=ttyPS0,115200 clk_ignore_unused root=/dev/mmcblk0p2 rw rootwait cma=512M";
       };
    };
    

Configure the kernel

$ petalinux-config -c kernel

Nothing to change in menuconfig dialog, exit and save

Configure u-boot

$ petalinux-config -c u-boot

Boot Media

For SD boot, enable booting from SD Card, disable other options.

For initrd RAM boot, leave all unchecked.

Configure Root file system

$ petalinux-config -c rootfs

User packages : add gpio-demo and peekpoke

Build

$ petalinux-build

JTAG download and boot using initrd RAM

Verify JTAG adapter connection to Zynq

  1. Open Vivado hardware project
  2. Open Hardware Manager
  3. Open target. This should detect the JTAG adapter. I use a Xilinx Platform Cable USB II DLC10.
  4. Connect and verify that you can see the Zynq target.
  5. Disconnect.

JTAG boot

$ petalinux-boot --jtag --kernel

This will download the bitstream, first-stage bootloader, device tree, u-boot, kernel image and root file system to DDR memory, and then start the boot process.

I use minicom terminal @ 115200baud to monitor the download and boot process.

system.bit
zynq_fsbl.elf
system.dtb at 0x00100000
u-boot.elf
uImage at 0x00200000
rootfs.cpio.gz.u-boot at 0x04000000
boot.scr at 0x03000000

...

After several minutes, you should finally see the login prompt. The user is petalinux

login : petalinux
set the password

Boot from SD card

Create the BOOT.BIN file

$ cd images/linux
$ petalinux-package --boot --fsbl zynq_fsbl.elf --fpga system.bit --u-boot u-boot.elf -o BOOT.BIN --force

This is the output

[INFO] Sourcing buildtools
INFO: Getting system flash information...
INFO: File in BOOT BIN: "/home/nair/fpga/ebit/ebaz4205/petalinux_ram/images/linux/zynq_fsbl.elf"
INFO: File in BOOT BIN: "/home/nair/fpga/ebit/ebaz4205/petalinux_ram/images/linux/system.bit"
INFO: File in BOOT BIN: "/home/nair/fpga/ebit/ebaz4205/petalinux_ram/images/linux/u-boot.elf"
INFO: File in BOOT BIN: "/home/nair/fpga/ebit/ebaz4205/petalinux_ram/images/linux/system.dtb"
INFO: Generating zynq binary package BOOT.BIN...

****** Xilinx Bootgen v2022.2
  **** Build date : Sep 26 2022-06:24:42
    ** Copyright 1986-2022 Xilinx, Inc. All Rights Reserved.

[WARNING]: Partition zynq_fsbl.elf.0 range is overlapped with partition system.bit.0 memory range
[WARNING]: Partition system.bit.0 range is overlapped with partition system.dtb.0 memory range

[INFO]   : Bootimage generated successfully

INFO: Binary is ready.

The warning about overlap can be ignored, both files are being copied to the same memory partition, but are not actually overlapping in destination memory address ranges.

You can verify the layout of BOOT.BIN using the command

$ bootgen -arch zynq -read BOOT.BIN

Prepare SD card

Create boot and root file system partitions

On my system, the SD card shows up as /dev/sdb. I used a 32GB card, with 1GB allocated for the boot partition and the remainder for the root file system.

$ sudo fdisk /dev/sdb

Create two partitions

partition 1, primary, default offset, size +1024MB, FAT32 (0x0b), bootable
partition 2, primary, default offset, default size, Linux (0x83)

Format the partitions

$ sudo mkfs.msdos -n BOOT /dev/sdb1
$ sudo mkfs.ext4 -L rootfs /dev/sdb2

Mount the fat32 partition (in my case it is mounted at /media/nair/BOOT) and copy the required boot files

$ cp BOOT.BIN /media/nair/BOOT
$ cp boot.scr /media/nair/BOOT
$ cp image.ub /media/nair/BOOT 
$ sync

Write root file system

Method 1 : using build output rootfs.ext4

If the ext4 partition is mounted, unmount it before dd command

$ sudo umount /dev/sdb2
$ sudo dd if=rootfs.ext4 of=/dev/sdb2

Resize the ext4 partition to the full space available (~31GB).

$ sudo resize2fs /dev/sdb2
$ sudo e2label /dev/sdb2 "rootfs"

Mount the partition again

Method 2 : using rootfs.cpio build output

$ sudo cp rootfs.cpio /media/nair/rootfs
$ cd /media/nair/rootfs
$ sudo pax -rvf rootfs.cpio

Method 3 : using rootfs.tar.gz build output

Ensure the root partition is mounted. In my case it is mounted at /media/nair/rootfs.

$ sudo tar xvzf rootfs.tar.gz -C /media/nair/rootfs

Set ownership and permissions

$ sudo chown root:root /media/nair/rootfs/
$ sudo chmod 755 /media/nair/rootfs/

Flush caches to SD

$ sync

Safely eject the card

Clean project before rebuilding

rm -rf components/plnx_workspace
petalinux-build -x distclean
petalinux-build -x mrproper --force

Archive petalinux project

Method 1 : generate bsp

$ petalinux-package --bsp -p ./petalinux_sd --hwsource ./vivado --output petalinux_sd_may12.bsp

Method 2 : Clean and tar

$ petalinux-build -x mrproper
$ cd ..
$ tar -czvf petalinux_sd_may12.tar.gz ./petalinux_sd

Re-create petalinux project from bsp file

$ petalinux-create -t project -s petalinux_sd_may12.bsp

About

Petalinux 2022.2 build for EBAZ4205 board with Zynq 7010 SOC


Languages

Language:Tcl 99.8%Language:Shell 0.2%