参考文档:ug1144-petalinux-tools-reference-guide.pdf

环境安装

tofrodos iproute2 gawk gcc g++ git make net-tools libncurses5-dev tftpd zlib1g:i386 libssl-dev flex bison libselinux1 gnupg wget diffstat chrpath socat xterm autoconf libtool tar unzip texinfo zlib1g-dev gcc-multilib build-essential libsdl1.2-dev libglib2.0-dev screen pax gzip automake glib2-devel openssl openssl-devel xinetd tftp tftp-server redhat-lsb u-boot-tools(或 uboot-tools)

创建目录:

su root
mkdir /opt/env
chown -R huangshuchao:embd /opt/env/
#chown -R huangshuchao:embd /opt/env/ # 2016.4以后的petalinux不能以超级权限去安装,必须在$下安装petalinux。

安装

./petalinux-v2018.3-final-installer.run /opt/env/petalinux/2018.3

Ubuntu bash

dpkg-reconfigure dash
--> NO

使用

每次都需要:

 source /opt/env/petalinux/2018.3/settings.sh

本文链接https://www.cnblogs.com/schips/p/using-petalinux-build-linux-env.html

导入硬件

拷贝design_1_wrapper_hw_platform_0到Linux

创建项目

petalinux-create --type project --template zynq --name 项目名称(目录)

INFO: Create project: ax_peta
INFO: New project successfully created in /home/huangshuchao/ax_peta

导入硬件信息

输入以下命令:

