Xilinx Vivado, XSDK and Petalinux 2016.2 on Ubuntu 16.04

Just a list of a few new steps required to install and run Vivado, XSDK and Petalinux 2016.2 on Ubuntu 64bit 16.04:

  1. In order to run XSDK which can't use default GTK v3 we have to export new environmental variable. I usually add them at the end of my ~/.bashrc:

    export SWT_GTK3=0

  2. Another problem I discovered is when I open the Xilinx License Configuration Manager (XLCM) in Vivado Design Suite 2016.2, the HOST ID Matches column is shown as No. However, the host ID in the license file is correct. Looks like problem lies in new Ubuntu ethernet interface names and changing it back to eth0 fixes the issue. In order to make a change we have to add next settings to grub config in /etc/default/grub".

    GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0"

    Dont forget to update grub:

    sudo grub-mkconfig -o /boot/grub/grub.cfg

    Generating grub configuration file ...
    Warning: Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported.
    Found linux image: /boot/vmlinuz-4.4.0-31-generic
    Found initrd image: /boot/initrd.img-4.4.0-31-generic
    Found linux image: /boot/vmlinuz-4.4.0-21-generic
    Found initrd image: /boot/initrd.img-4.4.0-21-generic
    Found memtest86+ image: /boot/memtest86+.elf
    Found memtest86+ image: /boot/memtest86+.bin
    done

    Make changes to /etc/networking/interfaces and reboot:

    auto eth0
    iface eth0 inet dhcp

  3. Yet another source of problems - Vivado's settings64.sh: it sets LD_LIBRARY_PATH to point to Vivado/2016.2/lib/lnx64.o, but because its global it affects all binaries run within the shell where we source settings64.sh. In my case, I noticed problems with starting gedit and failed compilation of U-boot with error "awk: undefined symbol: mpfr_z_sub".
    Anyway, we actually can remove setting LD_LIBRARY_PATH from settings64.sh if your hardware design doesn't include AXI-BFM IP.

    #############################################################
    # Copyright (c) 1986-2016 Xilinx, Inc. All rights reserved. #
    ##############################################################

    export XILINX_VIVADO=/opt/Xilinx/Vivado/2016.2
    if [ -n "${PATH}" ]; then
    export PATH=/opt/Xilinx/Vivado/2016.2/bin:$PATH
    else
    export PATH=/opt/Xilinx/Vivado/2016.2/bin
    fi

    #if [ -n "${LD_LIBRARY_PATH}" ]; then
    # export LD_LIBRARY_PATH=/opt/Xilinx/Vivado/2016.2/lib/lnx64.o:$LD_LIBRARY_PATH
    #else
    # export LD_LIBRARY_PATH=/opt/Xilinx/Vivado/2016.2/lib/lnx64.o
    #fi

Linux Kernel 4.4 DTS node for Xilinx AXI-DMA IP.

I recently switch to Linux Kernel 4.4 (from 4.0) for some of my projects and to my no surprise found Xilinx AXI-DMA not working again. This time it complained that it can't find DMA channel: "unable to read dma-channels property" and as result "Probing channels failed." So, looks like Xilinx added support for "multi-channel mode" for kernel driver and this is a big deal! And I waited for this forever!

But, as a result of this - DTS node were changed again, braking compatibility. Also, if you using the only one DMA-channel either MM2S or S2MM channel index in your custom DTS node must be 0 in either case, unlike before if you were using only s2mm index was 1 and if only mm2s index was 0.

So, below example of DTS node for AXI DMA and modified xilinx_dmatest(single channel) which works for me for Linux 4.4

axidma0: axidma@40400000 {
        compatible = "xlnx,axi-dma-1.00.a";
        #dma-cells = <1>;
        reg = <0x40400000 0x10000>;
        interrupt-parent = <&intc>;
        dma-channel@40400030 {
                compatible = "xlnx,axi-dma-s2mm-channel";
                dma-channels = <1>;
                interrupts = <0 29 4>;
                xlnx,datawidth = <32>;
                xlnx,include-dre = <0>;
        };
} ;

dmatest0: dmatest@0 {
	compatible ="xlnx,axi-dma-test-1.00.a";
	dmas = <&axidma0 0>;
	dma-names = "axidma1";
};

HowTo use Eclipse with CDT to develop and cross-compile(for ARM) Linux kernel module.

A small HowTo (and reminder for myself) on how to use Eclipse (Xilinx SDK) to develop, cross-compile and upload Linux kernel modules for Zynq (ARM-based) embedded board using Xilinx SDK and Xilinx Embedded Linux aka Petalinux. But most steps are universal, you just have to setup cross-compiler and possibly some missing packages, like sshpass and scp.

This HowTo based on:
HowTo use the CDT to navigate Linux kernel source
Configuring Eclipse for Linux Kernel module development

  1. Linux kernel sources is a huge collection of files and Eclipse indexer needs lots of memory. So, start Xilinx SDK with extra memory for indexer:

    xsdk -vmargs -Xms1024m -Xmx2048m -XX:+UseParallelGC

  2. Add new C Project and configure it:
    1. Give it a name AXIDMATest.
    2. Check Use default location.
    3. Set Project Type to Makefile Project > Empty Project.
    4. Select Xilinx ARM GNU/Linux Toolchain for Toolchain.
    5. Click Finish.
  3. In C/C++ General properties for AXIDMAProject:
    1. Check Enable project specific settings.
    2. Select Indexer on left menu:
      1. Check Enable project specific settings.
      2. Uncheck Index source files not included in the build and check Index all header variants.
    3. Select Preprocessor Include Paths, Macros etc. on left menu:
      1. Select GNU C in Languages
      2. Select CDT User Settings Entries for Settings Entries.
      3. Click Add... button on right.
      4. Select Preprocessor Macros File in top-left drop-down menu.
      5. Select File System Path in top-right left drop-down menu.
      6. Set File to /home/d9/Projects/ZedBoardPetalinux/build/linux/kernel/xlnx-4.0/include/generated/autoconf.h.
      7. Now click on Providers tab and check CDT GCC Built-in Compiler Settings.
      8. Uncheck Use global provider shared between projects and add -nostdinc to Command to get compiler specs:.
    4. Now select Paths and Symbols on left menu:
      1. Select Includes tab.
      2. Select GNU C on left languages list.
      3. Click Add... button on right.
      4. Check Add to all configurations and click File system... button.
      5. Select /opt/Petalinux/petalinux-v2015.4-final/components/linux-kernel/xlnx-4.0/arch/arm/include and click OK.
      6. Repeat prev. steps and add /opt/Petalinux/petalinux-v2015.4-final/components/linux-kernel/xlnx-4.0/include.
      7. Now we have to set some symbols, so select #Symbols tab.
      8. Select GNU C on left languages list.
      9. Click Add... button on right.
      10. Type name __KERNEL__ and value 1, check Add to all configurations and click OK.
      11. You may need other symbols too, like DEBUG and CONFIG_OF.
      12. Now we must exclude staff we don't need, so select Source Location tab.
      13. Click on your project and click Link Folder... button on right.
      14. Check Link to folder in the file system and click Browse... button.
      15. Browse to /opt/Petalinux/petalinux-v2015.4-final/components/linux-kernel/xlnx-4.0 and click OK.
      16. Next expand project, select Filter and click on Edit Filter...button.
        Here we can add folders which we want to exclude from the indexing. All paths are relative to project folder. What to exclude is up to you, but the minimum will be all architectures except ARM.
      17. Apply changes and click OK to close all dialogs.
  4. We can exclude kernel source folders from indexer other way too:
    1. Expand AXIDMATest in Project Explorer tab.
    2. Expand xlnx-4.0, select source folders you think you don't need to be indexed and right click on them.
    3. Select Resource Configuration and click on Exclude from Build....
    4. Select project build configurations in which you want to exclude selected sources. In this case you must have the only Default, so select it and click Ok.
    5. Verify that previously selected folders and sources now greyed out and icons "crossed".
    6. If you want to enable them back - do same steps and uncheck related "build configuration" in Resource configuration.
  5. Add sources to project:
    1. Add new Sources Folder and name it sources.
    2. Copy into it axidmatest.c from "/opt/Petalinux/petalinux-v2015.4-final/components/linux-kernel/xlnx-4.0/drivers/dma/xilinx"
    3. Open axidmatest.c and make sure Indexer did it job (you don't have indexer markers complaining about syntax errors).
  6. Now we need a Makefile:
    1. Add new File to the project folder and name it Makefile.
    2. Code below represents Makefile in my case. You have to modify at least path to your configured kernel folder:
      ARCH:=arm
      CROSS_COMPILE:=arm-xilinx-linux-gnueabi-
      KDIR_DI := ~/Projects/ZedBoardPetalinux/build/linux/kernel/xlnx-4.0/
      PWD  := $(shell pwd)
      
      obj-m += sources/axidmatest.o
      
      all:
      	make -C $(KDIR_DI) M=$(PWD) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) SUBDIRS=$(PWD/sources) modules
      
      clean:
      	make -C $(KDIR_DI) M=$(PWD) clean
      
  7. Finally we are ready to compile our project. Run Build Project, expand sources folder and and verify that it now includes axidmatest.ko.
  8. To upload module and insmod it to remote system I write a small script, which can be used from Eclipse:
    1. In a AXIDMAProject create folder utils.
    2. In utils folder create file upload_rmmod_insmod.sh.
    3. Put something like code below. You obviously must install sshpass and maybe some other missing utils and modify names, passwords, addresses and etc.
      #!/bin/bash
      
      REMOTE_IP="172.21.0.10"
      FILENAME="axidmatest"
      
      sshpass -p 'xxxx' scp $FILENAME.ko root@$REMOTE_IP:~
      sshpass -p 'xxxx' ssh root@$REMOTE_IP "/sbin/rmmod $FILENAME"
      sshpass -p 'xxxx' ssh root@$REMOTE_IP "/sbin/insmod $FILENAME.ko"
      
    4. Set Execute permissions for this script in console or by right clicking on it and selecting Properties and checking permission boxes.
    5. In Run -> External Tools -> External Tools Configurations... add New launch configuration for Program.
      For some reason it is filtered by default in XSDK 2015.4. So, uncheck Filter Configuration Types in menu on top.
    6. In Main tab:
      1. Type name: AXIDMATest
      2. For Location: select ${workspace_loc:/AXIDMATest/utils/upload_insmod.sh}
      3. For Working Directory: select ${workspace_loc:/AXIDMATest/sources}
    7. In Build tab:
      1. Check Build before launch box.
      2. Select Specific projects radio-button.
      3. Click Projects... button to select projects to build.
      4. Check AXIDMATest box and click OK.
    8. In Common tab:
      1. Check Allocate console (necessary for input) box.
      2. Check Launch in background box.
    9. Click Apply and Close button.
    10. Now we can just run this "External Tool" after making changes to source and it will compile project, upload module to remote system, overwrite existin file, rmmod previous and insmod new version of the module. Output related to script execution will be captured in Eclipse console and module output will be posted on remote system stdout.
    11. axidmatest requires an entrance in DTS in order to work and without it insmod and rmmod are silent. So, to make it print something to stdout add pr_info() to the module __init() and __exit():
      static int __init axidma_init(void)
      {
      	pr_info("axidmatest.ko axidma_init() called.\n");
      	return platform_driver_register(&xilinx_axidmatest_driver);
      
      }
      late_initcall(axidma_init);
      
      static void __exit axidma_exit(void)
      {
      	pr_info("axidmatest.ko axidma_exit() called.\n");
      	platform_driver_unregister(&xilinx_axidmatest_driver);
      }
      module_exit(axidma_exit)
      
      MODULE_AUTHOR("Xilinx, Inc.");
      MODULE_DESCRIPTION("Xilinx AXI DMA Test Client");
      MODULE_LICENSE("GPL v2");
      

Xilinx Petalinux 2015.4 released today.

Today Xilinx released new Petalinux 2015.4 which is synchronized with Xilnx Vivado and SDK 2015.4.
So, now I can finally switch to a latest Vivado and play with Vivado HLS which now included to all Vivado editions including free of cost WebPack.

This release based on Kernel version 4.0 (Xilinx repo tag xilinx-v2015.4), U-boot 2015.07 and GCC 4.8.3 with experimental support of C++11 (GCC 5.1 and later support release C++11, before 5.1 support was experimental). It also includes Vivado DDR patch and support Zynq Ultrascale+ (the only released ZU9).

Unfortunately, Xilinx very slow in adopting latest Eclipse and CDT for it's SDK. Such, current CDT version is 8.8.0 and XSDK still uses 8.3.0 which is a few years old. Very, very conservative.

Time for some hacking :-)

Configure and build Qt5, tslib and evtest for ARM (Xilinx Zynq).

Just a short recipe on how to compile 'tslib' and use it with Qt5 on Xilinx Petalinux.

