ZYNQ学习之路12.PetaLinux开发环境搭建

简介

PetaLinux是一个嵌入式Linux系统开发工具,用于设计Xilinx基于FPGA的SOC片上系统。本节为第一节,旨在介绍如何使用PetaLinux工具。

软件环境: windows 10 64bit,VMware 12, ubuntu 16, Vivado2018.2

硬件环境: 米尔科技Zturn board

安装vmware后在其中安装ubuntu。

一、安装PetaLinux开发环境

安装PetaLinux要求:

  • 在非root权限下安装
  • PetaLinux依赖很多标准开发工具和库,需要先安装下表中的依赖。

表1-1 Packages and Linux workstation Environments

Tool / Library

CentOS 7.2/7.3

RHEL7.2/7.3

Ubuntu 16.04.1

python

python: 3.4.0

python: 3.4.0

python: 3.4.0

dos2unix

dos2unix-6.0.3-4.el7.x86_64.rpm

dos2unix-6.0.3-4.el7.x86_64.rpm

tofrodos_1.7.13+ds-2.debia

n.tar.xz

ip

iproute-3.10.0-74.el7.x86_64.rpm

iproute-3.10.0-74.el7.x86_64.rpm

iproute2 4.3.0-1ubuntu3

gawk

gawk-4.0.2-4.el7.x86_64.rpm

gawk-4.0.2-4.el7.x86_64.rpm

gawk (1:4.1.3+dfsg-0.1)

xvfb

xorg-x11-server-Xvfb-1.15.0-7.el7.x86_64.rpm

xorg-x11-server-Xvfb-1.15.0-7.el7.x86_64.rpm

xvfb (2:1.18.3-1ubuntu2.3)

git

git 1.8.3

git 1.8.3

git 1.7.1 or above

make

make 3.81

make 3.82

make 3.81

netstat

net-tools2.0

net-tools2.0

net-tools

ncursesdevel

ncurses-devel5.9-13

ncurses-devel5.9-13

libncurses5-dev

tftp server

tftp-server

tftp-server

tftpd

zlib devel

(also, install

32-bit of this

version)

zlib-devel-1.2.7-17.el7.x86_64.rpm

zlib-devel-1.2.7-17.el7.x86_64.rpm

i386/zlib1g-dev/1:1.2.8.dfsg

-2ubuntu4-dev

openssl devel

openssl-devel 1.0

openssl-devel 1.0

libssl-dev

flex

flex 2.5.37

flex 2.5.37

flex

bison

bison-2.7

bison-2.7.4

bison

libselinux

libselinux2.2.2

libselinux2.2.2

libselinux1

gnupg

gnupg

gnupg

gnupg

wget

wget

wget

wget

diffstat

diffstat

diffstat

diffstat

chrpath

chrpath

chrpath

chrpath

socat

socat

socat

socat

xterm

xterm

xterm

xterm

autoconf

autoconf

autoconf

autoconf

libtool

libtool

libtool

libtool

tar

tar:1.24

tar:1.24

tar:1.24

unzip

unzip

unzip

unzip

texinfo

texinfo

texinfo

texinfo

zlib1g-dev

-

-

zlib1g-dev

gcc-multilib

-

-

gcc-multilib

build-essential

-

-

build-essential

libsdl1.2-dev

-

-

libsdl1.2-dev

libglib2.0-dev

-

-

libglib2.0-dev

SDL-devel

SDL-devel

SDL-devel

-

glibc-devel

glibc-devel

glibc-devel

-

32-bit glibc

glibc.i686

glibc.i686

-

glib2-devel

glib2-devel

glib2-devel

-

automake

automake

automake

-

screen

screen

screen

screen

pax

pax

pax

pax

gzip

gzip

gzip

gzip

devtoolset-2

-

-

-

安装步骤如下。

1.1 安装Petalinux依赖库

首先更新源:sudo apt-get update,然后更具官方手册安装依赖库:

$ sudo apt-get install tofrodos iproute2 gawk xvfb gcc git make net-tools libncurses5-dev tftpd zlib1g-dev libssl-dev flex bison libselinux1 gnupg wget diffstat chrpath socat xterm autoconf libtool tar unzip texinfo gcc-multilib build-essential libsdl1.2-dev libglib2.0-dev libssl-dev screen pax gzip

Note:上述命令带有回车,在直接复制时需要去除回车符!

安装完成后更新:

$ sudo apt-get upgrade

1.2 安装petalinux

从官网下载好petalinux,笔者下载的2018.2版本。

$ mkdir -p /home/software/petalinux
$ cd /home/software/petalinux

将petalinux-v2018.2-final-installer.run拖拽到petalinux文件夹下。

$ mkdir -p /opt/pkg/petalinux 
$ sudo chmod 755 /opt/pkg/petalinux 
$ ./petalinux-v2018.2-final-installer.run /opt/pkg/petalinux

Note:不使用root权限进行安装,/opt/pkg/petalinux的权限应该是755,当然安装目录也可以是其他任何目录,但权限必须是755.

安装过程输出信息如下:

$./petalinux-v2018.2-final-installer.run /opt/pkg/petalinux
INFO: Checking installer checksum...
INFO: Extracting PetaLinux installer...

LICENSE AGREEMENTS

PetaLinux SDK contains software from a number of sources.  Please review
the following licenses and indicate your acceptance of each to continue.

You do not have to accept the licenses, however if you do not then you may 
not use PetaLinux SDK.

Use PgUp/PgDn to navigate the license viewer, and press 'q' to close

