Xilinx Zynq Ultrascale+ DDR Memory Reservation


Useful Links

Required Tools

  • Linux OS
  • Xilinx Vivado 2018.2
  • Xilinx SDK 2018.2
  • Petalinux 2018.2 Installer
  • Ultra96 BSP
  • Pynq ULTRA96 Disk Image
  • Image Writer (Win32DiskImager)
  • 16Gb Micro SD card

Step 1 – Prepare your environment

  • Update your linux
    • Open terminal.
    • Run: “sudo apt-get update”.
    • Run: “sudo apt-get upgrade“.
  • Install following packages (use sudo apt-get install “package name”):
tofrodosiproute2gawkxvfb
gitmakenet-toolslibncurses5-dev
tftpdzlib1g-devlibssl-devflex
bisonlibselinux1gnupgwget
diffstatchrpathsocatxterm
autoconflibtooltarunzip
texinfozlib1g:i386gcc-multilibbuild-essential
libsdl1.2-devlibglib2.0-devscreenpax
gzip python  

Comment: if you miss one of the packages, petalinux installation will stop and the installer will list all missing packages.

Step 2 – Install Petalinux

  • Check that your host system (“ls –al /bin/sh”) is bash
    • If not type: 
      • sudo rm /bin/sh
      • sudo ln -s /bin/bash /bin/sh
      • check that it is now pointing to bash (“ls –al /bin/sh”)

Comment:you cannot install petalinux as root user (with “sudo” command). You can install it to any folder that has the 755 permissions. In this example petalinux will be installed in “Downloads” folder

  • Create a folder “mkdir –p  /home/osboxes/Downloads/petalinux”.
  • Go to “/home/osboxes/Downloads/petalinux and type “chmod 775 .” to change permissions settings.
  • Go to the folder with the petalinux installer and type “./petalinux-v2018.2-final-installer.run / osboxes/Downloads/petalinux”.
  • During this step, you the installation might stop with an error that you are missing system tools or libraries. Go back to step 1 and install missing libriaries.
  • Installation will take some time.

At the end, you will see:

Comment: every time when starting to work with petalinux Source settings script by typing “source settings.sh” in the petalinux folder

Step 3 – Install BSP

  • Create a folder for your projects “/osboxes/Downloads/petalinux/projects”.
  • Type: “cd /osboxes/Downloads/petalinux/projects”.
  • Type“petalinux-create –t project –s <path to ultra96 bsp>”.

Comment: further steps are optional.
To make changes in the device tree go to step 4
To build standard Xilinx petalinux go to step 5
To install PYNQ petalinux go to step 6

Step 4 – Edit Device tree (optional)

  • You can find ULTRA96 device tree in “/osboxes/Downloads/petalinux/projects/Xilinx-ultra96-reva-2018.2/project-spec/meta-user/recipes-bsp/device-tree/files”
  • You need to edit “system-user.dtsi” file (below shown the example of memory reservation with different drivers
/include/ "system-conf.dtsi"
/include/ "openamp-overlay.dtsi"
/{
memory {
                reg = <0x0 0x0 0x0 0x80000000>;
        };
        reserved-memory {
                #address-cells = <2>;
                #size-cells = <2>;
                ranges;

                reserved_1: osc@5e000000 {
                        reg = <0x0 0x5e000000 0x0 0x2000000>;
			compatible = "generic-uio";
                };

                reserved_2: buffer1@6e000000 {
			compatible = "shared-dma-pool";
			reusable;
                        reg = <0x0 0x6e000000 0x0 0x2000000>;
			linux,cma-default;
                };	
        };
};
  • Save your changes.

Step 5 – Build Standard Petalinux

  • Go to “/osboxes/Downloads/petalinux/projects/Xilinx-ultra96-reva-2018.2”.
  • Type “petalinux-build”.
  • At this point you can get the following error: 
  • You can use Atilla solution to work around this error.
  • Build will take some time.After build has finished go to “/osboxes/Downloads/petalinux/projects/Xilinx-ultra96-reva-2018.2/images”
  • Run: “petalinux-package –boot –fsbl components/plnx_workspace/fsbl/fsbl/Release/fsbl.elf –fpga hardware/xilinx-ultra96-reva-2018.2/xilinx-ultra96-reva-2018.2.runs/impl_1/design_1_wrapper.bit –pmufw components/plnx_workspace/pmu-firmware/pmu-firmware/Release/pmu-firmware.elf –u-boot”
  • Go to “/osboxes/Downloads/petalinux/projects/Xilinx-ultra96-reva-2018.2/images/linux”
  • Copy BOOT.bin & image.ub to the boot partition of the SD card.
  • Keep standard petalinux file system.
  • Insert SDcard in the board and turn it on. Petalinux will boot.

Step 6 – Build PYNQ Petalinux

  • Go to https://github.com/Xilinx/PYNQ/tree/master/sdbuild/boot
  • Download “meta-pynq” folder.
  • Add PYNQ meta-layer to your Petalinux project by coping “meta-pynq” folder to the “/osboxes/Downloads/petalinux/projects/Xilinx-ultra96-reva-2018.2/project-spec” folder
  • Run: “petalinux-config” –> Yocto Settings —> User Layers —>
  • Run: ${proot}/project-spec/meta-pynq
  • Exit config window
  • Verify by viewing the file in /build/conf/bblayers.conf.
  • Run: “petalinux-build” command
  • Run: “petalinux-package –boot –fsbl components/plnx_workspace/fsbl/fsbl/Release/fsbl.elf –fpga hardware/xilinx-ultra96-reva-2018.2/xilinx-ultra96-reva-2018.2.runs/impl_1/design_1_wrapper.bit –pmufw components/plnx_workspace/pmu-firmware/pmu-firmware/Release/pmu-firmware.elf –u-boot”
  • Format your microSD card.
  • Write ultra96_v2.3.img to your SD card.
  • Go to the boot partition and delete all the files (BOOT.BIN & image.ub)
  • Go to“/osboxes/Downloads/petalinux/projects/Xilinx-ultra96-reva-2018.2/images/linux”
  • Copy new BOOT.bin & image.ub to the boot partition of the SD card.
  • Keep PYNQ file system
  • Insert SDcard in the board and turn it on. Petalinux with PYNQ will boot.