At the moment I'm using Ubuntu 14.04 64bit as a host machine, MicroZed 7020 as a target, Xilinx Vivado version 2014.2 and Petalinux vesion 2014.2.
My Vivado tools installed to default path '/opt/Xilinx' and I will install Qt5.3.2 and tslib to /opt/Qt/ and /opt/tslib directories.
Also, I'm using 'Project' folder in my home directory for Vivado and Petalinux projects. Now, after I set the scene, let's actually build it.

  1. Clone tslib into our Project folder:
  2. cd ~/Projects/
    git clone https://github.com/kergoth/tslib.git tslib
    cd ~/Projects/tslib

  3. To configure and build 'tslib' we have to setup a few enviroment variables: CROSS_COMPILE, CC, CXX and we have to source Vivado settings64.sh. So, I will create and use a small bash script:
  4. #!/bin/bash

    export CROSS_COMPILE=arm-xilinx-linux-gnueabi-
    source /opt/Xilinx/Vivado/2014.2/settings64.sh

    export CC=$(which arm-xilinx-linux-gnueabi-gcc)
    export CXX=$(which arm-xilinx-linux-gnueabi-g++)

    ./autogen.sh
    ./configure --host=arm-xilinx-linux-gnueabi --prefix /opt/tslib

    make
    sudo make install

  5. Next 'evtest'. This is a small, but very helpful utility when you trying to figure out what is wrong with your touchscreen or touchscreen controller.
  6. cd ~/Projects/
    git clone git://anongit.freedesktop.org/evtest evtest_util
    cd ~/Projects/evtest_util

    #!/bin/bash

    export CROSS_COMPILE=arm-xilinx-linux-gnueabi-
    source /opt/Xilinx/Vivado/2014.2/settings64.sh

    ./autogen.sh
    ./configure --host=arm-xilinx-linux-gnueabi prefix=/opt/evtest/
    make
    sudo make install

  7. Tslib generates 'ts.conf' file, which you can locate in /opt/tslib/etc/. We have to uncomment the module_raw for our touch controller. In my case it 'input'.
  8. Now when we got tslib, we can configure Qt5. I will build Qt5 from scratch using opensource Qt Everywhere Sources. So, lets download and unpack Qt5 sources.
  9. cd ~/Projects/
    wget http://download.qt-project.org/official_releases/qt/5.3/5.3.2/single/qt-everywhere-opensource-src-5.3.2.tar.gz
    tar -zxvf qt-everywhere-opensource-src-5.3.2.tar.gz

  10. Now, before we can configure Qt5 we must create 'mkspecs' for our Xilinx Zynq. So, create new device folder 'linux-arm-xilinx-zynq-g++' and two files in it. 'qplatformdefs' contains just an include, but second file 'qmake.conf' is quite important. This is the place where we set your CFLAGS/CXXFLAGS, some ENV variables which will be used by default by QMAKE and later by Qt5 libs.

    So, if you need to set something differently, this is the time!

  11. cd ~/Projects/qt-everywhere-opensource-src-5.3.2/qtbase/mkspecs/devices/
    create linux-arm-xilinx-zynq-g++

    'qmake.conf':

    #
    # qmake configuration for linux-g++ using arm-xilinx-g++ compiler
    #
    
    MAKEFILE_GENERATOR      = UNIX
    CONFIG                 += incremental gdb_dwarf_index
    QMAKE_INCREMENTAL_STYLE = sublib
    
    include(../../common/linux.conf)
    include(../../common/gcc-base-unix.conf)
    include(../../common/g++-unix.conf)
    
    load(device_config)
    
    QT_QPA_DEFAULT_PLATFORM = linuxfb
    
    # modifications to g++.conf
    QMAKE_CC                = $${CROSS_COMPILE}gcc
    QMAKE_CXX               = $${CROSS_COMPILE}g++
    QMAKE_LINK              = $${QMAKE_CXX}
    QMAKE_LINK_SHLIB        = $${QMAKE_CXX}
    
    # modifications to linux.conf
    QMAKE_AR                = $${CROSS_COMPILE}ar cqs
    QMAKE_OBJCOPY           = $${CROSS_COMPILE}objcopy
    QMAKE_NM                = $${CROSS_COMPILE}nm -P
    QMAKE_STRIP             = $${CROSS_COMPILE}strip
    
    QMAKE_CFLAGS           += -I$$[QT_SYSROOT]/include -DZYNQ
    QMAKE_CXXFLAGS         += -Wno-psabi -I$$[QT_SYSROOT]/include -DZYNQ
    QMAKE_LFLAGS           += -L$$[QT_SYSROOT]/lib
    
    QMAKE_CFLAGS           += -march=armv7-a -mtune=cortex-a9 -mcpu=cortex-a9 -mfpu=neon -pipe -fomit-frame-pointer
    QMAKE_CXXFLAGS         += $$QMAKE_CFLAGS
    
    deviceSanityCheckCompiler()
    
    load(qt_config)
    

    'qplatformdefs.h':

    /****************************************************************************
    **
    ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
    ** Contact: http://www.qt-project.org/legal
    **
    ** This file is part of the qmake spec of the Qt Toolkit.
    **
    ** $QT_BEGIN_LICENSE:LGPL$
    ** Commercial License Usage
    ** Licensees holding valid commercial Qt licenses may use this file in
    ** accordance with the commercial license agreement provided with the
    ** Software or, alternatively, in accordance with the terms contained in
    ** a written agreement between you and Digia.  For licensing terms and
    ** conditions see http://qt.digia.com/licensing.  For further information
    ** use the contact form at http://qt.digia.com/contact-us.
    **
    ** GNU Lesser General Public License Usage
    ** Alternatively, this file may be used under the terms of the GNU Lesser
    ** General Public License version 2.1 as published by the Free Software
    ** Foundation and appearing in the file LICENSE.LGPL included in the
    ** packaging of this file.  Please review the following information to
    ** ensure the GNU Lesser General Public License version 2.1 requirements
    ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    **
    ** In addition, as a special exception, Digia gives you certain additional
    ** rights.  These rights are described in the Digia Qt LGPL Exception
    ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    **
    ** GNU General Public License Usage
    ** Alternatively, this file may be used under the terms of the GNU
    ** General Public License version 3.0 as published by the Free Software
    ** Foundation and appearing in the file LICENSE.GPL included in the
    ** packaging of this file.  Please review the following information to
    ** ensure the GNU General Public License version 3.0 requirements will be
    ** met: http://www.gnu.org/copyleft/gpl.html.
    **
    **
    ** $QT_END_LICENSE$
    **
    ****************************************************************************/
    
    #include "../../linux-g++/qplatformdefs.h"
    
  12. Next step is to configure Qt5 and below configuration I'm using. Again, this is critical step and if you have change something (compile with OpenGl support for example), you have to do it now. Also, if you want to reconfigure Qt, you have to clean using 'gmake clean' before running configuration script again.
  13. cd ~/Projects/qt-everywhere-opensource-src-5.3.2/
    ./build_qt5_3_2.sh
    gmake
    sudo gmake install

    'build_qt5_3_2.sh':

    #!/bin/bash
    
    export CROSS_COMPILE=arm-xilinx-linux-gnueabi-
    source /opt/Xilinx/Vivado/2014.2/settings64.sh
    
    read -p "Run 'confclean'? (y/n) "
    if [ "$REPLY" == "y" ]; then
            gmake clean
    fi 
    
    ./configure -prefix /opt/Qt/5.3.2 \
    	-device linux-arm-xilinx-zynq-g++ \
    	-device-option CROSS_COMPILE=arm-xilinx-linux-gnueabi- \
    	-release \
    	-confirm-license \
    	-opensource \
    	-optimized-qmake \
    	-no-qml-debug \
    	-qt-zlib \
    	-qt-libpng \
    	-qt-libjpeg \
    	-qt-freetype \
    	-qt-harfbuzz \
    	-qt-pcre \
    	-no-xcb \
    	-qt-xkbcommon \
    	-no-opengl \
    	-no-pch \
    	-verbose \
    	-no-kms \
    	-no-eglfs \
    	-no-icu \
    	-no-iconv \
    	-skip qtwebkit \
    	-tslib \
    	-no-gcc-sysroot \
    	-nomake tools \
    	-no-compile-examples \
    	-I /opt/tslib/include \
    	-L /opt/tslib/lib
    
    read -p "Run 'gmake'? (y/n) "
    if [ "$REPLY" == "y" ]; then
    	cd ~/Projects/$QtSrcName
    	gmake
    fi
    
    read -p "Run 'gmake install'? (y/n) "
    if [ "$REPLY" == "y" ]; then
    	cd ~/Projects/$QtSrcName
    	sudo gmake install
    fi
    
  14. After a few minutes(ha-ha) build will finish and we can build a couple of Qt examples for testing purposes. I created a small script to build each example individually. All I need to do is just copy it in project folder and run it. Examples I usually use is a 'Mainwindow' and a 'Pathstroke'.
  15. 'build_qt5_app.sh'

    #!/bin/bash
    
    export CROSS_COMPILE=arm-xilinx-linux-gnueabi-
    source /opt/Xilinx/Vivado/2014.3/settings64.sh
    
    export QTDIR=/opt/Qt/5.3.2
    export PATH=$QTDIR/bin:$PATH
    export LD_LIBRARY_PATH=/$QTDIR/lib:$LD_LIBRARY_PATH
    
    qmake
    
    make
    
    sudo make install
    
  16. Now, to install Qt5 libs and apps we will create Petalinux 'component'.
  17. cd ~/Projects/$PetalinuxProjectName
    petalinux-create -t libs -n qt-5.3.2 --enable
    cd components/libs/qt-5.3.2/
    rm libqt*
    cp -Pr /opt/Qt/5.3.2/lib .
    cp -Pr /opt/Qt/5.3.2/plugins/ ./lib/
    mkdir bin
    cp /opt/Qt/5.3.2/examples/widgets/painting/pathstroke/pathstroke bin/pathstroke
    cp /opt/Qt/5.3.2/examples/widgets/mainwindows/mainwindow/mainwindow bin/mainwindow

  18. Now, we have to make a few changes in our new 'component' in a Petalinux project( ~/Projects/$PetalinuxProjectName/components/libs/qt-5.3.2/): create 'Makefile' and some file with settings for Qt applications. Tet's call it 'profile.qt-5.3.2'.
  19. 'profile.qt-5.3.2':

    export QT_PLUGIN_PATH=/usr/lib/plugins
    export QT_QPA_FONTDIR=/usr/lib/fonts
    export QT_QPA_PLATFORM_PLUGIN_PATH=/usr/lib/plugins/platforms
    export QT_QPA_PLATFORM=linuxfb
    export QT_QPA_GENERIC_PLUGINS=tslib:/dev/input/event0
    

    Makefile(Don't forget to change username):

    ifndef PETALINUX
    $(error "Error: PETALINUX environment variable not set.  Change to the root of your PetaLinux install, and source the settings.sh file")
    endif
    
    include libs.common.mk
    
    LIB=libqt_5_3_2
    
    all: build install
    
    .PHONY: build
    build:
    
    install:
    	#Install libraries and fonts to the rootfs.
    
    	mkdir -p $(TARGETDIR)/usr/lib
    	USER=d9
    	GROUP=d9
    	rsync -rav ./bin/* $(TARGETDIR)/usr/bin/
    	rsync -rav ./lib/* $(TARGETDIR)/usr/lib/
    
    	#Install the script to ensure the font directory is properly specified.
    	mkdir -p $(TARGETDIR)/etc/profile.d
    	cp profile.qt-5.3.2 $(TARGETDIR)/etc/profile.d/profile.qt-5.3.2
    
    clean:
    
  20. We also need to add 'tslib' to our buildroot. So, I will create another Petalinux 'component', create and copy tslib configuration files:
  21. cd ~/Projects/$PetalinuxProjectName
    petalinux-create -t libs -n tslib --enable
    cd components/libs/tslib/
    rm libtslib*
    rm README
    cp -Pr /opt/tslib/bin .
    cp -Pr /opt/tslib/lib .
    cp -Pr /opt/etc/ts.conf .
    cp -Pr Makefile .
    cp -Pr profile.tslib .
    cp -Pr pointercal .

    My 'profile.tslib'. You may need to change it:

    export TSLIB_TSEVENTTYPE='INPUT'
    export TSLIB_CALIBFILE='/etc/pointercal'
    export TSLIB_CONFFILE='/etc/ts.conf'
    export TSLIB_CONSOLEDEVICE='none'
    export TSLIB_FBDEVICE='/dev/fb0'
    export TSLIB_PLUGINDIR='/usr/lib/ts'
    export TSLIB_TSDEVICE='/dev/input/event0'
    

    'pointercal' for my 800x600 touchscreen:

    94 -13605 53617952 -10567 205 40161292 65536 800 600
    

    'Makefile' (Don't forget to change username):

    ifndef PETALINUX
    $(error "Error: PETALINUX environment variable not set.  Change to the root of your PetaLinux install, and source the settings.sh file")
    endif
    
    include libs.common.mk
    
    LIB=tslib
    
    all: build install
    
    .PHONY: build
    build:
    
    install:
    	#Install libraries and fonts to the rootfs.
    
    	mkdir -p $(TARGETDIR)/usr/lib
    	USER=d9
    	GROUP=d9
    	rsync -rav ./bin/* $(TARGETDIR)/usr/bin/
    	rsync -rav ./lib/* $(TARGETDIR)/usr/lib/
    
    	cp ts.conf $(TARGETDIR)/etc/ts.conf
    	cp profile.tslib $(TARGETDIR)/etc/profile.d/tslib
    	cp pointercal $(TARGETDIR)/etc/pointercal
    
    clean:
    
  22. Qt is a C++ library and like any other C++ application or library it depend on standard c++ library. So, if you didn't include it in your rootfs yet you have to do it now.

    petalinux-config -c rootfs

    Then go to 'Filesystem Packages' -> 'Base' -> 'External-xilinx-toolchain' -> Enable 'libstdc++6'.

  23. This is basically it. Now we have rebuild our Petalinux project and start using it. Just a few notes:
    - After we add Qt5 libraries, our Linux image file will grow is size, so you may need to change U-boot settings to accomodate it.
    - If you need to recalibrate touchscreen - use 'ts_calibrate' utility.
    - If you want to keep it - you must save changes in '/etc/pointercal' file.
    - If you got not only touchscreen, but also mouse and/or keyboard you have to start your application with additional parameters: '-plugin EvdevMouse' '-plugin EvdevKeyboard'.

Some material on Linux Device Drivers from Xilinx.

John Linn posted some interesting material on Linux Device Drivers. It covers basic Linux driver topics in introduction Sessions 1 and 2, UIO drivers in Session 3 and DMA drivers in kernel mode in Session 4. I found all sessions very interesting, but especially on DMA since it really hard to find any kind of information on that topic, besides what is included in Kernel/Documentation folder.

drivers-sessions1-2-public.pdf
drivers-session3-uio-4public.pdf
drivers-session4-dma-4public.pdf

HDMI on ZedBoard with Petalinux update.

I finally figure it out why Analog Devices reference design create/generated in Vivado 2014 by script(obviously updated to use new IP's, otherwise it didn't assemble 'Block Design' at all) didn't work. Reason is changes in Xilinx Concat IP, which used in reference design to concatenate interrupt signals from VDMA and I2C IP blocks to Zynq's F2S interrupt bus.
So, now in 2014.1, we got version 2.0 of it and it preserve the order of input signals on the output. Which means we must either change inputs order or change interrupt numbers in DTS.

So, for AD reference design generated in Vivado2014.1 interrupts are:

  • AXI_IIC_MAIN - #56.
  • AXI_VDMA_0 - #55.
  • AXI_IIC_FMC - #59.

zynq16_001

HDMI on ZedBoard with Petalinux.

This is step-by-step tutorial on how to build reference design for Analog Devices ADV7511 HDMI encoder used on ZedBoard with PetaLinux 2013.10. It will be mostly based on AD HDL reference design http://wiki.analog.com/resources/fpga/xilinx/kc705/adv7511 and AD Linux drivers wiki page http://wiki.analog.com/resources/tools-software/linux-drivers/platforms/zynq and Xilinx PetaLinux documentation http://www.wiki.xilinx.com/PetaLinux.

As of today, 25 May 2014, to create HDL design for ADV7511 from scratch, we have to use Vivado 2013.4, even though Vivado 2014.1 is already available. The reason is some changes in a Xilinx IP's (which I didn't had a chance to figure out yet) prevent HDL design from build/work properly.

  1. First step is to download HDL libraries and projects from AnalogDevices repositories on a github: https://github.com/analogdevicesinc/hdl. You can clone it or download a ZIP. I will download a ZIP and extract 'hdl-master' in my Projects/FPGA/ folder on Windows7 machine.
  2. Second step is to build a few Analog Devices IP required to create ZedBoard HDMI design. Run Xilinx Vivado 2013.4, open a TCL console, change directories and 'source' a .tcl scripts. For example, to build AXI_CLKGEN IP:

    cd c:/Projects/FPGA/hdl-master/library/axi_clkgen
    source ./axi_clkgen_ip.tcl

    After script finish, close created project and build the next. For ZedBoard we have build the next IP's:

    • hdl-master/library/axi_clkgen
    • hdl-master/library/axi_hdmi_tx
    • hdl-master/library/axi_i2s_adi
    • hdl-master/library/axi_spdif_tx
    • hdl-master/library/util_i2c_mixer
  3. After we done with all required IP's, we can build ADV7511 reference design for ZedBoard. In a Tcl Console change directory to ADV7511 and run 'system_project' script.

    cd c:/Projects/FPGA/hdl-master/projects/adv7511/zed/
    source ./system_project.tcl

    Script will create block design, run synthesis and implementation, generate bitstream and even export software to SDK(without opening it). This was the case on my system - everything went smoothly. We are done with Vivado and can close it.

    We have to create HDL in Vivado 2013.4, but later we can import created project into Vivado 2014.1 and update it to use latest Xilinx IP's.

  4. Let's build a FSBL. We need very typical Zynq first stage boot loader and I covered creation of it before, so now just a short description:
    • Run XSDK.
    • Create new 'Hardware Platform Specification' project (I named it 'ZedBoard-HDMI-HW') and specify HW created in a previous step.
    • Create Application project (named 'ZedBoard-HDMI-FSBL') using our new 'Hardware Platform' and select to create new BSP for it. Don't forget to use 'Zynq FSBL' template. Build it if this not done automatically.
  5. Next step is to create PetaLinux BSP. This is also very typical PetaLinux BSP, just don't forget to change 'Configuration' to reflect ZedBoard configuration and name it 'ZedBoard-HDMI-petalinux_bsp'.

    zynq15_002

    We are done with Xilinx SDK. You can close it.

  6. Next step is to create PetaLinux project and set 'hardware description'. I will call it 'ZedBoard-HDMI' Petalinux project:

    petalinux-create -t project -n ZedBoard-HDMI
    cd ~/Projects/ZedBoard-HDMI-petalinux_bsp/
    petalinux-config --get-hw-description -p ../ZedBoard-HDMI/
    cd ~/Projects/ZedBoard-HDMI/
    rm -r hw-description

  7. Now, as of today, ADV7511 Linux driver not in a mainstream kernel. So, we need to get Kernel from Analog Devices repository with appropriate patches. Current version is 3.14.0. Let's clone it, and checkout 'xcomm_zynq' branch.

    cd ~/Projects/
    git clone https://github.com/analogdevicesinc/linux.git analogdevices-kernel
    cd analogdevices-kernel/
    git checkout xcomm_zynq

  8. Create necessary directories and copy 'xcomm_zynq' branch to our PetaLinux project directory.

    cd ~/Projects/
    mkdir ~/Projects/ZedBoard-HDMI/components
    mkdir ~/Projects/ZedBoard-HDMI/components/linux-kernel
    cp -a analogdevices-kernel ~/Projects/ZedBoard-HDMI/components/linux-kernel/

  9. Run 'petalinux-config' and change kernel to 'analogdevices-kernel' and system boot device to 'SD card'.
  10. cd ZedBoard-HDMI
    petalinux-config

  11. Next we need to configure Linux kernel for PetaLinux and we need to enable all options required by ADV7511. AnalogDevices kernel support special configuration option 'zynq_xcomm_adv7511_defconfig', but we cannot run it with PetaLinux. So, we have to pre-configure kernel separately ('make ARCH=arm zynq_xcomm_adv7511_defconfig') and just copy resulted config into 'ZedBoard-HDMI/subsystems/linux/configs/kernel'. So, I did it and also copied it into PetaLinux Kernel configs directory '/opt/petalinux-v2013.10-final/etc/template/project/template-zynq/subsystems/linux/configs/kernel'. So, I can later reuse it. Also notice that kernel default config file have dot in the front and PetaLinux files don't.
    Anyway, here is link to my resulted kernel config file: https://blog.idv-tech.com/wp-content/uploads/2014/05/config_hdmi_3_14.config
  12. We also, have to modify 'devices tree' generated by PetaLinux for our project. AnalogDecices Linux kernel have template for ZedBoard which you can find in 'arch/arm/boot/dts/zynq-zed-adv7511.dts', so we basically have to copy missing devices from AD into our tree.
    Link to my resulted DTS file for ZedBoard: https://blog.idv-tech.com/wp-content/uploads/2014/05/adv7511_dts.config.
  13. We are basically done. At this point you my want to modify PetaLinux project, for example, include Qt5 library and test app to check frame buffer device later. I covered this topics in my previous post, so I wont repeat it here.

    Build Petalinux project, create BOOT.BIN and copy it together with Linux image file 'image.ub' on SD card:

    petalinux-build
    petalinux-package --boot --fsbl ../ZedBoard-HDMI-FSBL/Release/ZedBoard-HDMI-FSBL.elf --fpga ../ZedBoard-HDMI-HW/system_top.bit --uboot --force -o images/linux/BOOT.BIN

  14. Insert SD card into slot of ZedBoard and turn it on. During boot kernel should detect ADV7511(hdmi) and ADAU1761(sound) devices and create '/dev/fb0' device.So, below partial bootlog from my ZedBoard:
  15. ...
    [drm] Initialized drm 1.1.0 20060810
    /analogdevices-kernel/drivers/gpu/drm/adi_axi_hdmi/axi_hdmi_drv.c:axi_hdmi_platform_probe[176]
    platform 70e00000.axi_hdmi: Driver axi-hdmi requests probe deferral
    ...
    adv7511-hdmi-snd adv7511_hdmi_snd.2: adv7511 <-> 75c00000.axi-spdif-tx mapping ok
    ...
    zed-adau1761-snd zed_sound.3: adau-hifi <-> 77600000.axi-i2s mapping ok
    ...
    Console: switching to colour frame buffer device 180x56
    axi-hdmi 70e00000.axi_hdmi: fb0:  frame buffer device
    axi-hdmi 70e00000.axi_hdmi: registered panic notifier
    [drm] Initialized axi_hdmi_drm 1.0.0 20120930 on minor 0
    /analogdevices-kernel/drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
    ALSA device list:
      #0: HDMI monitor
      #1: ZED ADAU1761
    Freeing unused kernel memory: 23356K (c062b000 - c1cfa000)
    INIT: version 2.88 booting
    Starting Bootlog daemon: bootlogd.
    ...
    
     _____       _           _      _
    | ___ \     | |         | |    (_)
    | |_/ / ___ | |_   __ _ | |     _  _ __   _   _ __  __
    |  __/ / _ \| __| / _` || |    | || '_ \ | | | |\ \/ /
    | |   |  __/| |_ | (_| || |____| || | | || |_| | >  <
    \_|    \___| \__| \__,_|\_____/|_||_| |_| \__,_|/_/\_\
    
    PetaLinux v2013.10 (Yocto 1.4) ZedBoard ttyPS0
    
    ZedBoard login: root
    Password:
    login[923]: root login  on `ttyPS0'
    
    root@ZedBoard:~# ls /dev/fb0
    /dev/fb0
    root@ZedBoard:~# uname -a
    Linux ZedBoard 3.14.0-g681a2d8-dirty #2 SMP PREEMPT Sun May 25 22:46:28 EDT 2014 armv7l GNU/Linux
    root@ZedBoard:~#
    
  16. This is basically it - once you have a framebuffer device you can start using it. So I ran my Qt5 test app and it worked. We obviously don't have any hardware acceleration with this HDL design, but we got basic FB device and HDMI output. Congratulations!

Zynq MMC/SD controller with Linux Kernel 3.12.x and later.

Just a quick note regarding Zynq SD card controller support in Linux Kernel 3.13.x and later. Apparently, Xilinx used industry standard IP blocks for Zynq PS hardware, including SDHC controller. And now they are switching away from 'custom' drivers. For example, Xilinx Zynq PS I2C now called 'Cadence I2C Controller' and new name for Zynq SDHC controller is 'Arasan'.

To make SD card work again with latest kernels, we need to select appropriate option during Linux kernel configuration and make changes for 'ps7_sd_0' and/or 'ps7_sd_1' in devices tree file(DTS). Arasan driver also looking for different 'clock-names'.

Below SD controller section of my DTS file for ZedBoard:

ps7_sd_0: ps7-sdio@e0100000 {
	clock-frequency = <50000000>;
	clock-names = "clk_xin", "clk_ahb";
	clocks = <&clkc 21>, <&clkc 32>;
	compatible = "arasan, sdhci-8.9a";
	interrupt-parent = <&ps7_scugic_0>;
	interrupts = <0 24 4>;
	reg = <0xe0100000 0x1000>;
	xlnx,has-cd = <0x1>;
	xlnx,has-power = <0x0>;
	xlnx,has-wp = <0x1>;
} ;

zynq12_001

Howto build Qt 5.2.1 for Xilinx Zynq.

    Update for Qt 5.3.2: https://blog.idv-tech.com/2014/10/15/building-and-configuring-qt5-tslib-and-evtest-for-arm-xilinx-zynq/.

    This is a small how-to build latest Qt 5.2.1 for Zynq and use it with PetaLinux 2013.10 projects. I'm using 64 bit Ubuntu 13.10 as a host, with Xilinx Vivado 2013.4 and ZedBoard
    'Rev. D' as a target. If this howto works for you, especially if you using it on other boards please let me know, so I can push to Qt Zynq support changes.

  1. Download and extract Qt everywhere sources to your home/Download directory:

    wget http://download.qt-project.org/official_releases/qt/5.2/5.2.1/single/qt-everywhere-opensource-src-5.2.1.tar.gz
    tar -zxvf qt-everywhere-opensource-src-5.2.1.tar.gz

  2. Qt5 don't yet support Zynq device, so we need to add it. You can download and extract prepared files(linux-arm-xilinx-zynq-g++.tar.gz) to 'qt-everywhere-opensource-src-5.2.1/qtbase/mkspecs/devices/linux-arm-xilinx-zynq-g++' folder. Or you create files yourself:
    • In a 'qt-everywhere-opensource-src-5.2.1/qtbase/mkspecs/devices' create new folder named 'linux-arm-xilinx-zynq-g++'.
    • In a 'linux-arm-xilinx-zynq-g++' create 'qmake.conf' file:
    • #
      # qmake configuration for linux-g++ using arm-xilinx-g++ compiler
      #
      
      MAKEFILE_GENERATOR      = UNIX
      CONFIG                 += incremental gdb_dwarf_index
      QMAKE_INCREMENTAL_STYLE = sublib
      
      include(../../common/linux.conf)
      include(../../common/gcc-base-unix.conf)
      include(../../common/g++-unix.conf)
      
      load(device_config)
      
      QT_QPA_DEFAULT_PLATFORM = linuxfb
      
      # modifications to g++.conf
      QMAKE_CC                = $${CROSS_COMPILE}gcc
      QMAKE_CXX               = $${CROSS_COMPILE}g++
      QMAKE_LINK              = $${QMAKE_CXX}
      QMAKE_LINK_SHLIB        = $${QMAKE_CXX}
      
      # modifications to linux.conf
      QMAKE_AR                = $${CROSS_COMPILE}ar cqs
      QMAKE_OBJCOPY           = $${CROSS_COMPILE}objcopy
      QMAKE_NM                = $${CROSS_COMPILE}nm -P
      QMAKE_STRIP             = $${CROSS_COMPILE}strip
      
      QMAKE_CFLAGS           += -I$$[QT_SYSROOT]/include -DZYNQ
      QMAKE_CXXFLAGS         += -Wno-psabi -I$$[QT_SYSROOT]/include -DZYNQ
      QMAKE_LFLAGS           += -L$$[QT_SYSROOT]/lib
      
      QMAKE_CFLAGS           += -march=armv7-a -mcpu=cortex-a9 -mtune=cortex-a9 -mfpu=neon -pipe -fomit-frame-pointer
      QMAKE_CXXFLAGS         += $$QMAKE_CFLAGS
      
      deviceSanityCheckCompiler()
      
      load(qt_config)
      
    • And also 'qplatformdefs.h' file:
    • /****************************************************************************
      **
      ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
      ** Contact: http://www.qt-project.org/legal
      **
      ** This file is part of the qmake spec of the Qt Toolkit.
      **
      ** $QT_BEGIN_LICENSE:LGPL$
      ** Commercial License Usage
      ** Licensees holding valid commercial Qt licenses may use this file in
      ** accordance with the commercial license agreement provided with the
      ** Software or, alternatively, in accordance with the terms contained in
      ** a written agreement between you and Digia.  For licensing terms and
      ** conditions see http://qt.digia.com/licensing.  For further information
      ** use the contact form at http://qt.digia.com/contact-us.
      **
      ** GNU Lesser General Public License Usage
      ** Alternatively, this file may be used under the terms of the GNU Lesser
      ** General Public License version 2.1 as published by the Free Software
      ** Foundation and appearing in the file LICENSE.LGPL included in the
      ** packaging of this file.  Please review the following information to
      ** ensure the GNU Lesser General Public License version 2.1 requirements
      ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
      **
      ** In addition, as a special exception, Digia gives you certain additional
      ** rights.  These rights are described in the Digia Qt LGPL Exception
      ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
      **
      ** GNU General Public License Usage
      ** Alternatively, this file may be used under the terms of the GNU
      ** General Public License version 3.0 as published by the Free Software
      ** Foundation and appearing in the file LICENSE.GPL included in the
      ** packaging of this file.  Please review the following information to
      ** ensure the GNU General Public License version 3.0 requirements will be
      ** met: http://www.gnu.org/copyleft/gpl.html.
      **
      **
      ** $QT_END_LICENSE$
      **
      ****************************************************************************/
      
      #include "../../linux-g++/qplatformdefs.h"
      
  3. QT_QPA_DEFAULT_PLATFORM variable set to Linux Framebuffer and if your hardware design supports something else you may want to change it. Or you can always control it thru QT_QPA_PLATFORM env. variable and leave default to simplest 'linuxfb'. You may also want to modify CFLAGS and CXXFLAGS here.
  4. Set CROSS_COMPILE variable and source Xilinx tools settings:

    export CROSS_COMPILE=arm-xilinx-linux-gnueabi-
    source /opt/Xilinx/Vivado/2013.4/settings64.sh

  5. Now we can run Qt 'configure' utility, Below, configuration from my building script. Notice I disabled OpenGL ES support since my hardware don't have it yet, but your might, so you may want to include egl support.
  6. ./configure -prefix /opt/Qt/5.2.1 \
    	-device linux-arm-xilinx-zynq-g++ \
    	-device-option CROSS_COMPILE=arm-xilinx-linux-gnueabi- \
    	-release \
    	-no-qml-debug \
    	-reduce-relocations \
    	-qt-zlib \
    	-qt-libpng \
    	-qt-libjpeg \
    	-qt-freetype \
    	-qt-harfbuzz \
    	-qt-pcre \
    	-no-xcb \
    	-qt-xkbcommon \
    	-no-opengl \
    	-no-eglfs \
    	-no-kms \
    	-confirm-license \
    	-opensource \
    	-no-icu \
    	-no-pch \
    	-verbose
    
  7. Configure will build 'qmake' first and generate 'Makefiles' for all the components. Check your output in details and verify it match your configuration. Below output in my case:
  8. Configure summary
    
    Building on:   linux-g++ (x86_64, CPU features: mmx sse sse2)
    Building for:  devices/linux-arm-xilinx-zynq-g++ (arm, CPU features: neon)
    Platform notes:
    
                - Also available for Linux: linux-kcc linux-icc linux-cxx
            
    qmake vars .......... styles += mac fusion windows DEFINES += QT_NO_MTDEV 
    DEFINES += QT_NO_LIBUDEV DEFINES += QT_NO_XCB sql-drivers =  sql-plugins =  sqlite qmake switches ......... 
    
    Build options:
      Configuration .......... accessibility audio-backend c++11 clock-gettime clock-monotonic compile_examples 
     concurrent cross_compile evdev eventfd freetype full-config getaddrinfo getifaddrs harfbuzz iconv inotify
     ipv6ifname large-config largefile linuxfb medium-config minimal-config mremap neon nis no-pkg-config pcre 
     png posix_fallocate qpa qpa reduce_exports reduce_relocations release rpath shared small-config xkbcommon-qt zlib 
      Build parts ............ libs examples
      Mode ................... release
      Using C++11 ............ yes
      Using PCH .............. no
      Target compiler supports:
        iWMMXt/Neon .......... no/yes
    
    Qt modules and options:
      Qt D-Bus ............... no
      Qt Concurrent .......... yes
      Qt GUI ................. yes
      Qt Widgets ............. yes
      JavaScriptCore JIT ..... yes (To be decided by JavaScriptCore)
      QML debugging .......... no
      Use system proxies ..... no
    
    Support enabled for:
      Accessibility .......... yes
      ALSA ................... no
      CUPS ................... no
      FontConfig ............. no
      FreeType ............... qt
      HarfBuzz ............... qt
      Iconv .................. yes
      ICU .................... no
      Image formats: 
        GIF .................. yes (plugin, using bundled copy)
        JPEG ................. yes (plugin, using bundled copy)
        PNG .................. yes (in QtGui, using bundled copy)
      Glib ................... no
      GTK theme .............. no
      Large File ............. yes
      mtdev .................. no
      Networking: 
        getaddrinfo .......... yes
        getifaddrs ........... yes
        IPv6 ifname .......... yes
        OpenSSL .............. no
      NIS .................... yes
      OpenGL ................. no
      OpenVG ................. no
      PCRE ................... yes (bundled copy)
      pkg-config ............. no 
      PulseAudio ............. no
      QPA backends: 
        DirectFB ............. no
        EGLFS ................ no
        KMS .................. no
        LinuxFB .............. yes
        XCB .................. no
      Session management ..... yes
      SQL drivers: 
        DB2 .................. no
        InterBase ............ no
        MySQL ................ no
        OCI .................. no
        ODBC ................. no
        PostgreSQL ........... no
        SQLite 2 ............. no
        SQLite ............... yes (plugin, using bundled copy)
        TDS .................. no
      udev ................... no
      xkbcommon .............. yes (bundled copy)
      zlib ................... yes (bundled copy)
    
    NOTE: Qt is using double for qreal on this system. This is binary incompatible against Qt 5.1.
    Configure with '-qreal float' to create a build that is binary compatible with 5.1.
    Info: creating cache file /home/d9/Projects/qt5_build_test/qt-everywhere-opensource-src-5.2.1/qtbase/.qmake.cache
    
    Qt is now configured for building. Just run 'gmake'.
    Once everything is built, you must run 'gmake install'.
    Qt will be installed into /opt/Qt/5.2.1
    
    Prior to reconfiguration, make sure you remove any leftovers from
    the previous build.
    
  9. Build and install Qt. It will be installed in a directory you set as a prefix during configuration.

    cd qt-everywhere-opensource-src-5.2.1/qtbase/
    gmake & gmake install

  10. Now, lets add Qt libraries and couple of Qt example binaries to PetaLinux project. Go to your PetaLinux project directory and create Qt component using 'libs' template.

    petalinux-create -t libs -n qt-5.2.1 --enable

  11. We don't need template created files, so delete them.

    cd components/libs/qt-5.2.1/
    rm libqt*

  12. Copy prebuilt Qt library files to 'lib' subdirectory, qt fonts and plugin directories also to 'lib' and a couple of Qt examples to 'bin' subdirectory:

    cp -Pr /opt/Qt/5.2.1/lib .
    cp -Pr /opt/Qt/5.2.1/plugins/ ./lib/
    mkdir bin
    cp /opt/Qt/5.2.1/examples/widgets/painting/pathstroke/pathstroke bin/pathstroke
    cp /opt/Qt/5.2.1/examples/widgets/mainwindows/mainwindow/mainwindow bin/mainwindow

  13. We also have to set a few enviromental variables on a target rootfs, so lets create 'profile.qt-5.2.1' file. Last one is for 'tslib', so if you don't use it you may delete it. Also, depending on your setup - you may need to change this or add other variables here.
  14. export QT_PLUGIN_PATH=/usr/lib/plugins
    export QT_QPA_FONTDIR=/usr/lib/fonts
    export QT_QPA_PLATFORM_PLUGIN_PATH=/usr/lib/plugins/platforms
    export QT_QPA_PLATFORM=linuxfb
    export QT_QPA_GENERIC_PLUGINS=tslib:/dev/input/event0
    
  15. Now we have to modify our PetaLinux component Makefile. We got nothing to build, but need to install our Qt5 library files to target rootfs.
  16. ifndef PETALINUX
    $(error "Error: PETALINUX environment variable not set. Try to source the settings.sh file")
    endif
    
    include libs.common.mk
    
    LIB=libqt_5_2_1
    
    all: build install
    
    .PHONY: build
    build:
    
    install:
    	#Install libraries and fonts to the rootfs.
    
    	mkdir -p $(TARGETDIR)/usr/lib
    	USER=your_user_name
    	GROUP=your_user_group
    	rsync -rav ./bin/* $(TARGETDIR)/usr/bin/
    	rsync -rav ./lib/* $(TARGETDIR)/usr/lib/
    
    	#Install the script to ensure the font directory is properly specified.
    	mkdir -p $(TARGETDIR)/etc/profile.d
    	cp profile.qt-5.2.1 $(TARGETDIR)/etc/profile.d/profile.qt-5.2.1
    
    clean:
    
  17. Last configuration step is to include 'libstdc++6' to target rootfs, since Qt is a C++ library and depends on it.

    petalinux-config -c rootfs

    Then go to 'Filesystem Packages' -> 'Base' -> 'External-xilinx-toolchain' -> Enable 'libstdc++6'.

  18. Thats it. Rebuild PetaLinux project, transfer image.ub file to SD card. Qt5 library will add about 20M to image size, so it may not fit into reserved space and you may need to adjust appropriate u-boot variable (loadaddr, netstart...). After boot you we can run 'pathstroke' and 'mainwindow' Qt example apps.
  19. zynq9_001

The easiest way to add screen to ZedBoard.

While waiting for my custom TFT panel board to be build and Zynq IP created, I'm decided to go ahead and build Qt libraries and start porting application. In order to test my application I need linux video framebuffer of any sort and easiest way to add screen to ZedBoard is to use DisplayLink Video USB-to-DVI adaptor. I got first generation of DisplayLink adaptor from Kengsington model K33907.

I did use Xilinx PetaLinux 13.10 under Ubuntu 13.10 and kernel v3.12.0 from Xilinx git repo: and I did reuse PetaLinux project I created using ZedBoard CTT hardware design from ZedBoard_CTT_v2013_2_130807 tutorial. But it works just as good with PetaLinux 13.10 default linux kernel 3.8.11.

  1. First, we need to reconfigure linux kernel to include a driver and enable some framebuffer related options. So, run kernel config utility, go to 'Device Drivers' -> 'Graphics support' and make appropriate changes:

    cd ~/Projects/my_zedboard_petalinux_project/
    petalinux-config -c kernel

    zynq6_001

    zynq6_002

  2. Clean PetaLinux project from previous build and rebuild it:

    petalinux-build -x mrproper
    petalinux-build

  3. Connect DisplayLink USB adaptor to USB OTG port of ZedBoard.
  4. Check JP2 and JP3 jumpers on the ZedBoard - both must be shorted to set USB in a Host mode.
  5. Now transfer new image.ub to SD card if you using SD card. Or if you using 'tftp' to load kernel - just reset ZedBoard.
  6. During boot process you should see something similar to the code below and if you do this means DisplayLink driver works, it found video adapter connected to USB, got EDID with modes from monitor and set appropriate mode. In my case it 1440x900 59Hz:

    usb 1-1: new high-speed USB device number 2 using xusbps-ehci
    usb 1-1: New USB device found, idVendor=17e9, idProduct=0033
    usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
    usb 1-1: Product: K33907
    usb 1-1: Manufacturer: DisplayLink
    usb 1-1: SerialNumber: 0033-105190
    udlfb: DisplayLink K33907 - serial #0033-105190
    udlfb: vid_17e9&pid_0033&rev_0002 driver's dlfb_data struct at ceb5b000
    udlfb: console enable=1
    udlfb: fb_defio enable=1
    udlfb: shadow enable=1
    udlfb: vendor descriptor not available (-32)
    udlfb: allocated 4 65024 byte urbs
    udlfb: 1440x900 @ 59 Hz valid mode
    udlfb: 720x400 @ 70 Hz valid mode
    udlfb: 640x480 @ 60 Hz valid mode
    udlfb: 640x480 @ 67 Hz valid mode
    udlfb: 640x480 @ 72 Hz valid mode
    udlfb: 640x480 @ 75 Hz valid mode
    udlfb: 800x600 @ 56 Hz valid mode
    udlfb: 800x600 @ 60 Hz valid mode
    udlfb: 800x600 @ 72 Hz valid mode
    udlfb: 800x600 @ 75 Hz valid mode
    udlfb: 832x624 @ 75 Hz valid mode
    udlfb: 1024x768 @ 60 Hz valid mode
    udlfb: 1024x768 @ 70 Hz valid mode
    udlfb: 1024x768 @ 75 Hz valid mode
    udlfb: 1280x1024 @ 75 Hz valid mode
    udlfb: 1152x864 @ 75 Hz valid mode
    udlfb: 1440x900 @ 60 Hz valid mode
    udlfb: 1440x900 @ 75 Hz valid mode
    udlfb: 1280x1024 @ 60 Hz valid mode
    udlfb: 1280x960 @ 60 Hz valid mode
    udlfb: 1152x864 @ 75 Hz valid mode
    udlfb: Reallocating framebuffer. Addresses will change!
    udlfb: 1440x900 @ 59 Hz valid mode
    udlfb: set_par mode 1440x900
    udlfb: open /dev/fb0 user=0 fb_info=c0889400 count=1
    udlfb: set_par mode 1440x900
    Console: switching to colour frame buffer device 180x56
    udlfb: set_par mode 1440x900
    udlfb: DisplayLink USB device /dev/fb0 attached. 1440x900 resolution. Using 5064K framebuffer memory

  7. One of the monitors I tried - didn't send EDID data to the adapter, so I endup creating /etc/fb.modes file with all the modes supported by my monitor.
  8. Now, just verify we got linux framebuffer device in your "/dev/" - it should be "/dev/fb0" and send some random data to it to see if it really works.
  9. cat /bin/busybox > /dev/fb0
    udlfb: open /dev/fb0 user=1 fb_info=cebc5400 count=2
    udlfb: released /dev/fb0 user=1 count=1

  10. If you see random data on screen, similar to the screenshot below - congratulations! Your adapter now works with ZedBoard!
  11. zynq6_005

ZedBoard Linux-FreeRTOS AMP Board Bringup Guide.

One of the many nice features of Xilinx Zynq is ability to run it in Asymmetric MultiProcessing or AMP configuration. Xilinx released version v2013.10 of a UG980(Petalinux Board Bringup) and UG978(Zynq Linux-FreeRTOS AMP) guides for Xilinx ZC702 board. Today I will follow those guides to build Linux-FreeRTOS solution for ZedBoard.
I already have Vivado and Xilinx SDK packages installed along with required, but initially missing packages on my Ubuntu 13.10 64 bit Virtual Machine.

  1. First of all we will need so called Zynq 'Hardware Platform' which will satisfy both Linux and FreeRTOS minimum requirements.
    Linux requires one UART and at least one storage peripheral, for example SD Card. And FreeRTOS also requires one UART and also a Timer.
    So, I will modify ZedBoard CTT hardware design I created using ZedBoard_CTT_v2013_2_130807 tutorial. That 'Hardware Platform', in addition to base system, consist of 8 switches, 8 led's and 5 push buttons and I will activate 1 more UART and 1 more timer for FreeRTOS.

    Open Vivado ZedBoard CTT project or create it from scratch using ZedBoard CTT tutorial. I called my project 'ZedBoard-AMP' and made next 2 modifications to CTT design:

    • Zynq7 Processing System: MIO Configuration: I/O Peripherals: Enable UART0 and set its IO as 'EMIO'.
    • Zynq7 Processing System: MIO Configuration: Application Processor Unit: Enable Timer1 and set its IO as 'EMIO'.

    As a result I got the system with the such 'Block Diagram': zynq5_001

  2. Run Synthesis, Implementation, generate new BitStream and Export new 'Hardware' to SDK. I prefer not to lauch SDK right away for a good reason - you have to source Xilinx SDK settings and/or PetaLinux settings before running XSDK. After export finished we can close Vivado.
  3. Lets set required settings and run Xilinx SDK (XSDK). Set 'Eclipse' workspace to our ~/Projects/ directory.
  4. mkdir Projects
    cd Projects
    source /opt/Xilinx/Vivado/2013.4/settings64.sh
    xsdk

  5. We need to add PetaLinux and FreeRTOS repositories to XSDK. In XSDK -> Xilinx Tools -> 'Xilinx SDK' -> 'Repositories' -> add 'Local Repositories' from your PetaLinux 13.10 components folder. In my case PetaLinux installed into '/opt/petalinux-v2013.10-final/'. So added repo's are:
    • /opt/petalinux-v2013.10-final/components/edk_user_repository
    • /opt/petalinux-v2013.10-final/components/edk_user_repository/FreeRTOS
    • /opt/petalinux-v2013.10-final/components/edk_user_repository/FreeRTOS/bsp
    • /opt/petalinux-v2013.10-final/components/edk_user_repository/FreeRTOS/drivers

    zynq5_002

  6. Create 'Hardware Platform Specification' project using 'Hardware Platfrom' exported from our ZedBoard-AMP Vivado project. I named it 'ZedBoard-AMP-HW'.
  7. zynq5_003

  8. Create FSBL for AMP configuration using File -> New Project -> Application Project. I named it FSBL-AMP and selected 'ZedBoard-AMP-HW' as Hardware Platform, 'ps7_cortex9_0' as a Processor, 'standalone 'OS Platfrom ', after clicking 'Next' select 'Zynq FSBL' template and finish project creation. Compile both 'FSBL-AMP_bsp' and 'FSBL-AMP' projects if it didnt autobuilt.
    zynq5_004
  9. Now we will need to build a few PetaLinux projects, but before we can do this, we have to quit XSDK and source some PetaLinux settings. So, close XSDK, apply settings in next order and launch XSDK again:
  10. export CROSS_COMPILE=arm-xilinx-linux-gnueabi-
    source /opt/Xilinx/Vivado/2013.4/settings64.sh
    source /opt/petalinux-v2013.10-final/settings.sh
    xsdk

  11. Create PetaLinux BSP project. In SDK select File -> New -> Project -> 'Board Support Package'. Name it 'petalinux_bsp_amp'. Select 'ZedBoard-AMP-HW' as Hardware Platform, CPU 'ps7_cortexa9_0'. Board Support Package OS 'petalinux'. Then Finish.
    zynq5_005

    XSDK should automatically open 'Board Support Package Settings' page. Go to 'Overview' -> 'petalinux' menu of that page and set:

    • 'ps7_uart_1' for stdout and stdin.
    • 'ps7_ddr_0' for main memory.
    • 'ps7_qspi' for flash memory.
    • 'ps7_sd_0' for sdio.
    • 'ps7_ethernet' for ethernet.

    zynq5_006
    Build this project.

  12. Create FreeRTOS BSP project. In SDK select File -> New -> Project -> 'Board Support Package'. Name it 'freertos_bsp_amp'. Select 'ZedBoard-AMP-HW' as Hardware Platform, CPU 'ps7_cortexa9_1'. Board Support Package OS 'freertos'. Then Finish.
    zynq5_008

    XSDK will automatically open 'Board Support Package Settings' page now for FreeRTOS project. Then:

    • 'Overview' -> 'freertos' -> Set 'ps7_uart_0' for both stdin and stdout.
    • 'drivers' -> 'cpu_cortexa9' -> Set 'extra_compiler_flags' to '-g -DUSE_AMP=1'.

    zynq5_009

    zynq5_007
    This flag will enable AMP specific features in the FreeRTOS firmware. Hit Ok. And build this project too if it not built automatically.

  13. Create FreeRTOS test applications project. In SDK select File -> New -> Project -> 'Application Project'. Name it 'freertos_amp_demo'. Select 'ZedBoard-AMP-HW' as Hardware Platform, Processor 'ps7_cortexa9_1', OS Platfrom 'freertos', for Board Support Package select 'Use existing' -> then our 'freertos_bsp_amp' project. Click 'Next' and select 'FreeRTOS AMP' template. Click 'Finish'. And build it.

    zynq5_12

    zynq5_14

  14. We are done with XSDK for now. Close it.
  15. Now we have to create PetaLinux 'project'. And I will name it 'AMP-Demo'.

    cd ~/Projects
    export CROSS_COMPILE=arm-xilinx-linux-gnueabi-
    source /opt/Xilinx/Vivado/2013.4/settings64.sh
    source /opt/petalinux-v2013.10-final/settings.sh
    petalinux-create -t project -n AMP-Demo

    INFO: Create project: AMP-Demo
    INFO: New project successfully created in /home/d9/Projects/AMP-Demo

  16. Next step is to adjust our PetaLinux configuration to match our unique 'Hardware Platform' we created using Vivado - 'ZedBoard-AMP'. But we have to do it using BSP we created for our 'Hardware Platform' - 'petalinux_bsp_amp'. So, in a ~/Projects directory:

    cd petalinux_bsp_amp/
    petalinux-config --get-hw-description -p ../AMP-Demo/

    INFO: Checking component...
    INFO: Getting hardware description...
    INFO: Using MSS file /home/d9/Projects/petalinux_bsp_amp/system.mss and XML file /home/d9/Projects/petalinux_bsp_amp/../ZedBoard-AMP-HW/system.xml
    INFO: Copy autoconfig for PetaLinux project: /home/d9/Projects/AMP-Demo
    INFO: Merging platform settings into kernel configuration
    Auto-config file successfully updated for PetaLinux project: /home/d9/Projects/AMP-Demo
    [INFO ] generate /home/d9/Projects/AMP-Demo/subsystems/linux/hw-description/system.dts

  17. Verify, that we got the right configuration. In particular, amount of DDR memory - it should be 512M or 0x20000000. Below 'subsystems/linux/hw-description/xparameters.h' file generated in my case:
    /*
     * (C) Copyright 2007-2008 Michal Simek
     *
     * Michal SIMEK <monstr@monstr.eu>
     *
     * CAUTION: This file is automatically generated by libgen.
     * Version: Xilinx EDK 2013.4 EDK_2013.4.20131205
     * Generate by U-BOOT v4.00.c
     * Project description at http://www.monstr.eu/uboot/
     */
    
    #define XILINX_BOARD_NAME "AMP-Demo"
    
    /* ARM is ps7_cortexa9_0 */
    #define XPAR_CPU_CORTEXA9_CORE_CLOCK_FREQ_HZ	666666687
    
    /* Interrupt controller is ps7_scugic_0 */
    #define XILINX_PS7_INTC_BASEADDR		0xf8f00100
    
    /* System Timer Clock Frequency */
    #define XILINX_PS7_CLOCK_FREQ	333333343
    
    /* Uart console is ps7_uart_1 */
    #define XILINX_PS7_UART
    #define XILINX_PS7_UART_BASEADDR	0xe0001000
    #define XILINX_PS7_UART_CLOCK_HZ	50000000
    
    /* IIC doesn't exist */
    
    /* GPIO doesn't exist */
    
    /* SDIO controller is ps7_sd_0 */
    #define XILINX_PS7_SDIO_BASEADDR		0xe0100000
    
    /* Main Memory is ps7_ddr_0 */
    #define XILINX_RAM_START	0x00000000
    #define XILINX_RAM_SIZE		0x20000000
    
    /* Flash Memory is ps7_qspi_0 */
    #define XILINX_PS7_QSPI_FLASH_BASEADDR	0xE000D000
    #define XILINX_SPI_FLASH_MAX_FREQ	50000000
    #define XILINX_SPI_FLASH_CS	0
    
    /* Sysace doesn't exist */
    
    /* Ethernet controller is ps7_ethernet_0 */
    #define XILINX_PS7_GEM_BASEADDR			0xe000b000
    
  18. Next step is to configure our PetaLinux project. AMP system share memory between Linux Kernel and FreeRTOS, so PetaLinux project must be configured to segment the memory and lets split it 256M/256M since our ZedBoard have 512M total of DDR3 memory. I will also change boot media type to SD Card, Host and Product names. So, run petalinux-config and make next this changes:

    cd ~/Projects/AMP-Demo/
    petalinux-config

    zynq5_010

  19. Time to configure Linux Kernel for AMP. In a project directory:

    petalinux-config -c kernel

    In a main page:

    • Make sure that 'Enable loadable module support' is selected.
    • In 'Kernel Features' -> make sure that 'High Memory Support' is enabled.
    • In 'Kernel Features' -> change 'Memory split' to '2G/2G'.
    • In 'Device Drivers' -> 'Generic Driver Options' -> make sure 'Userspace firmware loading support' is enabled.
    • In 'Device Drivers' -> 'Remoteproc drivers(EXPERIMENTAL)' -> change 'ZYNQ remoteproc' to (module) and disble Microblaze support.
    • In 'Device Drivers' -> 'Rpmsg drivers(EXPERIMENTAL)' -> set all three modules to ('An rpmsg server sample', 'rpmsg OMX driver' and 'An FreeRTOS statistic')

    Save changes and quit from menuconfig.

  20. Configure PetaLinux project ROOTFS. All we need to change now is to in 'Apps-->' menu add/enable 'latencystat' app.

    petalinux-config -c rootfs

  21. Next very important step is to update 'Device Tree Source'(DTS). We need it to do because 'remoteproc' driver instantianated and configured by its node in a device tree.
    DTS file we need to modify located in a our petalinux project 'AMP-Demo/subsystems/linux/hw-description/system.dts'. We have to add 'remoteproc' node to 'ps7_axi_interconnect_0' device. Below a portion of my system.dts file. More details regarding 'remoteproc' you can find in a Xilinx UG978 v2013.10:

    	ps7_axi_interconnect_0: amba@0 {
    		#address-cells = <1>;
    		#size-cells = <1>;
    		compatible = "xlnx,ps7-axi-interconnect-1.00.a", "simple-bus";
    		ranges ;
    		test: remoteproc-test@0 {
    			compatible = "xlnx,zynq_remoteproc";
    			reg = < 0x0 0x10000000 >;
    			interrupt-parent = <&ps7_scugic_0>;
    			interrupts = < 0 37 4 0 38 4>;
    			firmware = "freertos";
    			ipino = <6>;
    			vring0 = <2>;
    			vring1 = <3>;
    		} ;
    		ps7_spi_0: ps7-spi@e0006000 {
    			clock-names = "ref_clk", "aper_clk";
    			clocks = <&clkc 25>, <&clkc 34>;
    			compatible = "xlnx,ps7-spi-1.00.a";
    			interrupt-parent = <&ps7_scugic_0>;
    			interrupts = <0 26 4>;
    			num-chip-select = <3>;
    			reg = <0xe0006000 0x1000>;
    			bus-num = <0>;
    			speed-hz = <1000000>;			//1000kHz
    			xlnx,has-ss0 = <0x1>;
    			xlnx,has-ss1 = <0x1>;
    			xlnx,has-ss2 = <0x1>;
    			xlnx,spi-clk-freq-hz = <0xF4240>;
    			device@0{
    				compatible="linux,spidev";
    				reg =<0>;			//CS0
    				spi-max-frequency= <1000000>;
    			};
    			device@1{
    				compatible="linux,spidev";
    				reg =<1>;			//CS1
    				spi-max-frequency= <1000000>;
    			};
    		} ;
    		ps7_spi_1: ps7-spi@e0007000 {
    			clock-names = "ref_clk", "aper_clk";
    			clocks = <&clkc 26>, <&clkc 35>;
    			compatible = "xlnx,ps7-spi-1.00.a";
    			interrupt-parent = <&ps7_scugic_0>;
    			interrupts = <0 49 4>;
    			num-chip-select = <2>;
    			reg = <0xe0007000 0x1000>;
    			bus-num = <1>;
    			speed-hz = <1000000>;			//1000kHz
    			xlnx,has-ss0 = <0x1>;
    			xlnx,has-ss1 = <0x1>;
    			xlnx,spi-clk-freq-hz = <0xF4240>;
    			device@0{
    				compatible="linux,spidev";
    				reg =<0>;			//CS0
    				spi-max-frequency= <1000000>;
    			};
    			device@1{
    				compatible="linux,spidev";
    				reg =<1>;			//CS1
    				spi-max-frequency= <1000000>;
    			};
    		} ;
    		ps7_ethernet_0: ps7-ethernet@e000b000 {
    			#address-cells = <1>;
    			#size-cells = <0>;
    			clock-names = "ref_clk", "aper_clk";
    			clocks = <&clkc 13>, <&clkc 30>;
    			compatible = "xlnx,ps7-ethernet-1.00.a";
    			interrupt-parent = <&ps7_scugic_0>;
    			interrupts = <0 22 4>;
    			local-mac-address = [ 00 0a 35 00 18 e0 ];
    			phy-handle = <&phy0>;
    			phy-mode = "rgmii-id";
    			reg = <0xe000b000 0x1000>;
    			xlnx,enet-reset = "";
    			xlnx,eth-mode = <0x1>;
    			xlnx,has-mdio = <0x1>;
    			xlnx,ptp-enet-clock = <111111115>;
    			mdio {
    				#address-cells = <1>;
    				#size-cells = <0>;
    				phy0: phy@0 {
    					compatible = "marvell,88e1116r";
    					device_type = "ethernet-phy";
    					reg = <0>;
    				} ;
    			} ;
    		} ;
    
  22. Now, with PetaLinux configured, we can add our FreeRTOS demo app we created and compiled using XSDK into PetaLinux rootfs image. In order to do it we can create PetaLinux app using template.

    cd ~/Projects/AMP-Demo/
    petalinux-create -t apps --template install -n freertos_fw

    INFO: Create apps: freertos_fw
    INFO: New apps successfully created in /home/d9/Projects/AMP-Demo/components/apps/freertos_fw

  23. Copy our FreeRTOS compiled app into PetaLinux apps directory:

    cd ~/Projects/AMP-Demo/components/apps/freertos_fw/
    cp ../../../../freertos_amp_demo/Debug/freertos_amp_demo.elf data/freertos

  24. Modify 'install' section of Makefile in the app folder:
    ifndef PETALINUX
    $(error "Error: PETALINUX environment variable not set.  Change to the root of your PetaLinux install, and source the settings.sh file")
    endif
    
    include $(PETALINUX)/components/apps/apps.common.mk
    
    all: build install
    
    build:
    
    clean:
    
    .PHONY: install image
    
    install:
            $(TARGETINST) -d data/freertos /lib/firmware/freertos
    
  25. Configure PetaLinux 'rootfs' to include this new 'freertos_fw' in 'Apps-->' menu:

    cd ~/Projects/AMP-Demo/
    petalinux-config -c rootfs

    zynq5_011

  26. Build PetaLinux project, create BOOT.BIN image using our 'FSBL-AMP' and 'ZedBoard-AMP' bitstream file. Create/update prebuilt configuration.

    cd ~/Projects/AMP-Demo/
    petalinux-build
    petalinux-package --boot --fsbl ../FSBL-AMP/Debug/FSBL-AMP.elf --fpga ../ZedBoard-AMP-HW/system_wrapper.bit --uboot --force -o images/linux/BOOT.BIN
    petalinux-package --prebuilt --fpga ../ZedBoard-AMP-HW/system_wrapper.bit --force

  27. Copy BOOT.BIN and image.ub to sd card, set ZedBoard MIO3, MIO4 and MIO5 to 'SD Boot' configuration and turn ZedBoard on.
  28. Login as 'root'/'root' and verify our kernel version and build timestamp.

    root@ZedBoard-AMP:~# uname -a
    Linux ZedBoard-AMP 3.8.11 #2 SMP PREEMPT Wed Feb 26 15:39:37 EST 2014 armv7l GNU/Linux
    root@ZedBoard-AMP:~#

  29. Because we included remoteproc as a module and it not loaded yet - Linux must be using both CPU's in a conventional SMP way. Lets verify it:

    more /proc/cpuinfo

    processor       : 0
    model name      : ARMv7 Processor rev 0 (v7l)
    BogoMIPS        : 1332.01
    Features        : swp half thumb fastmult vfp edsp neon vfpv3 tls 
    CPU implementer : 0x41
    CPU architecture: 7
    CPU variant     : 0x3
    CPU part        : 0xc09
    CPU revision    : 0
    
    processor       : 1
    model name      : ARMv7 Processor rev 0 (v7l)
    BogoMIPS        : 1332.01
    Features        : swp half thumb fastmult vfp edsp neon vfpv3 tls 
    CPU implementer : 0x41
    CPU architecture: 7
    CPU variant     : 0x3
    CPU part        : 0xc09
    CPU revision    : 0
    
    Hardware        : Xilinx Zynq Platform
    Revision        : 0000
    Serial          : 0000000000000000
    
  30. Now, lets load remoteproc driver:

    modprobe zynq_remoteproc

    CPU1: shutdown
     remoteproc0: 0.remoteproc-test is available
     remoteproc0: Note: remoteproc is still under development and considered experimental.
     remoteproc0: THE BINARY FORMAT IS NOT YET FINALIZED, and backward compatibility isn't yet guaranteed.
    

    modprobe rpmsg_freertos_statistic

     remoteproc0: powering up 0.remoteproc-test
     remoteproc0: Booting fw image freertos, size 2130820
     remoteproc0: remote processor 0.remoteproc-test is now up
    virtio_rpmsg_bus virtio0: rpmsg host is online
    virtio_rpmsg_bus virtio0: creating channel rpmsg-timer-statistic addr 0x50
    rpmsg_freertos_statistic rpmsg0: new channel: 0x400 -> 0x50!
    

    So, second Processor unloaded from Linux and is setup to execute the FreeRTOS firmware.

  31. Now, we can run 'latencystat' FreeRTOS demo app.

    latencystat -b

    Linux FreeRTOS AMP Demo.
       0: Command 0 ACKed
       1: Command 1 ACKed
    Waiting for samples...
       2: Command 2 ACKed
       3: Command 3 ACKed
       4: Command 4 ACKed
    -----------------------------------------------------------
    Histogram Buckvirtio_rpmsg_bus virtio0: msg received with no recepient
    et Values:
    	Bucket 341 ns (38 ticks) had 14813 frequency
    	Bucket 431 ns (48 ticks) had 1 frequency
    	Bucket 521 ns (58 ticks) had 1 frequency
    	Bucket 593 ns (66 ticks) had 1 frequency
    	Bucket 692 ns (77 ticks) had 1 frequency
    -----------------------------------------------------------
    Histogram Data:
    	min: 341 ns (38 ticks)
    	avg: 341 ns (38 ticks)
    	max: 692 ns (77 ticks)
    	out of range: 0
    	total samples: 14817
    -----------------------------------------------------------
    root@ZedBoard-AMP:~#
    
  32. Access the TraceBuffer - a section of shared memory which is only written to by the FreeRTOS application. This
    TraceBuffer used as a logging console to transfer information to Linux and 'latencystat' app uses it. So, lets check it out:

    more /sys/kernel/debug/remoteproc/remoteproc0/trace0

    Congratulation! We got Linux-FreeRTOS AMP configuration running on our ZedBoard.

Use SDCard to boot ZedBoard using PetaLinux 13.10

Up until now, I was using JTAG to boot my ZedBoard using PetaLinux builds. But at some point we will neet to switch to QSPI or SDCard. This post will be about using SD Card. And PetaLinux 13.10 made this process very easy. For default U-boot 2013.07 all we need to do is to change boot device in PetaLinux configurations.

I will use Avnet-Digilent-ZedBoard-2013.3 project I used before. See here for more details about how to install it:

  1. First, go to your project directory and run petalinux-config tool
  2. d9@ubuntu:~$ cd Projects/Avnet-Digilent-ZedBoard-2013.3/
    d9@ubuntu:~/Projects/Avnet-Digilent-ZedBoard-2013.3$ petalinux-config

  3. In a main manu select 'System boot device' submenu.
  4. zynq4_001

  5. Inside 'System boot device' menu switch to 'SD card' option.
  6. zynq4_002

  7. Save configuration and exit.
  8. Now, lets clean and rebuild images - in our project directory:
  9. petalinux-build -x mrproper
    petalinux-build

  10. To Re-generate BOOT.BIN in our project directory run:
  11. petalinux-package --boot --fsbl pre-built/linux/images/zynq_fsbl.elf --fpga pre-built/linux/implementation/download.bit --uboot --force -o images/linux/BOOT.BIN

    INFO: Generating zynq binary package BOOT.BIN...
    INFO: Binary is ready.

  12. Copy BOOT.BIN and image.ub from our project Avnet-Digilent-ZedBoard-2013.3/images/linux directory to SD card. And we done. Umount SD card, install it into ZedBoard, set jumpers to SDCard boot mode (MIO3 to ground position, MIO4 and MIO5 to high) and power board.
  13. Run gtkterm to monitor the process.
    Btw, if you expireince 20-40 seconds delay before you can access port with error "cannot open /dev/ttyACM0: Device or resource busy" and/or sometimes U-boot process stopped without any error and will continue to boot when you type 'boot' command - you may want to uninstall Ubuntu's ModemManager which cause all this things by trying to access/control our port once it powered.
  14. sudo apt-get purge modemmanager

Update U-boot and Linux Kernel for PetaLinux 13.10.

PetaLinux 13.10 coming with U-boot vesrion 2013.07 and Linux Kernel 3.8.1. If for some reason you need to change U-boot and/or Linux kernel with newer one - u can do it manually(configure, compile and include to BOOT.BIN image) or using PetaLinux tools to automate it. This post will be about later.
I will do it on virtual machine (VMWare Workstation 10) running Ubuntu 13.10 64 bit version with PetaLinux 13.10 already installed. I will also use fresh installation of prebuilt Avnet-Digilent BSP for ZedBoard, but this recipe works for my custom "hardware design" for ZedBoard too.

  1. So, since I'm using 64 bit Ubuntu, I'm missing quite a few packages, especially 32bit versions. Below the list, but some package uninstalled my 64 version of GCC, so I re-install it as a last step.
  2. sudo apt-get install gawk
    sudo apt-get install build-essential
    sudo apt-get install automake
    sudo apt-get install libtool
    sudo apt-get install lib32ncurses5
    sudo apt-get install lib32ncurses5-dev
    sudo apt-get install lib32ncursesw5
    sudo apt-get install ncurses-dev:i386
    sudo apt-get install libstdc++6:i386
    sudo apt-get install libselinux1:i386
    sudo apt-get install gcc

  3. Also, gmake package for Ubuntu not exist, but some Xilinx tools relay on it, so lets gmake symlink to make:

    sudo ln -s /usr/bin/make /usr/bin/gmake

  4. We also have to source PetaLinux settings, but because I'm always forget to do it - I will change my .bashrc so it will be done automatically, each time I log in. SO, in home directory, add next instructions to the end of the ~/.bashrc file.

    export CROSS_COMPILE=arm-xilinx-linux-gnueabi-
    source /opt/petalinux-v2013.10-final/settings.sh
    source /opt/Xilinx/Vivado/2013.4/settings64.sh

  5. Next, download 'petalinux-v2013.10-final-installer.run' from Xilinx website and put in ~/Downloads directory.
  6. Now, let's create 'Projects' forlder for our PetaLinux projects and install Avnet-Digilent BSP project into it. It will create 2 projects for us: Vivado 13.3 and ISE-14.7. I will use Vivado one and we can delete 14.7.
  7. d9@ubuntu:~$ mkdir Projects
    d9@ubuntu:~$ cd Projects
    d9@ubuntu:~/Projects$ petalinux-create -t project -s ../Downloads/Avnet-Digilent-ZedBoard-v2013.10-final.bsp

    INFO: Create project:
    INFO: Projects:
    INFO: * Avnet-Digilent-ZedBoard-14.7
    INFO: * Avnet-Digilent-ZedBoard-2013.3
    INFO: has been successfully installed to /home/d9/Projects/
    INFO: New project successfully created in /home/d9/Projects/

    d9@ubuntu:~/Projects$ cd Avnet-Digilent-ZedBoard-2013.3/

  8. Let's test prebuilt packages using JTAG on our ZedBoard. Set MIO3, MIO4 and MIO5 jumpers on ZedBoard to JTAG boot(all to GND), turn board on, run 'gtkterm' (use ZedBoard USB-to-Serial port) and boot using petalinux-boot. Below output I got on my ZedBoard:
  9. d9@ubuntu:~/Projects/Avnet-Digilent-ZedBoard-2013.3$ petalinux-boot --jtag --prebuilt 3

    U-Boot 2013.07 (Nov 21 2013 - 18:27:09)
    
    Memory: ECC disabled
    DRAM:  512 MiB
    MMC:   zynq_sdhci: 0
    SF: Detected S25FL256S_64K with page size 64 KiB, total 32 MiB
    *** Warning - bad CRC, using default environment
    
    In:    serial
    Out:   serial
    Err:   serial
    Net:   Gem.e000b000
    U-BOOT for Avnet-Digilent-ZedBoard-2013.3
    
    Gem.e000b000 Waiting for PHY auto negotiation to complete...Booting Linux on physical CPU 0x0
    Linux version 3.8.11 (xbrbbot@xbrlab02) (gcc version 4.7.3 (Sourcery CodeBench Lite 2013.05-40) ) 
    #2 SMP PREEMPT Thu Nov 21 18:30:11 EST 2013
    CPU: ARMv7 Processor [413fc090] revision 0 (ARMv7), cr=18c5387d
    CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
    Machine: Xilinx Zynq Platform, model: .
    Memory policy: ECC disabled, Data cache writealloc
    PERCPU: Embedded 7 pages/cpu @c1004000 s6592 r8192 d13888 u32768
    Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 130048
    Kernel command line: console=ttyPS0,115200
    PID hash table entries: 2048 (order: 1, 8192 bytes)
    Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
    Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
    __ex_table already sorted, skipping sort
    Memory: 512MB = 512MB total
    Memory: 507392k/507392k available, 16896k reserved, 0K highmem
    Virtual kernel memory layout:
        vector  : 0xffff0000 - 0xffff1000   (   4 kB)
        fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)
        vmalloc : 0xe0800000 - 0xff000000   ( 488 MB)
        lowmem  : 0xc0000000 - 0xe0000000   ( 512 MB)
        pkmap   : 0xbfe00000 - 0xc0000000   (   2 MB)
        modules : 0xbf000000 - 0xbfe00000   (  14 MB)
          .text : 0xc0008000 - 0xc04eafd4   (5004 kB)
          .init : 0xc04eb000 - 0xc0bb39c0   (6947 kB)
          .data : 0xc0bb4000 - 0xc0be1900   ( 183 kB)
           .bss : 0xc0be1900 - 0xc0bfcff0   ( 110 kB)
    Preemptible hierarchical RCU implementation.
    NR_IRQS:16 nr_irqs:16 16
    xslcr mapped to e0802000
    Zynq clock init
    sched_clock: 16 bits at 54kHz, resolution 18432ns, wraps every 1207ms
    ps7-ttc #0 at e0804000, irq=43
    Console: colour dummy device 80x30
    Calibrating delay loop... 1332.01 BogoMIPS (lpj=6660096)
    pid_max: default: 32768 minimum: 301
    Mount-cache hash table entries: 512
    CPU: Testing write buffer coherency: ok
    Setting up static identity map for 0x359180 - 0x3591b4
    L310 cache controller enabled
    l2x0: 8 ways, CACHE_ID 0x000000c0, AUX_CTRL 0x72360000, Cache size: 524288 B
    CPU1: Booted secondary processor
    Brought up 2 CPUs
    SMP: Total of 2 processors activated (2664.03 BogoMIPS).
    devtmpfs: initialized
    NET: Registered protocol family 16
    DMA: preallocated 256 KiB pool for atomic coherent allocations
    xgpiops e000a000.ps7-gpio: gpio at 0xe000a000 mapped to 0xe084e000
    bio: create slab <bio-0> at 0
    GPIO IRQ not connected
    XGpio: /amba@0/gpio@41200000: registered, base is 251
    GPIO IRQ not connected
    XGpio: /amba@0/gpio@41210000: registered, base is 243
    GPIO IRQ not connected
    XGpio: /amba@0/gpio@41220000: registered, base is 235
    SCSI subsystem initialized
    usbcore: registered new interface driver usbfs
    usbcore: registered new interface driver hub
    usbcore: registered new device driver usb
    Switching to clocksource xttcps_clocksource
    NET: Registered protocol family 2
    TCP established hash table entries: 4096 (order: 3, 32768 bytes)
    TCP bind hash table entries: 4096 (order: 3, 32768 bytes)
    TCP: Hash tables configured (established 4096 bind 4096)
    TCP: reno registered
    UDP hash table entries: 256 (order: 1, 8192 bytes)
    UDP-Lite hash table entries: 256 (order: 1, 8192 bytes)
    NET: Registered protocol family 1
    RPC: Registered named UNIX socket transport module.
    RPC: Registered udp transport module.
    RPC: Registered tcp transport module.
    RPC: Registered tcp NFSv4.1 backchannel transport module.
    jffs2: version 2.2. (NAND) (SUMMARY)  © 2001-2006 Red Hat, Inc.
    msgmni has been set to 991
    Block layer SCSI generic (bsg) driver version 0.4 loaded (major 253)
    io scheduler noop registered
    io scheduler deadline registered
    io scheduler cfq registered (default)
    e0001000.serial: ttyPS0 at MMIO 0xe0001000 (irq = 82) is a xuartps
    console [ttyPS0] enabled
    xdevcfg f8007000.ps7-dev-cfg: ioremap f8007000 to e0874000 with size 100
    st: Version 20101219, fixed bufsize 32768, s/g segs 256
    osst :I: Tape driver with OnStream support version 0.99.4
    osst :I: $Id: osst.c,v 1.73 2005/01/01 21:13:34 wriede Exp $
    SCSI Media Changer driver v0.25 
    xqspips e000d000.ps7-qspi: master is unqueued, this is deprecated
    m25p80 spi32766.0: fallback to 3-byte address mode
    m25p80 spi32766.0: maximum accessible size is 16MB
    m25p80 spi32766.0: s25fl256s1 (32768 Kbytes)
    4 ofpart partitions found on MTD device spi32766.0
    Creating 4 MTD partitions on "spi32766.0":
    0x000000000000-0x000000500000 : "boot"
    0x000000500000-0x000000520000 : "bootenv"
    0x000000520000-0x000000fa0000 : "image"
    0x000000fa0000-0x000002000000 : "spare"
    xqspips e000d000.ps7-qspi: at 0xE000D000 mapped to 0xE0876000, irq=51
    libphy: XEMACPS mii bus: probed
    xemacps e000b000.ps7-ethernet: pdev->id -1, baseaddr 0xe000b000, irq 54
    ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
    ULPI transceiver vendor/product ID 0x0451/0x1507
    Found TI TUSB1210 ULPI transceiver.
    ULPI integrity check: passed.
    xusbps-dr xusbps-udc.0: Controller already in use
    xusbps-dr: probe of xusbps-udc.0 failed with error -16
    Initializing USB Mass Storage driver...
    usbcore: registered new interface driver usb-storage
    USB Mass Storage support registered.
    i2c /dev entries driver
    xadcps f8007100.ps7-xadc: enabled:	yes	reference:	external
    sdhci: Secure Digital Host Controller Interface driver
    sdhci: Copyright(c) Pierre Ossman
    sdhci-pltfm: SDHCI platform and OF driver helper
    mmc0: SDHCI controller on e0100000.ps7-sdio [e0100000.ps7-sdio] using ADMA
    usbcore: registered new interface driver usbhid
    usbhid: USB HID core driver
    TCP: cubic registered
    NET: Registered protocol family 10
    sit: IPv6 over IPv4 tunneling driver
    NET: Registered protocol family 17
    NET: Registered protocol family 40
    VFP support v0.3: implementor 41 architecture 3 part 30 variant 9 rev 4
    Registering SWP/SWPB emulation handler
    Freeing init memory: 6944K
    INIT: version 2.88 booting
    mmc0: new high speed SDHC card at address aaaa
    mmcblk0: mmc0:aaaa SU32G 29.7 GiB 
     mmcblk0: p1
    Starting Bootlog daemon: bootlogd.
    Creating /dev/flash/* device nodes
    Configuring network interfaces... udhcpc (v1.20.2) started
    Sending discover...
    xemacps e000b000.ps7-ethernet: Set clk to 24999999 Hz
    xemacps e000b000.ps7-ethernet: link up (100/HALF)
    IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
    Sending discover...
    Sending select for 172.19.1.113...
    Lease of 172.19.1.113 obtained, lease time 28800
    /etc/udhcpc.d/50default: Adding DNS 172.19.2.60
    /etc/udhcpc.d/50default: Adding DNS 172.19.2.56
    done.
    starting Busybox inet Daemon: inetd... done.
    Starting uWeb server:
    INIT: Entering runlevel: 5
    Stopping Bootlog daemon: bootlogd.
    
     _____       _           _      _
    | ___ \     | |         | |    (_)
    | |_/ / ___ | |_   __ _ | |     _  _ __   _   _ __  __
    |  __/ / _ \| __| / _` || |    | || '_ \ | | | |\ \/ /
    | |   |  __/| |_ | (_| || |____| || | | || |_| | >  <
    \_|    \___| \__| \__,_|\_____/|_||_| |_| \__,_|/_/\_\
    
    PetaLinux v2013.10 (Yocto 1.4) Avnet-Digilent-ZedBoard-2013_3 ttyPS0
    
    Avnet-Digilent-ZedBoard-2013_3 login:
    
  10. As you can see very first in a log is U-boot version and build timestamp: U-Boot 2013.07 (Nov 21 2013 - 18:27:09).
    Loging as 'root'/'root' and check what version of kernel we got. It's 3.8.11 and it built on Thu Nov 21 18:30:11 EST 2013.
  11. root@Avnet-Digilent-ZedBoard-2013_3:~# uname -a
    Linux Avnet-Digilent-ZedBoard-2013_3 3.8.11 #2 SMP PREEMPT Thu Nov 21 18:30:11 EST 2013 armv7l GNU/Linux

  12. Now, let's verify that we can reconfigure and rebuild existing kernel, uboot and rootfs. Run petalinux-config for each one, but don't change any settings yet. Just go thru menus if you like and exit. If you got any errors - most likely your installation missing some packages.
  13. d9@ubuntu:~/Projects/Avnet-Digilent-ZedBoard-2013.3$ petalinux-config
    d9@ubuntu:~/Projects/Avnet-Digilent-ZedBoard-2013.3$ petalinux-config -c kernel
    d9@ubuntu:~/Projects/Avnet-Digilent-ZedBoard-2013.3$ petalinux-config -c rootfs

  14. Clean whatever we may have from previus builds and re-build it.
  15. d9@ubuntu:~/Projects/Avnet-Digilent-ZedBoard-2013.3$ petalinux-build -x mrproper
    d9@ubuntu:~/Projects/Avnet-Digilent-ZedBoard-2013.3$ petalinux-build

  16. This is the build log I got.
  17. INFO: Checking component...
    INFO: Generating make files and build linux
    INFO: Generating make files for the subcomponents of linux
    INFO: Building linux
    [INFO ] pre-build linux/rootfs/fwupgrade
    [INFO ] pre-build linux/rootfs/peekpoke
    [INFO ] pre-build linux/rootfs/uWeb
    [INFO ] build system.dtb
    [INFO ] build linux/kernel
    [INFO ] update linux/u-boot source
    [INFO ] generate linux/u-boot configuration files
    [INFO ] build linux/u-boot
    [INFO ] Setting up stage config
    [INFO ] Setting up rootfs config
    [INFO ] Updating for armv7a-vfp-neon
    [INFO ] Updating package manager
    [INFO ] Expanding stagefs
    [INFO ] build linux/rootfs/fwupgrade
    [INFO ] build linux/rootfs/peekpoke
    [INFO ] build linux/rootfs/uWeb
    [INFO ] build kernel in-tree modules
    [INFO ] modules linux/kernel
    [INFO ] post-build linux/rootfs/fwupgrade
    [INFO ] post-build linux/rootfs/peekpoke
    [INFO ] post-build linux/rootfs/uWeb
    [INFO ] pre-install linux/rootfs/fwupgrade
    [INFO ] pre-install linux/rootfs/peekpoke
    [INFO ] pre-install linux/rootfs/uWeb
    [INFO ] install linux/kernel
    [INFO ] install linux/u-boot
    [INFO ] Setting up rootfs config
    [INFO ] Setting up stage config
    [INFO ] Updating for armv7a-vfp-neon
    [INFO ] Updating package manager
    [INFO ] Expanding rootfs
    [INFO ] install sys_init
    [INFO ] install linux/rootfs/fwupgrade
    [INFO ] install linux/rootfs/peekpoke
    [INFO ] install linux/rootfs/uWeb
    [INFO ] install kernel in-tree modules
    [INFO ] modules_install linux/kernel
    [INFO ] post-install linux/rootfs/fwupgrade
    [INFO ] post-install linux/rootfs/peekpoke
    [INFO ] post-install linux/rootfs/uWeb
    [INFO ] package rootfs.cpio to /home/d9/Projects/Avnet-Digilent-ZedBoard-2013.3/images/linux
    [INFO ] Update and install vmlinux image
    [INFO ] vmlinux linux/kernel
    [INFO ] install linux/kernel
    [INFO ] package zImage
    [INFO ] zImage linux/kernel
    [INFO ] install linux/kernel
    [INFO ] package FIT image

  18. Now, we need to generate BOOT.BIN which includes our hardware implementation bitstream, FSBL and U-boot. Bitstream and FSBL executable are the same, so we will point them to petalinux tool and it will use just built u-boot exec. By default tool will put BOOT.BIN in current directory, but we need it to be in images directory. I will also force to replace file if it exists.
  19. petalinux-package --boot --fsbl pre-built/linux/images/zynq_fsbl.elf --fpga pre-built/linux/implementation/download.bit --uboot --force -o images/linux/BOOT.BIN

    INFO: Generating zynq binary package BOOT.BIN...
    INFO: Binary is ready.

  20. Replace, so called, prebuilt configuration for our PetaLinux project
  21. petalinux-package --prebuilt --fpga pre-built/linux/implementation/download.bit --force

    INFO: Pre-built directory is updated.

  22. Now we are ready to boot our rebuilt images using JTAG. So, reset ZedBoard (with JP13 shorted) or repower and run. Verify that we have same version of U-boot (2013.07) and Kernel 3.8.11, but build date is new.
  23. d9@ubuntu:~/Projects/Avnet-Digilent-ZedBoard-2013.3$ petalinux-boot --jtag --prebuilt 3

    INFO: The image provided is a zImage and no addition options were provided
    INFO: Append dtb - /home/d9/Projects/Avnet-Digilent-ZedBoard-2013.3/pre-built/linux/images/system.dtb and other options to boot zImage
    INFO: Configuring the FPGA...
    INFO: FPGA configuration completed.
    INFO: Downloading FSBL
    INFO: FSBL download completed.
    INFO: Launching XMD for file download and boot.
    INFO: This may take a few minutes, depending on the size of your image.

    U-Boot 2013.07 (Feb 19 2014 - 14:43:34)
    Linux Avnet-Digilent-ZedBoard-2013_3 3.8.11 #2 SMP PREEMPT Wed Feb 19 14:45:59 EST 2014 armv7l GNU/Linux

  24. Now, lets download new versions of U-boot and Linux kernel for Xilinx Git repository. More about Xilinx repo you can read on
  25. sudo git clone git://github.com/Xilinx/linux-xlnx.git /opt/linux-xlnx-git

    Cloning into '/opt/linux-xlnx-git'...
    remote: Reusing existing pack: 3464199, done.
    remote: Counting objects: 102, done.
    remote: Compressing objects: 100% (102/102), done.
    remote: Total 3464301 (delta 55), reused 0 (delta 0)
    Receiving objects: 100% (3464301/3464301), 827.49 MiB | 5.99 MiB/s, done.
    Resolving deltas: 100% (2906448/2906448), done.
    Checking connectivity... done
    Checking out files: 100% (44825/44825), done.

    sudo git clone git://github.com/Xilinx/u-boot-xlnx.git /opt/u-boot-xlnx-git

    Cloning into '/opt/u-boot-xlnx-git'...
    remote: Reusing existing pack: 252804, done.
    remote: Total 252804 (delta 0), reused 0 (delta 0)
    Receiving objects: 100% (252804/252804), 69.40 MiB | 6.19 MiB/s, done.
    Resolving deltas: 100% (201743/201743), done.
    Checking connectivity... done

  26. Let's see what we got.
  27. d9@ubuntu:~/Projects/Avnet-Digilent-ZedBoard-2013.3$ cd /opt/linux-xlnx-git/
    d9@ubuntu:/opt/linux-xlnx-git$ git describe
    xilinx-v2013.4

    VERSION = 3
    PATCHLEVEL = 12
    SUBLEVEL = 0
    EXTRAVERSION =
    NAME = One Giant Leap for Frogkind

    d9@ubuntu:/opt/linux-xlnx-git$ cd /opt/u-boot-xlnx-git/
    d9@ubuntu:/opt/u-boot-xlnx-git$ git describe
    xilinx-v2013.4
    d9@ubuntu:/opt/u-boot-xlnx-git$ more Makefile

    #
    # (C) Copyright 2000-2013
    # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
    #
    # SPDX-License-Identifier: GPL-2.0+
    #

    VERSION = 2013
    PATCHLEVEL = 10
    SUBLEVEL =
    EXTRAVERSION =

  28. So, for what its worth, for Kernel we got Git tag version 2013.4 and Makefile saying its 3.12.0. And for U-boot Git tag is 2013.4 and Makefile 2013.10.
    Now we can copy Linux Kernel and U-Boot sources into our PetaLinux projects, but first we have to create some directories
  29. d9@ubuntu:~/Projects/Avnet-Digilent-ZedBoard-2013.3$ mkdir components
    d9@ubuntu:~/Projects/Avnet-Digilent-ZedBoard-2013.3$ mkdir components/linux-kernel
    d9@ubuntu:~/Projects/Avnet-Digilent-ZedBoard-2013.3$ mkdir components/u-boot

    d9@ubuntu:~/Projects/Avnet-Digilent-ZedBoard-2013.3$ cp -r /opt/linux-xlnx-git components/linux-kernel/
    d9@ubuntu:~/Projects/Avnet-Digilent-ZedBoard-2013.3$ cp -r /opt/u-boot-xlnx-git components/u-boot/

  30. Configure PetaLinux project to include new kernel and u-boot sources. Run petalinux-config.
  31. d9@ubuntu:~/Projects/Avnet-Digilent-ZedBoard-2013.3$ petalinux-config

  32. In a main menu select 'kernel' submenu and then switch from kernel 'xlnx-3.8' kernel to our new 'linux-xlnx-git'.
  33. In a main menu select 'u-boot' submenu and then switch to 'u-boot-xlnx-git'.
  34. In a main menu select 'u-boot config' and then switch to 'other'.
  35. In a main menu select 'u-boot config target (NEW)' and type 'zynq_zed'.
  36. zynq3_001

  37. Save configuration and exit from menus. You can read more about options for Xilinx version of U-boot at , unfortunately not much more.

    I went thru Xilinx Wiki pages and all PetaLinux documentation for 13.10 version and found very little information about u-boot customization options. I also went thru U-boot configuration scripts for PetaLinux and U-boot sources and found no specific different between Zynq_Zed and Zynq_Zc70x targets. Where is no 'MicroZed' target and I'm not sure if Zed or Zc70x will work for it.
    If somebody knows more about Xilinx patches and/or configuration for U-boot - please share information. I'm in particular interesting if I will need to change U-boot configuration to support my custom board, what and how.

  38. Anyway. Now we can rebuild whole thing.
  39. d9@ubuntu:~/Projects/Avnet-Digilent-ZedBoard-2013.3$ petalinux-build -x mrproper
    d9@ubuntu:~/Projects/Avnet-Digilent-ZedBoard-2013.3$ petalinux-build

    INFO: Checking component...
    INFO: Generating make files and build linux
    INFO: Generating make files for the subcomponents of linux
    INFO: Building linux
    [INFO ] pre-build linux/rootfs/fwupgrade
    [INFO ] pre-build linux/rootfs/peekpoke
    [INFO ] pre-build linux/rootfs/uWeb
    [INFO ] build system.dtb
    [INFO ] build linux/kernel
    [INFO ] update linux/u-boot source
    [INFO ] generate linux/u-boot configuration files
    [INFO ] build linux/u-boot
    [INFO ] Setting up stage config
    [INFO ] Setting up rootfs config
    [INFO ] Updating for armv7a-vfp-neon
    [INFO ] Updating package manager
    [INFO ] Expanding stagefs
    [INFO ] build linux/rootfs/fwupgrade
    [INFO ] build linux/rootfs/peekpoke
    [INFO ] build linux/rootfs/uWeb
    [INFO ] build kernel in-tree modules
    [INFO ] modules linux/kernel
    [INFO ] post-build linux/rootfs/fwupgrade
    [INFO ] post-build linux/rootfs/peekpoke
    [INFO ] post-build linux/rootfs/uWeb
    [INFO ] pre-install linux/rootfs/fwupgrade
    [INFO ] pre-install linux/rootfs/peekpoke
    [INFO ] pre-install linux/rootfs/uWeb
    [INFO ] install linux/kernel
    [INFO ] install linux/u-boot
    [INFO ] Setting up rootfs config
    [INFO ] Setting up stage config
    [INFO ] Updating for armv7a-vfp-neon
    [INFO ] Updating package manager
    [INFO ] Expanding rootfs
    [INFO ] install sys_init
    [INFO ] install linux/rootfs/fwupgrade
    [INFO ] install linux/rootfs/peekpoke
    [INFO ] install linux/rootfs/uWeb
    [INFO ] install kernel in-tree modules
    [INFO ] modules_install linux/kernel
    [INFO ] post-install linux/rootfs/fwupgrade
    [INFO ] post-install linux/rootfs/peekpoke
    [INFO ] post-install linux/rootfs/uWeb
    [INFO ] package rootfs.cpio to /home/d9/Projects/Avnet-Digilent-ZedBoard-2013.3/images/linux
    [INFO ] Update and install vmlinux image
    [INFO ] vmlinux linux/kernel
    [INFO ] install linux/kernel
    [INFO ] package zImage
    [INFO ] zImage linux/kernel
    [INFO ] install linux/kernel
    [INFO ] package FIT image

  40. Build BOOT.BIN and refresh Pre-built package using same commands:
  41. d9@ubuntu:~/Projects/Avnet-Digilent-ZedBoard-2013.3$ petalinux-package --boot --fsbl pre-built/linux/images/zynq_fsbl.elf --fpga pre-built/linux/implementation/download.bit --uboot --force -o images/linux/BOOT.BIN
    INFO: Generating zynq binary package BOOT.BIN...
    INFO: Binary is ready.
    d9@ubuntu:~/Projects/Avnet-Digilent-ZedBoard-2013.3$ petalinux-package --prebuilt --fpga pre-built/linux/implementation/download.bit --forceINFO: Pre-built directory is updated.

  42. Reset board and boot using JTAG:
  43. d9@ubuntu:~/Projects/Avnet-Digilent-ZedBoard-2013.3$ petalinux-boot --jtag --prebuilt 3

    INFO: The image provided is a zImage and no addition options were provided
    INFO: Append dtb - /home/d9/Projects/Avnet-Digilent-ZedBoard-2013.3/pre-built/linux/images/system.dtb and other options to boot zImage
    INFO: Configuring the FPGA...
    INFO: FPGA configuration completed.
    INFO: Downloading FSBL
    INFO: FSBL download completed.
    INFO: Launching XMD for file download and boot.
    INFO: This may take a few minutes, depending on the size of your image.

  44. Verify that now U-boot version is 2013.10 and Linux Kernel is 3.12.0
  45. U-Boot 2013.10 (Feb 19 2014 - 15:47:16)

    Linux Avnet-Digilent-ZedBoard-2013_3 3.12.0+ #2 SMP PREEMPT Wed Feb 19 15:49:58 EST 2014 armv7l GNU/Linux

    Congratulations! We got latest Xilinx patched u-boot and kernel version running on our ZedBoard.

    P.S. I tried to download and build vanilla Linux Kernel versions 3.12.11 and 3.13.3 from kernel.org - it builds and boots, but some hardware not working. So, we may need to apply some Xilinx Zynq related patches to vanilla kernel, but this is another topic.