Running Ubuntu on Zynq-7000

I have lately needed to get Ubuntu running on my Zynq, and as usual, it required a bit more a following a recipe. My final goal was to run a macro benchmark where the task was to compile the Linux Kernel for ARM in the Zynq itself. In this post, I will go through what are the necessary steps to get Ubuntu running on the Zynq, what is needed to get a working apt-get, and finally how to fix some compilation errors when compiling the kernel. Note that the last point is not specific for the kernel, but it can happen even when compiling a simple Hello World.

While Xilinx documentation for running Ubuntu on Zynq is a *very good* place to start (test binaries, initial Ubuntu root filesystem, device tree, etc); there is some outdated/missing necessary steps. I will go through all the steps and point to the relevant Xilinx documentation when necessary:

    1. Partition the SD card so that one can be used as boot partition and the other as root file system (Ubuntu). Follow these instructions for partitioning the SD card (the instructions also include how to set the Zynq to boot from the SD card).
    2. Download the binaries for the boot partition and the root file system. (the links are taken from in case you don’t trust mine – I won’t take it personal, I would not trust random links either :))
    3. Extract the boot images and copy the necessary files to the SD card:
      $ tar xvJf zynq-ubuntu-core-12.10-core-armhf-boot.tar.xz
      $ mount /dev/sdX1 /mnt/boot
      $ cp boot/uImage boot/uramdisk.image.gz boot/zc702/boot.bin boot/zc702/devicetree.dtb /mnt/boot
      $ umount /dev/sdX1
      $ tar xvJf zynq-ubuntu-core-12.10-core-armhf-rootfs.tar.xz
      $ mount /dev/sdX2 /mnt/root
      $ cp roots/* /mnt/root
      $ umount /dev/sdX2
    4. Log in. root: root, pass:root
    5. Enable dhcp
      $ dhclient eth0
      1. In order to wake the interface up automatically on reboot, add the following lines to /etc/network/interfaces
        $ auto eth0 
        $ iface eth0 inet dhcp
    6. Update the Ubuntu repositories (source.list) with the following repositories:
      >>  deb saucy main universe restricted
      >>  deb saucy-security universe
      >>  deb saucy-updates universe
      >>  deb quantal main
      >>  deb quantal main restricted

      $ vi /etc/apt/sources.list
      [add repositories]
      $ apt-get upgrade
      $ apt-get update
    7. Install a compilation environment
      $ apt-get install build-essential
      $ apt-get install libssl-dev
      $ apt-get install u-boot-tools

At this points you should have a pretty much functional Ubuntu running on your Zynq. Since the repositories are updated, it is possible to install almost anything that you can run in a normal ubuntu distribution.

In my case, since I want to compile the Linux Kernel in the Zynq, I need to install git and clone a linux tree that can run in the Zynq (this is not a requirement, but still).

$ apt-get install git
$ git clone git://
$ git checkout -b zynq_base_trd_14_5 xilinx-14.5-build-trd

Now, if you try to compile the kernel, you will get this error (several times):

$ undefined reference to `__stack_chk_fail'
$ undefined reference to `__stack_chk_guard'

The problem comes because gcc is using the stack protector, but libc was – for some reason – not compiled with it (at leas the one you can get from the repositories above). To deactivate the stack protection, add -fno-stack-protector the KBUILD_CFLAGS in the Makefile. It should look like this:

KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
     -fno-strict-aliasing -fno-common \
     -Werror-implicit-function-declaration \
     -Wno-format-security \
     -fno-delete-null-pointer-checks \
     -fno-stack-protector \

(Note that this is a normal compilation error. Adding -fno-stack-protector to CFLAGS tend to solve it)

Now you can compile the Linux kernel in the Zynq.

$ make ARCH=arm xilinx_zynq_base_trd_nosmp_defconfig
$ make -j2 ARCH=arm uImage modules UIMAGE_LOADADDR=0x8000

Wait about 60 minutes, and you have it!

     real   51m44.866s
     user   75m20.180s
     sys    4m16.700s

Enjoy! 🙂

Update: I have modified Xilinx’s wiki, so the content is now the same in both pages.


One thought on “Running Ubuntu on Zynq-7000

  1. Pingback: 在Zedboard上安裝Ubuntu – Boris's Blog

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s