Getting Started With Yocto

Install Yocto prerequisites

You can skip this section and continue with the Yocto installation if you have the required package versions installed (git, tar, Python and chrpath) :
wget http://downloads.yoctoproject.org/releases/yocto/yocto-2.2.1/buildtools/x86_64-buildtools-nativesdk-standalone-2.2.1.sh
chmod +x x86_64-buildtools-nativesdk-standalone-2.2.1.sh 
sh x86_64-buildtools-nativesdk-standalone-2.2.1.sh

source /opt/poky/2.2.1/environment-setup-x86_64-pokysdk-linux
You may always need to source the environment script before using Yocto, if your machine has incompatible versions of the required packages. e.g. if default Python is 2.7 instead of 3.

Install Yocto and additional required layers

You may want to change "pyro" to the Yocto version of your choice.
git clone git://git.yoctoproject.org/poky
cd poky && git checkout -b pyro origin/pyro && cd -

git clone git://git.openembedded.org/openembedded-core
cd openembedded-core && git checkout -b pyro origin/pyro && cd -

git clone git://git.openembedded.org/meta-openembedded
cd meta-openembedded && git checkout -b pyro origin/pyro && cd -

git clone git://git.yoctoproject.org/meta-xilinx
cd meta-xilinx && git checkout -b pyro origin/pyro && cd -

For building Images for zcu106, change to "warrior" version for each of the layers added.

cd poky && git checkout -b warrior origin/warrior && cd -

cd meta-xilinx && git checkout -b warrior origin/warrior && cd -

cd meta-openembedded && git checkout -b warrior origin/warrior && cd - 

cd openembedded-core && git checkout -b warrior origin/warrior && cd -

cd meta-yocto-bsp && git checkout -b warrior origin/warrior && cd-
Also, you can install meta-xilinx-tools layer for .hdf, .bit, BOOT.bin etc.
git clone https://github.com/Xilinx/meta-xilinx-tools.git
cd meta-xilinx-tools &&  git checkout master

Build Yocto image files for the Zynq SoC

Initialize your build environment:
cd poky
source oe-init-build-env

Edit the conf/bblayers.conf in order to include all the layers that are needed. Here is an example of bblayers.conf for zcu102, adjust the paths as necessary:

# POKY_BBLAYERS_CONF_VERSION is increased each time build/conf/bblayers.conf
# changes incompatibly
POKY_BBLAYERS_CONF_VERSION = "2"

BBPATH = "${TOPDIR}"
BBFILES ?= ""

BBLAYERS ?= " \
  /home/spiwoks/yocto/poky/meta \
  /home/spiwoks/yocto/poky/meta-poky \
  /home/spiwoks/yocto/poky/meta-yocto-bsp \
  /home/spiwoks/yocto/meta-xilinx \
  /home/spiwoks/yocto/meta-openembedded/meta-oe \
  /home/spiwoks/yocto/meta-openembedded/meta-python \
  "

Example of bblayers.conf for zcu106:

# POKY_BBLAYERS_CONF_VERSION is increased each time build/conf/bblayers.conf    
# changes incompatibly                                                                                                       
POKY_BBLAYERS_CONF_VERSION = "2"                                                                         
                                                                                                                                            
BBPATH = "${TOPDIR}"
BBFILES ?= ""

 BBLAYERS ?= " \
  /home/mamta/poky/meta \
  /home/mamta/poky/meta-poky \
  /home/mamta/poky/meta-yocto-bsp \
  /home/mamta/poky/meta-openembedded/meta-oe \
  /home/mamta/poky/meta-openembedded/meta-python \
  /home/mamta/poky/meta-openembedded/meta-systemd \
  /home/mamta/poky/meta-openembedded/meta-filesystems \
  /home/mamta/poky/meta-openembedded/meta-initramfs \
  /home/mamta/poky/meta-openembedded/meta-gnome \
  /home/mamta/poky/meta-openembedded/meta-networking \
  /home/mamta/poky/meta-openembedded/meta-webserver \
  /home/mamta/poky/meta-xilinx/meta-xilinx-bsp \
  /home/mamta/poky/meta-xilinx/meta-xilinx-contrib \
  /home/mamta/poky/meta-xilinx/meta-xilinx-standalone \
  "

Edit the conf/local.conf file and define the following:

  1. MACHINE = "zedboard-zynq7" (or MACHINE = "zcu102-zynqmp" depending on the type of your Zynq board).
  2. IMAGE_FSTYPES += "cpio.gz"

