Sunday, December 17, 2017

PetaLinux From Scratch (Xilinx MPSoC ZCU102) - Installation and Basic Run

Basic Glossary

  1. FSBL - First Stage Boot Loader (using the SDK).
  2. u-boot.elf - Linux boot loader.
  3. BOOT.BIN - which is the catenation of the FSBL, file system, system.bit(option), and u-boot.elf using the SDK.
  4. uImage - A Linux kernel named uImage.
  5. Devicetree - A devicetree blob named devicetree.dtb.
  6. A FAT32 partition on our SD card that comprises these files BOOT.BIN,uImage, and devicetree.dtb

Basic SD card

Basic SD card must contain the following files:
  • BOOT.BIN - includes FSBL, u-boot, file system and FPGA bitsteeam(optional), device tree (optional) http://www.wiki.xilinx.com/Prepare+boot+image
  • image.ub - linux kernel
  • rootfs.cpio.gz – file system
Optional:
  • system.dtb - Device tree (if not included in BOOT.BIN)
  • system.bit - FPGA bitstream (if not included in BOOT.BIN)
Installation

  1. Virtual machine


  1. Install virtual machine VirtualBox.
  2. Create new machine with ~120GB HD
  3. Download Ubuntu x64 iso image, mount it and install.

  1. Folders


  1. Create workspace folder inside /home/usr: mkdir workspace
  2. Create petalinux and SharedFS folder inside workspace folder.

cd workspace
mkdir petalinux
mkdir SharedFS  


  1. Shared Folder between windows and Vbox


  1. Create Ubuntu-Shared folder inside Windows
  2. Add Ubuntu-Shared to Vbox Shared folders.
  3. Mount the folder inside Ubuntu

sudo mount -t vboxsf Ubuntu-Shared /home/<user name>/workspace/SharedFS/

  1. Install Packages 

The follow packages are necessary
sudo apt --yes --force-yes update
sudo apt --yes --force-yes upgrade
python --version
sudo apt --assume-yes install tofrodos
sudo apt --assume-yes install iproute2
sudo apt --assume-yes install gawk
sudo apt --assume-yes install xfvb
sudo apt --assume-yes install git
sudo apt --assume-yes install net-toolsp
sudo apt --assume-yes install tftpd
sudo apt --assume-yes install zlib1g-dev
sudo apt --assume-yes install libssl-dev
sudo apt --assume-yes install flex
sudo apt --assume-yes install bison
sudo apt --assume-yes install libselinux1
sudo apt --assume-yes install gnupg
sudo apt --assume-yes install wget
sudo apt --assume-yes install diffstat
sudo apt --assume-yes install chrpath
sudo apt --assume-yes install socat
sudo apt --assume-yes install xterm
sudo apt --assume-yes install autoconf
sudo apt --assume-yes install libtool
sudo apt --assume-yes install unzip
sudo apt --assume-yes install texinfo
sudo apt --assume-yes install zlib1g-dev
sudo apt --assume-yes install gccmultilib
sudo apt --assume-yes install gcc-multilib
sudo apt --assume-yes install build-essential
sudo apt --assume-yes install libsdl1.2-dev
sudo apt --assume-yes install libglib2.0-dev
sudo apt --assume-yes install screen
sudo apt --assume-yes install gzip
sudo apt --assume-yes install libncurses5-dev
sudo apt --assume-yes install xvfb
sudo apt --assume-yes install zlib1g:i386

  1. Create TFTP

sudo nano /etc/xinetd.d/tftp
Paste below:
    service tftp
    {
    protocol        = udp
    port            = 69
    socket_type = dgram
    wait            = yes
    user            = nobody
    server          = /usr/sbin/in.tftpd
    server_args = /tftpboot
    disable         = no
    }
note: Don’t forget ti save the file ctrl+o and exit ctrl+x

note: under root
sudo mkdir /tftpboot
sudo chmod -R 777 /tftpboot
sudo chown -R nobody /tftpboot
sudo service xinetd restart

  1. Install PetaLinux SDK

  1. Download the installer:

  1. Install the SDK to /workspace/petalinux/:
./petalinux-v2017.2-final-installer.run ~/workspace/petalinux/

  1. Load SDK Environments variables
source ~/workspace/petalinux/settings.sh


  1. Install Xilinx SDK (if you want to compile something)

  • Download Software Development Kit Standalone WebInstall Client:

Note: you need internet connection

  • Change the file access permission:
sudo chmod +x Xilinx_SDK_2017.2_0616_1_Lin64.bin
   
  • Install SDK by:
sudo ./Xilinx_SDK_2017.2_0616_1_Lin64.bin

  • Install the SDK to:
/home/bspdeveloper/workspace/Xilinx-SDK


How to Generate Reference Design (TRD)
  • Download TRD reference design zip file:
  • Extract zip file to:
~/workspace/peta-builds/<trd name>
  • Enter the extracted folder (must)
~/workspace/peta-builds/<trd name>/apu/petalinux_bsp

  • Load SDK environments
Source ~/workspace/petalinux/settings.h

  • Compile the reference design
petalinux-build

Note: For more option see petalinux-build --help

How to use ZCU102 BSP
  1. Create new project

  • Download bsp file for ZCU102:

  • Save the bsp file for example:
~/workspace/peta-builds/

  • Create new Petalinux project and import bsp
source ~/workspace/petalinux/settings.sh
cd ~/workspace/peta-builds/bsp
petalinux-create -t project -s xilinx-zcu102-v2017.2-final.bsp

  1. Import HDF (Hardware configuration file) from vivado

Copy HDF file to project folder
For example:
~/workspace/peta-builds/bsp/hdf
cd ~/workspace/peta-builds/xilinx-zcu102-2017.2/
petalinux-config --get-hw-description=~/workspace/peta-builds/bsp/hdf

  • Compile bsp again
cd ~/workspace/peta-builds/bsp/xilinx-zcu102-2017.2
petalinux-build

Configuring Devicetree
  1. System-user.dtsi

PetaLinux device tree configuration is associated with following config file
~/workspace/peta-builds/<projectname>/project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi

Which can be modified, please note that any changes on other dtsi files will be overwrite after compile
  1. Generated files

All the generated device tree files are located in:
~/workspace/peta-builds/<project name>/components/plnx_workspace/device-tree-generation/

Generate BOOT.BIN Image
petalinux-package --boot --fsbl <FSBL image> --fpga <FPGA bitstream> --pmufw <PATH_TO_PMU_FW_ELF> --u-boot

For example:

petalinux-package --boot --fsbl zynqmp_fsbl.elf --u-boot --force

or

petalinux-package --boot --fsbl zynqmp_fsbl.elf --fpga zcu102_top.bit --u-boot --force

Boot a PetaLinux Image on Hardware with SD Card
Copy the following files from <plnx-proj-root>/pre-built/linux/images/ into the root directory of the first partition which is in FAT32 format in the SD card:
  • BOOT.BIN
  • image.ub

No comments:

Post a Comment