Petalinux简单使用[转载]

转载:https://www.cnblogs.com/likaiwei/p/10223354.html

 

Description/说明

PetaLinux版本:2016.4

操作系统版本:Ubuntu 16.04(如使用Ubuntu,墙裂建议使用16.04,其他版本官方手册并没有标明支持,可能会出现莫名其妙的问题)

参考文件来源:UG1144

Introduction/介绍

PetaLinux is an Embedded Linux System Development Kit specifically targeting FPGA-based System-on-Chip designs. This guide helps the reader to familiarize with the tool enabling overall usage of PetaLinux.

PetaLinux是专门针对基于FPGA进行嵌入式Linux系统设计的开发套件。本指南帮助读者熟悉该工具的整体使用。

Installation/安装

Installation Requirements/安装需求

PetaLinux requires a number of standard development tools and libraries to be installed on your Linux host workstation.

PetaLinux需要"/bin/sh" is bash,如果使用Ubuntu系统,需要进行切换。

PetaLinux需要在Linux主机工作站上安装许多标准的开发工具和库。比如python dos2unix ip gawk xvfb-run gcc git make...等,详见资料UG1144,只有按照要求安装好这些开发工具和库后,后面安装才不会出现问题,这里给出安装命令。

$ sudo dpkg-reconfigure bash

$ sudo apt install chrpath socat autoconf libtool git texinfo gcc-multilib libsdl1.2-dev libglib2.0-dev xvfb libssl-dev libncurses5-dev zlib1g:i386 diffstat build-essential

Installation Steps/安装步骤

You can download PetaLinux installer from PetaLinux Downloads.

第一步下载PetaLinux 2016.4(根据你的Vivado版本进行下载,此处以2016.4为例)安装包,到官网登录你的Xilinx账号进行下载,下载文件大小8G以上。

  1. 将下载好的文件petalinux-v2016.4-final-installer.run放到Linux系统的工作目录里面
  2. 给文件增加可执行权限:$ chmod 777 petalinux-v2016.4-final-installer.run
  3. 打开文件进行安装:$ ./petalinux-v2016.4-final-installer.run /home/user/Xilinx/petalinux

这里将petalinx安装到了目录:/home/user/Xilinx/petalinux里面,安装过程中需要先按回车键,然后按键盘q,按y进行协议许可确认;然后按键盘q,按y进行协议许可确认;然后按键盘q,按y进行协议许可确认;(不能有误,否则退出安装,共3遍)。

Environment Setup/环境配置

$ source /home/user/Xilinx/petalinux/settings.sh

$ echo $PETALINUX

进行环境配置需要运行上面的命令,之后运行下面一句命令,如果打印出你的petalinux安装目录出来,表示安装成功。(在系统重启后需要重新运行第一条命令进行环境配置)

如果在上面步骤中有任何报错,请检查Installation Requirements/安装需求里面的开发工具和库是否已经安装,只有在输入命令后打印出下面所示的文字时才不缺少开发工具和库,否则请根据所使用的操作系统安装(不要根据打印出的缺少的名称安装,找到UG1144表格中的名称安装)。

PetaLinux environment set to ' /home/user/Xilinx/petalinux '

INFO: Checking free disk space

INFO: Checking installed tools

INFO: Checking installed development libraries

INFO: Checking network and other services

WARNING: No tftp server found - please refer to "PetaLinux SDK Installation Guide"

for its impact and solution

Use/使用

创建一个工程 

$ petalinux-create -t project --template zynq --name test

导入硬件配置文件

将Vivado工程产生的.hdf文件(需要的文件只有这一个,产生bit、BOOT.BIN、内核、设备树、文件系统等文件)复制到工程目录中(这里以~/Desktop/test文件夹为例):

$ petalinux-config --get-hw-description=/home/user/Desktop/test

弹出配置界面:

 

将选项:Subsystem AUTO Hardware Settings -> Advanced bootable images storage Settings -> boot image settings 中 ‘image storage media’ 更改为 ‘primary sd’;

将选项:Subsystem AUTO Hardware Settings -> Advanced bootable images storage Settings -> kernel image settings 中 ‘image storage media’ 更改为 ‘primary sd’;

将选项:Subsystem AUTO Hardware Settings -> Advanced bootable images storage Settings -> dtb image settings 中 ‘image storage media’ 更改为 ‘primary sd’

将选项:Image Packaging Configurations 中 ‘Root filesystem type’ 更改为 ‘SD card’

配置u-boot

$ petalinux-config -c u-boot


配置内核

$ petalinux-config -c kernel

 

配置文件系统

$ petalinux-config -c rootfs

编译

$ petalinux-build

该步骤需要的时间较长(根据PC性能有所不同),需要耐心等待。。。

 

最后打印:[INFO] successfully built project,表示成功完成。

查看目录中,多了image/linux文件夹:

image.ub rootfs.cpio rootfs.tar.gz System.map.linux u-boot.elf zImage
test_wrapper.bit rootfs.cpio.gz system.dtb u-boot.bin vmlinux zynq_fsbl.elf

里面并没有BOOT.BIN,我们需要手工生成。

 

生成BOOT.BIN

首先进入./image/linux文件夹,通过下面的命令生成BOOT.BIN:

$ petalinux-package --boot --format BIN --fsbl ./images/linux/zynq_fsbl.elf --fpga ./images/linux/test_wrapper.bit --u-boot

该命令将zynq_fsbl.elf、test_wrapper.bit、u-boot.elf三个文件合成一个BOOT.BIN,方法类似于在SDK中生成BOOT.BIN。

 

至此,我们有了以下文件:

BOOT.BIN:包含 FSBL BIT U-BOOT三合一;

image.ub:内核文件;

system.dtb:设备树文件;

将以上3个文件复制到SD卡的BOOT分区;

 

文件系统 

虽然image/linux文件夹中生成了文件系统,但是我们需要更多功能的文件系统,比如Ubuntu或Linaro:

http://cdimage.ubuntu.com/ubuntu-base/releases/16.04/release/

将文件系统烧写到SD卡的rootfs分区;

 

启动

设置你手中的板卡从SD卡启动,连接串口即可看到使用petalinux生成的Linux系统启动过程。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值