Additional options you can add in local.conf to get .dtb, .bit, BOOT.bin directly from Yocto build:
KERNEL_CLASSES += "kernel-fitimage" (for fitimage dependecy).

KERNEL_IMAGETYPES += "fitImage vmlinux"

UBOOT_ENTRYPOINT = "0x80000"

UBOOT_LOADADDRESS = "0x80000"

PREFERRED_PROVIDER_virtual/pmu-firmware = "pmu-firmware"

PREFERRED_PROVIDER_virtual/boot-bin = "xilinx-bootbin"

PREFERRED_PROVIDER_virtual/dtb = "device-tree"

Now you can build the image files for the Zynq processor. If you close the terminal and come back later, remember that you must first initialize your build environment : cd poky && source oe-init-build-env.
In order to create a minimal Embedded Linux Image for your $MACHINE, run:

bitbake core-image-minimal
You can find the resulting image files under tmp/deploy/images

Sometimes resulting images are present with symlinks, and you can use command below to copy images with symlinks resolved:

rsync --archive --copy-links --recursive ~/poky/build/tmp/deploy/images/zcu106-zynqmp/   <path to destination folder>

Boot the Zynq SoC using Yocto image files

The following instructions describe how to boot the Zynq SoC using an SD card.

Prepare the SD card:
First you create two partitions on the SD card as follows:
Run lsblk to find the SD card device number X (sdX) under /dev.
Run sudo fdisk /dev/sdX .
Type p to see the partition table, then type n to create a new one. Select p to make it primary. Use default partition number and first sector. Set aside 1G for this partition by typing +1G. Set the bootable flag by typing a. Make the root partition by typing n. Select primary partition, leave the first and last sector to its default values. If you check your partition table now, you should see the two partitions that you have just created (a * appears under Boot for the first partition). After verification type w to write to disk and exit.

Format the two partitions using the following commands:

mkfs.vfat -F 32 -n boot /dev/sdX1
mkfs.ext4 -L root /dev/sdX2

Copy the image files into the boot partition:
Next you copy the files required for booting to the boot partition of the SD card. Here is an example for the Zedboard (ARMv7 32-bit - Cortex A9):

  1. The boot file: BOOT.bin, created using Vivaldo SDK, containing: FSBL.elf, system.bit, and u-boot.elf, see PreparingBootBinFile
  2. A compatible device tree file: e.g. <yocto_build_dir>/tmp/deploy/images/zedboard-zynq7/system-top.dtb, see PreparingDeviceTreeBlob
  3. The kernel image file: <yocto_build_dir>/tmp/deploy/images/zedboard-zynq7/uImage-zedboard-zynq7.bin
  4. The U-Boot environment file: uEnv.txt

Here is an example of the U-Boot environment file uEnv.txt, adjust file and variable names as necessary:

machine_name=zcu106-zynqmp
kernel_image=Image
kernel_load_address=0x80000
devicetree_image=zynqmp-zcu106-revA.dtb
devicetree_load_address=0x4000000
bootargs=earlycon clk_ignore_unused root=/dev/mmcblk0p2 rw rootwait
loadkernel=fatload mmc 0 ${kernel_load_address} ${kernel_image}
loaddtb=fatload mmc 0 ${devicetree_load_address} ${devicetree_image}
bootkernel=run loadkernel && run loaddtb && booti ${kernel_load_address} - ${devicetree_load_address}
uenvcmd=run bootkernel

Copy the root file system into the root partition:
Copy the root file system into the root partition of the SD card. Assuming that the root partition is mounted at /media/root , run the following commands to extract the root file system:

cd <yocto_build_dir>/tmp/deploy/images/zedboard-zynq7
sudo cp core-image-tdaq-zedboard-zynq7.cpio.gz /media/root
cd /media/root
sudo gzip -d core-image-tdaq-zedboard-zynq7.cpio.gz
sudo cpio -idm < core-image-tdaq-zedboard-zynq7.cpio
sync

Boot the Zynq SoC using the SD card:
Insert the SD card into the SD reader of your Zynq board. Select booting from SD. Power cycle or reset the Zynq SoC.

RalfSpiwoks - 2018-05-11

Edit | Attach | Watch | Print version | History: r7 < r6 < r5 < r4 < r3 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r7 - 2019-11-08 - MamtaRamendraShukla
 
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    SystemOnChip All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2021 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
or Ideas, requests, problems regarding TWiki? use Discourse or Send feedback