Press Enter to display the license agreements
Do you accept Xilinx End User License Agreement? [y/N] > y
Do you accept Webtalk Terms and Conditions? [y/N] > y
Do you accept Third Party End User License Agreement? [y/N] > y
INFO: Checking installation environment requirements...
INFO: Checking free disk space
INFO: Checking installed tools
INFO: Checking installed development libraries
INFO: Checking network and other services
INFO: Installing PetaLinux...
INFO: Checking PetaLinux installer integrity...
INFO: Installing PetaLinux SDK to "/opt/pkg/petalinux/."
................................................................................................................................................................................................................................................................................INFO: Installing aarch64 Yocto SDK to "/opt/pkg/petalinux/./components/yocto/source/aarch64"...
PetaLinux Extensible SDK installer version 2018.2
=================================================
You are about to install the SDK to "/opt/pkg/petalinux/components/yocto/source/aarch64". Proceed[Y/n]? Y
Extracting SDK................................done
Setting it up...
Extracting buildtools...
done
SDK has been successfully set up and is ready to be used.
Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g.
 $ . /opt/pkg/petalinux/components/yocto/source/aarch64/environment-setup-aarch64-xilinx-linux
INFO: Installing arm Yocto SDK to "/opt/pkg/petalinux/./components/yocto/source/arm"...
PetaLinux Extensible SDK installer version 2018.2
=================================================
You are about to install the SDK to "/opt/pkg/petalinux/components/yocto/source/arm". Proceed[Y/n]? Y
Extracting SDK..............................done
Setting it up...
Extracting buildtools...
done
SDK has been successfully set up and is ready to be used.
Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g.
 $ . /opt/pkg/petalinux/components/yocto/source/arm/environment-setup-cortexa9hf-neon-xilinx-linux-gnueabi
INFO: Installing microblaze_full Yocto SDK to "/opt/pkg/petalinux/./components/yocto/source/microblaze_full"...
PetaLinux Extensible SDK installer version 2018.2
=================================================
You are about to install the SDK to "/opt/pkg/petalinux/components/yocto/source/microblaze_full". Proceed[Y/n]? Y
Extracting SDK.............................done
Setting it up...
Extracting buildtools...
done
SDK has been successfully set up and is ready to be used.
Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g.
 $ . /opt/pkg/petalinux/components/yocto/source/microblaze_full/environment-setup-microblazeel-v10.0-bs-cmp-re-mh-div-xilinx-linux
INFO: Installing microblaze_lite Yocto SDK to "/opt/pkg/petalinux/./components/yocto/source/microblaze_lite"...
PetaLinux Extensible SDK installer version 2018.2
=================================================
You are about to install the SDK to "/opt/pkg/petalinux/components/yocto/source/microblaze_lite". Proceed[Y/n]? Y
Extracting SDK.............................done
Setting it up...
Extracting buildtools...
done
SDK has been successfully set up and is ready to be used.
Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g.
 $ . /opt/pkg/petalinux/components/yocto/source/microblaze_lite/environment-setup-microblazeel-v10.0-bs-cmp-re-ml-xilinx-linux
INFO: PetaLinux SDK has been installed to /opt/pkg/petalinux/.

 Important:PetaLinux要求系统"/bin/sh"是bash,但ubuntu默认的是dash,需要将系统的脚本命令配置为bash  

设置petalinux:

$ source /opt/pkg/petalinux/settings.sh

输出消息如下:

PetaLinux environment set to '/opt/pkg/petalinux'
INFO: Checking free disk space
INFO: Checking installed tools
INFO: Checking installed development libraries
INFO: Checking network and other services

检查是否配置好:

echo $PETALINUX

 输出如下:

/opt/pkg/petalinux

 为了开机自动添加petalinux的环境配置,将设置环境的命令添加到ubuntu自启动脚本中。用root权限打开~/.bashrc文件,在文件最后添加设置命令:

source /opt/pkg/petalinux/settings.sh

 1.3 安装PetaLinux BSP

Xilinx提供了用于用户创建自己的工程的参考工程样例,这些工程提供了BSP文件,包括所有必须的设计文件和配置文件,构建和测试硬件软件镜像,可以直接在QEMU仿真系统中启动。

首先从官网下载Petalinux BSP工程。下载ZED board的BSP

使用petalinux-create命令创建工程:

$ petalinux-create -t project -s <path-to-bsp>

 输出如下消息:

INFO: Create project: 
INFO: Projects: 
INFO: 	* avnet-digilent-zedboard-2018.2
INFO: has been successfully installed to /home/xxx/workspace/petalinux/
INFO: New project successfully created in /home/xxx/workspace/petalinux/

 1.4 编译并测试参考例程

在1.3生成的文件夹目录下进行系列操作:

编译:

$ petalinux-build

生成设备树文件,fsbl, uboot文件,linux内核和文件系统镜像,最后打包成一个启动镜像文件。

编译完成后生成的文件在目录<project-path>/images中。

PetaLinux提供了QEMU的支持,在软件环境下模拟硬件测试PetaLinux软件镜像。

在工程目录下启动linux内核镜像:

$ petalinux-boot --qemu --prebuilt 3

 --qemu告诉petalinux-tool启动QEMU,--prebuilt 3启动linux内核。

  • --prebuilt 1用于1级(FPGA比特流)启动,在QEMU中无效
  • --prebuilt 2启动U-boot
  • --prebuilt 3启动Linux镜像

 

图1-1 QEMU启动zed

 

Tip:退出QEMU:同时按住Ctrl+A,松开后按X

启动Linux内核也可以用以下命令:

$ petalinux-boot --qemu --kernel

参考资料

[1] ug1144-petalinux-tools-reference-guide.pdf

[2] ug1156-petalinux-tools-workflow-tutorial.pdf

  • 0
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值