硬件信息包:design_1_wrapper_hw_platform_0_test.tgz(来自13_vdma_to_qspi_sd

petalinux-config --get-hw-description ~/hw-vivado/design_1_wrapper_hw_platform_0_test

配置优化

我们这里再做一些优化工作,以方便我们的使用:

离线编译

注意,修改镜像时,填入的路径是以file://开头的。

-> Yocto Settings
## 设置缓存:SState cache
-> Local sstate feeds settings
-> local sstate feeds url ## 按 Enter
/home/xx/sstage_package_for_petalinux/arm -> Yocto Settings
## 设置镜像:download mirror
-> Add pre-mirror url ## 按 Enter
file:///home/xx/sstage_package_for_petalinux/downloads -> Yocto Settings
## 设置离线编译
[ ] Enable Network sstate feeds ## 按 N
[*] Enable BB NO NETWORK ## 按 Y

启动Linux时自动登录

避免输入账号密码。

-> Yocto Settings
[*] Enable Debug Tweaks ## 按 Y

不自动获取IP地址

如果网口存在时,可以考虑关闭自动获取IP地址(会造成开机过慢)

-> Subsystem AUTO Hardware Settings (SUBSYSTEM_HARDWARE_AUTO [=y])
-> Ethernet Settings
Primary Ethernet ((ps7_ethernet_0) # 确认 存在此项
[ ] Obtain IP address automatically # 按下空格键取消,并设置一个IP
(192.168.168.168) Static IP address
(255.255.255.0) Static IP netmask (NEW)
(192.168.168.1) Static IP gateway u-boot Configuration --->
(192.168.168.1) TFTP Server IP addres # 设置TFTP服务器地址

修改文件系统类型(可选)

默认的文件系统类型会导致文件系统无法保存,一开始的时候可以保持默认,可以在后续修改为以下配置:

-> Image Packaging Configuration
-> Root filesystem type
-> Root filesystem type (SD card) --->
(/dev/mmcblk0p2) Device node of SD device (NEW)

保存退出,以下是提示信息:

INFO: Getting hardware description...
[INFO] generating Kconfig for project
[INFO] menuconfig project *** End of the configuration.
*** Execute 'make' to start the build or try 'make help'. [INFO] sourcing bitbake
[INFO] generating plnxtool conf
[INFO] generating meta-plnx-generated layer
[INFO] generating machine configuration
[INFO] generating bbappends for project . This may take time !
[INFO] generating u-boot configuration files
[INFO] generating kernel configuration files
[INFO] generating kconfig for Rootfs
[INFO] oldconfig rootfs
[INFO] generating petalinux-user-image.bb

配置保护

保留Linux和UBoot源代码

echo 'RM_WORK_EXCLUDE += "linux-xlnx"'>> project-spec/meta-user/conf/petalinuxbsp.conf

echo 'RM_WORK_EXCLUDE += "u-boot-xlnx"'>> project-spec/meta-user/conf/petalinuxbsp.conf

echo ''>> project-spec/meta-user/conf/petalinuxbsp.conf

原理:run.do_rm_work中有对关键字进行解析,如果符合条件,那么不执行删除操作。

配置uboot

petalinux-config -c u-boot

进行如下配置:

配置项 值与说明
Boot media Boot介质,配置从SD卡启动
delay in seconds before automatically booting Boot自启动时间,默认4s,可修改
Disable support for parallel NOR flash NOR flash支持,无支持
add U-Boot environment variable vers U-Boot环境变量添加,无
Display information about the CPU during start up 启动阶段显示CPU信息,可选
Display information about the board during start up 启动阶段显示板卡信息,可选
Command line interface 命令行配置,用户可进一步配置
Device Tree Control 设备树控制,保持默认配置(embeded)

配置内核

输入:

petalinux-config -c kernel

以下是提示信息:

[INFO] generating Kconfig for project
[INFO] sourcing bitbake
[INFO] generating plnxtool conf
[INFO] generating meta-plnx-generated layer
[INFO] generating machine configuration
[INFO] configuring: kernel
[INFO] generating kernel configuration files
[INFO] bitbake virtual/kernel -c menuconfig
Parsing recipes: 100% |##########################################| ETA: 0:00:56 Parsing of 2569 .bb files complete (0 cached, 2569 parsed). 3445 targets, 149 skipped, 0 masked, 0 errors.
NOTE: Resolving any missing task queue dependencies

很快就会弹出Menuconfig菜单,选择

CONFIG_MICREL_PHY:

-> Device Drivers
-> Network device support (NETDEVICES [=y])
-> PHY Device support and infrastructure (PHYLIB [=y])
[y] Micrel PHYs

保存,EXIT。

配置文件系统

petalinux-config -c rootfs

petalinux-config -c rootfs && petalinux-build

无更改,保存退出

编译 uboot、内核、文件系统、设备树

petalinux-build

此后,生成下面的文件

# ls image/linux
rootfs.cpio rootfs.cpio.gz.u-boot rootfs.ext4 rootfs.jffs2 rootfs.tar.gz system.dtb u-boot.elf zynq_fsbl.elf image.ub rootfs.cpio.bz2 rootfs.ext3 rootfs.ext4.gz rootfs.manifest rootfs.testdata.json System.map.linux vmlinux rootfs.bin rootfs.cpio.gz rootfs.ext3.bz2 rootfs.its rootfs.tar.bz2 system.bit u-boot.bin zImage

生成BOOT.BIN

执行下面的代码生成BOOT.BIN

petalinux-package --boot --fsbl ./images/linux/zynq_fsbl.elf --fpga ./images/linux/system.bit --u-boot --force

下面的是提示信息:

INFO: Getting system flash information...
INFO: File in BOOT BIN: "/home/huangshuchao/ax_peta2/images/linux/zynq_fsbl.elf"
INFO: File in BOOT BIN: "/home/huangshuchao/ax_peta2/images/linux/system.bit"
INFO: File in BOOT BIN: "/home/huangshuchao/ax_peta2/images/linux/u-boot.elf"
INFO: Generating Zynq binary package BOOT.BIN... ****** Xilinx Bootgen v2018.3
**** Build date : Nov 15 2018-19:22:29
** Copyright 1986-2018 Xilinx, Inc. All Rights Reserved. INFO: Binary is ready.

生成image.ub

mkimage -f ./images/linux/rootfs.its image.ub

测试

image/linux中拷贝:BOOT.BINimage.ub,到SD卡即可。

创建项目的脚本

##
# Copyright By Schips, All Rights Reserved
# https://gitee.com/schips/
#
# File Name: copy_petalinux_project_with_hw.sh
# Created : 2020-07-25 11:28:24
#
##
#!/bin/sh
# 项目工程常见参数设置
## sstage包下载后设置
SSTATE_LOCAL_PATH="/home/huangshuchao/sstage_package_for_petalinux/"
## IP地址设置
NET=192.168.1
IPADDR=$NET.100 help () {
echo "Error : need \$projectname \$hw_bsp"
echo " eg :"
echo " $0 ax_project ~/hw-vivado-bsp-for-petalinux/some_packakge"
exit 1
} if [ -z "$1" ]; then
help
fi
if [ -z "$2" ]; then
help
fi command -v petalinux-create >/dev/null 2>&1 || { echo >&2 "Aborted : Require \"petalinux-create\" but not found."; exit 1; }
command -v petalinux-config >/dev/null 2>&1 || { echo >&2 "Aborted : Require \"petalinux-config\" but not found."; exit 1; } ## 删除源目录
rm $1 -rf ## 创建项目
petalinux-create --type project --template zynq --name $1
PROJECT=$1
## 导入硬件信息
cd $PROJECT
petalinux-config --get-hw-description $2 ## 使PetaLinux不删除源码
echo 'RM_WORK_EXCLUDE += "linux-xlnx"'>> project-spec/meta-user/conf/petalinuxbsp.conf
echo 'RM_WORK_EXCLUDE += "u-boot-xlnx"'>> project-spec/meta-user/conf/petalinuxbsp.conf
echo ''>> project-spec/meta-user/conf/petalinuxbsp.conf # 删除带有指定关键字的行
delete_line_with_special_word ()
{
if [[ $# -lt 2 ]]; then
return
fi
FILE=$1
WORD=$2
sed -i "/${WORD}/d" ${FILE}
} # 文件内容追加
append_line_into_file ()
{
if [[ $# -lt 2 ]]; then
return
fi
FILE=$1
LINE=$2
echo $LINE >> $FILE
}
CONFIG=project-spec/configs/config
cp $CONFIG $CONFIG.old ## 网络设置
delete_line_with_special_word $CONFIG CONFIG_SUBSYSTEM_ETHERNET_PS7_ETHERNET_0_USE_DHCP
append_line_into_file $CONFIG "# CONFIG_SUBSYSTEM_ETHERNET_PS7_ETHERNET_0_USE_DHCP is not set"
append_line_into_file $CONFIG "CONFIG_SUBSYSTEM_ETHERNET_PS7_ETHERNET_0_IP_ADDRESS=\"$IPADDR\""
append_line_into_file $CONFIG "CONFIG_SUBSYSTEM_ETHERNET_PS7_ETHERNET_0_IP_NETMASK=\"255.255.255.0\""
append_line_into_file $CONFIG "CONFIG_SUBSYSTEM_ETHERNET_PS7_ETHERNET_0_IP_GATEWAY=\"$NET.1\"" ## 本地包
delete_line_with_special_word $CONFIG CONFIG_YOCTO_NETWORK_SSTATE_FEEDS
append_line_into_file $CONFIG "# CONFIG_YOCTO_NETWORK_SSTATE_FEEDS is not set"
delete_line_with_special_word $CONFIG CONFIG_YOCTO_BB_NO_NETWORK
append_line_into_file $CONFIG "CONFIG_YOCTO_BB_NO_NETWORK=y"
delete_line_with_special_word $CONFIG CONFIG_PRE_MIRROR_URL
append_line_into_file $CONFIG "CONFIG_PRE_MIRROR_URL=\"file://${SSTATE_LOCAL_PATH}/downloads\""
delete_line_with_special_word $CONFIG CONFIG_YOCTO_LOCAL_SSTATE_FEEDS_URL
append_line_into_file $CONFIG "CONFIG_YOCTO_LOCAL_SSTATE_FEEDS_URL=\"${SSTATE_LOCAL_PATH}/arm\"" #zynq
## | 目录 | 平台 |
## | --------- | ----------- |
## | aarch64 | ZynqMP |
## | arm | Zynq |
## | mb-full | MB AXI |
## | mb-lite | MB AXI lite |
## | downloads | 全平台 | ## 免输入密码登陆
delete_line_with_special_word $CONFIG CONFIG_YOCTO_ENABLE_DEBUG_TWEAKS
append_line_into_file $CONFIG "CONFIG_YOCTO_ENABLE_DEBUG_TWEAKS=y"

附录:PetaLinux注意事项

导入项目创建项目以后,工程项目会确定当前路径,所以需要注意,不要随便改动工程路径。

ERROR:  OE-core's config sanity checker detected a potential misconfiguration.
Either fix the cause of this error or at your own risk disable the checker (see sanity.conf).
Following is the list of potential problems / advisories: Error, TMPDIR has changed location. You need to either move it back to /home/huangshuchao/ax_1_design1hw0_retry/build/tmp or rebuild

不过可以通过拷贝petalinux工程的配置到另外的目录,再build出那些临时文件。

详情见:加速 PetaLinux 工程编译、复制 PetaLinux 工程

附录: 构建各部分

petalinux-build -c kernel

petalinux-build -c device-tree

petalinux-build -c fsbl

petalinux-build -c u-boot

petalinux-package --boot --fsbl --fpga --u-boot --force

这样在images目录下就会生成我们需要的uImage、system.dtb以及BOOT.BIN,为了确保设备树修改完好,我们这里先反编译一下设备树,生成system.dts,查看里面是否我们要修改的东西都已经修改好了(需要device-tree-compiler)。

在system.dtb文件的目录下运行

dtc -I dtb -O dts -o system.dts system.dtb

打开ststem.dts,我们可以看到已经修改完毕

ZYNQ:使用 PetaLinux 构建Linux项目的更多相关文章

  1. Jenkins:基于linux构建ivy项目

    Jenkins:基于linux构建ivy项目 (二) 基于以上<Jenkins:VMware虚拟机Linux系统的详细安装和使用教程(一)>的配置再进行对ivy项目构建: 启动tomcat ...

  2. linux服务器中Jenkins集成git、Gradle持续构建Springboot项目

    Jenkins是用java编写的开源持续集成工具,目前被国内外各公司广泛使用.本章教大家如何在linux服务器中使用Jenkins自动发布一个可作为linux服务发布的Springboot项目. 自动 ...

  3. Linux下Jenkins与GitHub自动构建Node项目(Vue)

    根据上篇文章<Linux下Jenkins与GitHub自动构建NetCore与部署>,我们知道了Jenkins的强大功能,自动构建,部署了一个NetCore的Web,让开发人员专注于开发, ...

  4. 转】用Maven构建Mahout项目

    原博文出自于: http://blog.fens.me/hadoop-mahout-maven-eclipse/ 感谢! 用Maven构建Mahout项目 Hadoop家族系列文章,主要介绍Hadoo ...

  5. 转】用Maven构建Hadoop项目

    原博文出自于: http://blog.fens.me/hadoop-maven-eclipse/ 感谢!   用Maven构建Hadoop项目 Hadoop家族系列文章,主要介绍Hadoop家族产品 ...

  6. 运行预构建 Linux 映像的 Windows Azure 虚拟机中的交换空间 – 第 1 部分

    本文章由 Azure CAT 团队的 Piyush Ranjan (MSFT) 撰写. 随着基础结构服务(虚拟机和虚拟网络)近期在 Windows Azure 上正式发布,越来越多的企业工作负荷正在向 ...

  7. 使用 Gradle 构建 Java 项目

    使用 Gradle 构建 Java 项目 这个手册将通过一个简单的 Java 项目向大家介绍如何使用 Gradle 构建 Java 项目. 我们将要做什么? 我们将在这篇文档航中创建一个简单的 Jav ...

  8. Jenkins自动构建gitlab项目(jenkins+maven+giltlab+tomcat)

    环境准备: System:CentOS 7.3 (最小化安装) JDK: 8u161 (1.8_161) tomcat: 8.5.29 Jenkins: Jenkins 2.107.1 Gitlab: ...

  9. Eclipse 中构建 Maven 项目的完整过程 - SpringBoot 项目

    进行以下步骤的前提是你已经安装好本地maven库和eclipse中的maven插件了(有的eclipse中已经集成了maven插件) 一.Maven项目的新建 1.鼠标右键---->New--- ...

  10. vue-cli快速构建vue项目模板

    vue-cli 是vue.js的脚手架,用于自动生成vue.js模板工程的. 1.使用npm安装vue-cli 需要先装好vue 和 webpack(前提是已经安装了nodejs,否则连npm都用不了 ...

随机推荐

  1. Rust中的并发性:Sync 和 Send Traits

    在并发的世界中,最常见的并发安全问题就是数据竞争,也就是两个线程同时对一个变量进行读写操作.但当你在 Safe Rust 中写出有数据竞争的代码时,编译器会直接拒绝编译.那么它是靠什么魔法做到的呢? ...

  2. Mybatis学习五($和#区别以及其他tips)

    1.$和#区别 1 #是将传入的值当做字符串的形式,eg:select id,name,age from student where id =#{id},当前端把id值1,传入到后台的时候,就相当于 ...

  3. SpringBoot 利用Timer 在指定时间2小时后执行任务

    /** * @Description * @Author songwp * @Date 2022/8/5 12:51 * @Version 1.0.0 **/ @Component public cl ...

  4. PageOffice6 版本常用事件

    1.AfterDocumentOpened 事件 打开文件后自动触发的事件是 AfterDocumentOpened 事件,它通常用于实现文件打开后自动执行某些业务逻辑,比如将默认控件全屏.禁止保存. ...

  5. 节能降耗 | AIRIOT智慧电力综合管理解决方案

      电力技术的发展推动各行各业的生产力,与此同时,企业中高能耗设备的应用以及输配电过程中的电能损耗,也在一定程度上加剧了电能供应压力.以工业制造业为例,企业的管理水平.能耗结构.生产组织方式都关系到能 ...

  6. python连接redis,mongodb以及简单命令使用

    redis 环境如下: [root@mcw01 ~/msRedis]$ ps -ef|grep -v grep|grep redis root 46061 1 0 14:28 ? 00:00:45 r ...

  7. python计算机视觉学习笔记——PIL库的用法

    如果需要处理的原图及代码,请移步小编的GitHub地址 传送门:请点击我 如果点击有误:https://github.com/LeBron-Jian/ComputerVisionPractice 这个 ...

  8. 使用Redis实现短信登陆

    使用Redis实现发送验证码:验证码登陆.注册:登陆校验拦截.登陆状态刷新等一系列问题. 验证码发送和验证登陆注册 思路流程 整体的思路以及流程如题: 代码实现 实体类 User实体类 @Data @ ...

  9. 29.4K star! 仅需几行代码快速构建机器学习 Web 应用项目,无需前端技能!

    大家好,我是狂师! 今天给大家推荐一款开源的Python库:Gradio! Gradio是一个开源的Python库,用于创建机器学习和数据科学的交互式应用和演示. 项目地址: https://gith ...

  10. 【c++】const 限定符

    #include <iostream> int main() { using namespace std; cout << "Hello World!\n" ...