Running Ubuntu on Zynq-7000

[复制链接]
818|2
手机看帖
扫描二维码
随时随地手机跟帖
zhangmangui|  楼主 | 2019-5-30 10:18 | 显示全部楼层 |阅读模式
[backcolor=rgba(255, 255, 255, 0.95)]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.
[backcolor=rgba(255, 255, 255, 0.95)]
[backcolor=rgba(255, 255, 255, 0.95)]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:

    • 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).
    • Download the binaries for the boot partition and the root file system. (the links are taken from http://www.wiki.xilinx.com/Ubuntu+on+Zynq in case you don’t trust mine – I won’t take it personal, I would not trust random links either :))
    • Extract the boot images and copy the necessary files to the SD card:[backcolor=white !important][size=1em]
      [size=1em]1

      [size=1em]2

      [size=1em]3

      [size=1em]4

      [size=1em][size=1em]$ tar xvJf zynq-ubuntu-core-12.10-core-armhf-boot.tar.xz
      [size=1em]$ mount /dev/sdX1 /mnt/boot
      [size=1em]$ cp boot/uImage boot/uramdisk.image.gz boot/zc702/boot.bin boot/zc702/devicetree.dtb /mnt/boot
      [size=1em]$ umount /dev/sdX1



      [backcolor=white !important][size=1em]
      [size=1em]1

      [size=1em]2

      [size=1em]3

      [size=1em]4

      [size=1em][size=1em]$ tar xvJf zynq-ubuntu-core-12.10-core-armhf-rootfs.tar.xz
      [size=1em]$ mount /dev/sdX2 /mnt/root
      [size=1em]$ cp roots/* /mnt/root
      [size=1em]$ umount /dev/sdX2




    • Log in. root: root, pass:root
    • Enable dhcp[backcolor=white !important][size=1em]
      [size=1em]1

      [size=1em][size=1em]$ dhclient eth0



      • In order to wake the interface up automatically on reboot, add the following lines to /etc/network/interfaces[backcolor=white !important][size=1em]
        [size=1em]1

        [size=1em]2

        [size=1em][size=1em]$ auto eth0
        [size=1em]$ iface eth0 inet dhcp




    • Update the Ubuntu repositories (source.list) with the following repositories:
      >>  deb http://ports.ubuntu.com/ubuntu-ports saucy main universe restricted
      >>  deb http://ports.ubuntu.com/ubuntu-ports saucy-security universe
      >>  deb http://ports.ubuntu.com/ubuntu-ports saucy-updates universe
      >>  deb http://packages.namniart.com/repos/ros quantal main
      >>  deb http://archive.ubuntu.com/ubuntu quantal main restricted
      [backcolor=white !important][size=1em]
      [size=1em]1

      [size=1em]2

      [size=1em]3

      [size=1em]4

      [size=1em][size=1em]$ vi /etc/apt/sources.list
      [size=1em][add repositories]
      [size=1em]$ apt-get upgrade
      [size=1em]$ apt-get update



    • Install a compilation environment[backcolor=white !important][size=1em]
      [size=1em]1

      [size=1em]2

      [size=1em]3

      [size=1em][size=1em]$ apt-get install build-essential
      [size=1em]$ apt-get install libssl-dev
      [size=1em]$ apt-get install u-boot-tools




[backcolor=rgba(255, 255, 255, 0.95)]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.
[backcolor=rgba(255, 255, 255, 0.95)]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).
[backcolor=rgba(255, 255, 255, 0.95)][backcolor=white !important][size=1em]
[size=1em]1

[size=1em]2

[size=1em]3

[size=1em][size=1em]$ apt-get install git
[size=1em]$ git clone git://github.com/Xilinx/linux-xlnx.git
[size=1em]$ git checkout -b zynq_base_trd_14_5 xilinx-14.5-build-trd



[backcolor=rgba(255, 255, 255, 0.95)]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'
[backcolor=rgba(255, 255, 255, 0.95)]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 \
[backcolor=rgba(255, 255, 255, 0.95)](Note that this is a normal compilation error. Adding -fno-stack-protector to CFLAGS tend to solve it)
[backcolor=rgba(255, 255, 255, 0.95)]Now you can compile the Linux kernel in the Zynq.
[backcolor=rgba(255, 255, 255, 0.95)][backcolor=white !important][size=1em]
[size=1em]1

[size=1em]2

[size=1em][size=1em]$ make ARCH=arm xilinx_zynq_base_trd_nosmp_defconfig
[size=1em]$ make -j2 ARCH=arm uImage modules UIMAGE_LOADADDR=0x8000



[backcolor=rgba(255, 255, 255, 0.95)]Wait about 60 minutes, and you have it!
     real   51m44.866s     user   75m20.180s     sys    4m16.700s

使用特权

评论回复

相关帖子

aks88796h| | 2020-2-22 19:44 | 显示全部楼层
哎``没见过!!!!!!

使用特权

评论回复
发新帖
您需要登录后才可以回帖 登录 | 注册

本版积分规则

个人签名:欢迎进入【TI DSP 论坛】 & 【DSP 技术】           TI忠诚粉丝!

934

主题

26374

帖子

585

粉丝