ZYNQ:使用PetaLinux打包 BOOT.BIN、image.ub
说明
个人还是比较喜欢灵活去管理各个部分的源码。
有关文章:
ZYNQ:PetaLinux提取Linux和UBoot配置、源码
编译Linux
取得Linux源代码和配置后,可以在其中执行make,编译Linux。
注意,编译前请导入PetaLinux环境变量:
- 设置和导出ARCH为arm或者arm64;
- 设置和导出CROSS_COMPILE,比如aarch64-linux-gnu-。
编译(通过,但是diff 有差异):
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- xilinx_peta_defconfig
# xilinx_peta_defconfig 是 我们前文拷贝 .config 得来的。
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j 2
编译后得到vmlinux
打包 image.ub
将kernel
、dtb
、rootfs.img
打包成image.ub
。
kernel
:一般就是linux
生成的elf文件。dtb
:设备树,与驱动有关。rootfs.img
:编译完成的文件系统。
所以,image.ub 没有那么神秘,就是一个包。
使用以下命令:
#!/bin/sh
CROSS_COMPILE=arm-linux-gnueabihf-
${CROSS_COMPILE}-objcopy -O binary -R .note -R .comment -S vmlinux linux.bin
gzip -9 linux.bin
mv -f linux.bin.gz linux.bin
#需要修改 .its
mkimage -f fit-image-petalinux-user-image.its image.ub
编译 UBoot
取得UBoot源代码和配置后,需要有工具链的环境,编译:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- clean
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- xilinx_peta_defconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j 2
得到u-boot
(实际上就是u-boot.elf
)
打包 BOOT.BIN
1、需要4个文件:u-boot.elf
、zynq_fsbl.elf
、bootgen.bif
、system.bit
。
u-boot.elf
:就是uboot编译生成的bootgen.bif
:可以自己手写。zynq_fsbl.elf
:Vivado创建PS以后,在SDK中创建File
-New
-Application Project
-Zynq FSBL
以后Build Project
生成的。system.bit
:FPGA工程师生成的二进制流,用于PL端烧写的(可以没有)
2、修改bif文件,或者自己搞一个。
#cat build/bootgen.bif
//arch = zynq; split = false; format = BIN
the_ROM_image:
{
[bootloader] /tmp/tmp.SXFL3UZOJ7/zynq_fsbl.elf
/tmp/tmp.SXFL3UZOJ7/system.bit
/tmp/tmp.SXFL3UZOJ7/u-boot.elf
}
3、使用下列命令创建BOOT.BIN
。
bootgen -arch zynq -image bootgen.bif -o BOOT.BIN -w on
$ bootgen -help
****** Xilinx Bootgen v2018.3
**** Build date : Nov 15 2018-19:22:29
** Copyright 1986-2018 Xilinx, Inc. All Rights Reserved.
------------------------------------------------------------------------------+
COMMAND LINE OPTIONS |
-------------------------------+----------------------------------------------+
-arch [options] | Xilinx Architecture |
| options: [zynq, zynqmp, fpga] |
-------------------------------+----------------------------------------------+
-image <filename> | Input Boot Image File (.bif) |
-------------------------------+----------------------------------------------+
-o <filename> | Output filename in MCS/BIN format |
-------------------------------+----------------------------------------------+
-w [options] | Overwrite mode |
| options: [on, off] |
-------------------------------+----------------------------------------------+
-encrypt [options] | AES Key storage in chip (Zynq only) |
| options: [bbram, efuse] |
-------------------------------+----------------------------------------------+
-p <string> | Part name |
-------------------------------+----------------------------------------------+
-efuseppkbits <filename> | Generate PPK hash for e-fuse |
-------------------------------+----------------------------------------------+
-generate_hashes | Generate SHA hashes (PKCS#1v1.5) |
-------------------------------+----------------------------------------------+
-spksignature <filename> | Generate SPK signature file |
-------------------------------+----------------------------------------------+
-fill <hex-byte> | Fill byte for padding |
-------------------------------+----------------------------------------------+
-split [options] | Split partitions to diff files |
| options: [bin, mcs] |
-------------------------------+----------------------------------------------+
-padimageheader [options] | Pad header tables |
| options: [0, 1] |
-------------------------------+----------------------------------------------+
-process_bitstream [options] | Outputs bitstream in bin/mcs format |
| options: [bin, mcs] |
-------------------------------+----------------------------------------------+
-generate_keys [options] | Generate authentication keys |
| options: [pem, rsa, obfuscatedkey] |
-------------------------------+----------------------------------------------+
-dual_qspi_mode [options] | Generate 2 output files for Dual QSPI |
| options: [parallel, stacked <size>] |
-------------------------------+----------------------------------------------+
-log [options] | Generate log file |
| options: [error, warning, info, debug, trace]|
-------------------------------+----------------------------------------------+
-zynqmpes1 | Generate boot image for (1.0)ES1 |
-------------------------------+----------------------------------------------|
-nonbooting | Generate an intermediate boot image |
-------------------------------+----------------------------------------------|
-encryption_dump | Generate encryption log file |
-------------------------------+----------------------------------------------+
-h | -help | Print the help summary |
-------------------------------+----------------------------------------------+
-bif_help | Print the BIF help summary |
-------------------------------+----------------------------------------------+
Note : For more info on bootgen options, use the command |
bootgen -help <option> |
Example : bootgen -help efuseppkbits |
------------------------------------------------------------------------------+
bootgen 打包脚本
#/* @file package_BOOT.BIN.sh
#* @brief 打包BOOT.BIN
#* @author Schips
#* @date 2020-10-31 09:04:43
#* @version v1.0
#* @copyright Copyright By Schips, All Rights Reserved
#*
#**********************************************************
#*
#* @par 修改日志:
#* <table>
#* <tr><th>Date <th>Version <th>Author <th>Description
#* <tr><td>2020-10-31 <td>1.0 <td>Schips <td>创建初始版本
#* </table>
#*
#**********************************************************
#*/
#!/bin/sh
BIF=/tmp/.bif
help () {
echo "Error : need \$fsbl.elf \$system.bit \$u-boot.elf BOOT.BIN"
echo " eg :"
echo " $0 fsbl.elf system.bit u-boot.elf BOOT.BIN"
exit 1
}
if [ -z "$1" ]; then
help
fi
if [ -z "$2" ]; then
help
fi
if [ -z "$3" ]; then
help
fi
if [ -z "$4" ]; then
help
fi
FSBL=$1
PL_BIT=$2
UBOOT=$3
BOOT_BIN=$4
TMP_FSBL=/tmp/fsbl.elf
TMP_PL_BIT=/tmp/system.bit
TMP_UBOOT=/tmp/u-boot.elf
cp -v $FSBL $TMP_FSBL
cp -v $PL_BIT $TMP_PL_BIT
cp -v $UBOOT $TMP_UBOOT
require () {
command -v $1 >/dev/null 2>&1 || { echo >&2 "Aborted : Require \"$1\" but not found."; exit 1; }
}
# 文件内容追加
append_line_into_file ()
{
if [[ $# -lt 2 ]]; then
return
fi
FILE=$1
LINE=$2
echo $LINE >> $FILE
}
make_bif () {
rm ${BIF} -rf
echo "Making BIF for bootgen : \n\n"
append_line_into_file ${BIF} "//arch = zynq; split = false; format = BIN"
append_line_into_file ${BIF} "the_ROM_image:"
append_line_into_file ${BIF} "{"
append_line_into_file ${BIF} " [bootloader] $TMP_UBOOT"
append_line_into_file ${BIF} " $TMP_PL_BIT"
append_line_into_file ${BIF} " $TMP_UBOOT"
append_line_into_file ${BIF} "}"
echo "\n\n"
cat ${BIF}
}
make_boot_bin () {
echo "Making BOOT.BIN: \n\n"
bootgen -arch zynq -image $BIF -o $BOOT_BIN -w on
ls $BOOT_BIN -l
}
require bootgen
make_bif
make_boot_bin
exit $?
https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18842056/FPGA+Manager+ZCU102
http://www.uisrc.com/forum.php?mod=viewthread&tid=2334
#cat build/bootgen.bif
the_ROM_image:
{
[bootloader] /tmp/tmp.SXFL3UZOJ7/zynq_fsbl.elf
/tmp/tmp.SXFL3UZOJ7/system.bit
/tmp/tmp.SXFL3UZOJ7/u-boot.elf
}
patelinux-package 打包 BOOT.BIN
使用bootgen好像有问题,总是提示u-boot文件出现问题:
[ERROR] : Multiple executable program sections in /tmp/u-boot.elf
因此,还是推荐使用这个方法,但是这个方法需要在petalinux工程中进行。
petalinux-package --boot --fsbl ./images/linux/zynq_fsbl.elf --fpga ./images/linux/system.bit --u-boot --force && cp images/linux/BOOT.BIN /tftpboot/BOOT.BIN_for_emmc
编译uboot、Linux
编译uboot、kernel方法很常见,我这里介绍我自己使用的方法。
思路:先把通用的配置保存起来,编译uboot、kernel的时候只需要读取配置就可以了
配置
##
# Copyright By Schips, All Rights Reserved
#
# File Name: init.sh
# Created : 2020-07-21 09:12:10
#
##
#!/bin/sh
XLNX_SDK_CONFIG=~/.sdk_xlnx_config
cd `dirname $0`
SDKTOP=`cd ../../ && pwd`
TC=${SDKTOP}/toolchain
if [ ! -d "$TC" ]; then
TC=`cd ${SDKTOP}/../toolchain&& pwd`
fi
add_to_config () {
echo "$1" >> $XLNX_SDK_CONFIG
}
echo "Initializing [$XLNX_SDK_CONFIG]"
rm $XLNX_SDK_CONFIG 2>/dev/null
add_to_config "## For All"
add_to_config "export ARCH=arm"
add_to_config "export ARM_GCC_PATH=${TC}/petalinux_2018.3/gcc-arm-linux-gnueabi/bin"
add_to_config "export BUILD_CORE=4"
add_to_config ""
add_to_config "## app, kernel"
add_to_config "export APP_CROSS ?= arm-linux-gnueabihf-"
add_to_config "export KERNEL_CROSS ?= arm-linux-gnueabihf-"
add_to_config "export KERNEL_CFGDIR ?= arch/arm/configs"
add_to_config "export KERNEL_CONFIG ?= xilinx_zynq7000_peta_defconfig"
add_to_config ""
add_to_config "## Uboot"
add_to_config "export UBOOT_CROSS ?= arm-linux-gnueabihf-"
add_to_config "export UBOOT_CFGDIR ?= configs"
add_to_config "#export UBOOT_CROSS?= arm-none-eabi-"
add_to_config "export UBOOT_CONFIG ?= xilinx_zynq7000_peta_defconfig"
echo "============================="
cat $XLNX_SDK_CONFIG
echo "============================="
echo "Initalized [$XLNX_SDK_CONFIG]"
uboot
#==============================================
##
# Copyright By Schips, All Rights Reserved
#
# File Name: build_uboot.sh
# Created : 2020-07-13 10:49:24
#
##
#!/bin/sh
BASE=`pwd`
XLNX_SDK_CONFIG=~/.sdk_xlnx_config
get_config_from_sdk_config ()
{
ret=`cat $XLNX_SDK_CONFIG | grep -v "#" | grep -E '\=|\?\=' | grep "$1" | grep "export" | awk -F= '{print $2}'`
echo $ret
}
ARM_GCC_PATH=`get_config_from_sdk_config ARM_GCC_PATH`
export PATH=$PATH:$ARM_GCC_PATH
echo "Building [$BASE]"
BUILD_ARCH=`get_config_from_sdk_config ARCH`
BUILD_CROSS=`get_config_from_sdk_config UBOOT_CROSS`
CONFIG=`get_config_from_sdk_config UBOOT_CONFIG`
CORE=`get_config_from_sdk_config BUILD_CORE`
rebuild () {
make ARCH=${BUILD_ARCH} CROSS_COMPILE=$BUILD_CROSS clean
make ARCH=${BUILD_ARCH} CROSS_COMPILE=$BUILD_CROSS $CONFIG
make ARCH=${BUILD_ARCH} CROSS_COMPILE=$BUILD_CROSS -j $CORE
}
rebuild
echo "Built [$BASE]"
kernel
与uboot类似,配置项有一些小差异而已。
##
# Copyright By Schips, All Rights Reserved
#
# File Name: build_kernel.sh
# Created : 2020-08-06 14:19:04
#
##
#!/bin/sh
BASE=`pwd`
XLNX_SDK_CONFIG=~/.sdk_xlnx_config
date_time=`date +%0m%0d-%0k:%0M`
get_config_from_sdk_config ()
{
ret=`cat $XLNX_SDK_CONFIG | grep -v "#" | grep -E '\=|\?\=' | grep "$1" | grep "export" | awk -F= '{print $2}'`
echo $ret
}
ARM_GCC_PATH=`get_config_from_sdk_config ARM_GCC_PATH`
export PATH=$PATH:$ARM_GCC_PATH
BUILD_ARCH=`get_config_from_sdk_config ARCH`
BUILD_CROSS=`get_config_from_sdk_config KERNEL_CROSS`
CONFIG=`get_config_from_sdk_config KERNEL_CONFIG`
CORE=`get_config_from_sdk_config BUILD_CORE`
SRCCONFIGDIR=`get_config_from_sdk_config KERNEL_CFGDIR`
help () {
echo "Use following cmd : "
echo " help : For help"
echo " config : Memuconfig based on present config"
echo " deconfig : Reset config as [$CONFIG]"
echo " build : Build based on present config"
echo " clean : Clean object built"
echo " rebuild : Reset config, clean and build"
echo " dtbs : Build dtbs"
}
if [ -z "$1" ]; then
help
exit 1
fi
config() {
make ARCH=${BUILD_ARCH} CROSS_COMPILE=$BUILD_CROSS menuconfig
echo "Do you want to save this config as [${CONFIG}] ?"
echo " [yy/n], default [n] in 5 seconds."
read -t 5 answer
if [ "$answer" == "yy" ]; then
echo "Saving .config as default"
cp -v ${SRCCONFIGDIR}/${CONFIG} .${CONFIG}_backup_${date_time}
cp -v .config ${SRCCONFIGDIR}/xilinx_zynq7000_peta_defconfig
echo "Saved .config as default"
fi
}
deconfig () {
make ARCH=${BUILD_ARCH} CROSS_COMPILE=$BUILD_CROSS clean
cp .config .config_backup_${date_time} -v 2>/dev/null
make ARCH=${BUILD_ARCH} CROSS_COMPILE=$BUILD_CROSS $CONFIG
echo "Configed with [$CONFIG]"
}
rebuild () {
make ARCH=${BUILD_ARCH} CROSS_COMPILE=$BUILD_CROSS clean
make ARCH=${BUILD_ARCH} CROSS_COMPILE=$BUILD_CROSS $CONFIG
make ARCH=${BUILD_ARCH} CROSS_COMPILE=$BUILD_CROSS -j $CORE
make ARCH=${BUILD_ARCH} CROSS_COMPILE=$BUILD_CROSS dtbs -j $CORE
}
build () {
make ARCH=${BUILD_ARCH} CROSS_COMPILE=$BUILD_CROSS -j $CORE
}
dtbs () {
make ARCH=${BUILD_ARCH} CROSS_COMPILE=$BUILD_CROSS -j $CORE dtbs
}
clean () {
make ARCH=${BUILD_ARCH} CROSS_COMPILE=$BUILD_CROSS clean
}
command -v $1 >/dev/null 2>&1 || { help && exit 1; }
echo "Doing [$1]"
$1
echo "Done with [$1]"
ZYNQ:使用PetaLinux打包 BOOT.BIN、image.ub的更多相关文章
- MPSOC之5——开发流程BOOT.BIN
需要把若干文件打成大包,烧写到flash或者sd卡中,才能启动运行. 1.petalinux打包 petalinux-packet打包时,需要petalinux的工程,限制太死了,不用. 2 wind ...
- 如何解包,编辑,重新打包boot images
HOWTO: Unpack, Edit, and Repack Boot Images http://forum.xda-developers.com/showthread.php?t=443994 ...
- 一键解包/打包boot.img/recovery.img工具(高通/MTK双版 支持android 5.1以上)
下载地址: 链接: https://pan.baidu.com/s/1hsA2oWc 密码: skdx
- 嵌入式开发之zynqMp ---Zynq UltraScale+ MPSoC 图像编码板zcu102
1.1 xilinx zynqMp 架构 1.1.1 16nm 级别工艺 Zynq UltraScale+ MPSoC架构 Xilinx新一代Zynq针对控制.图像和网络应用推出了差异化的产品系,这 ...
- zynq linux驱动之PL-PS中断【转】
转自:https://blog.csdn.net/h244259402/article/details/83993524 PC:Windows 10 虚拟机:ubuntu 16.04 vivado:2 ...
- ZYNQ Linux 移植:包含petalinux移植和手动移植debian9
参考: https://electronut.in/workflow-for-using-linux-on-xilinx-zynq/ https://blog.csdn.net/m0_37545528 ...
- Boot Petalinux Project Using a remote system
通过jtag实现在远程服务器端下载petalinux image到连接在本地PC的开发板上的方法. 具体连接方式为 比如Host的系统为Windows,Remote system为运载在远程服务器上的 ...
- ZYNQ跑系统 系列(二) petalinux方式移植linux
三.搭建petalinux工程 0.定位目录 先在shell中找一个准备存放工程的地方,(我的是home/hlf/PRO),命令行cd home/hlf/PRO 1.定位编译链 根据安装p ...
- Android : 修改内核源码 and 编译、打包成新的boot.img
一.Android内核源码的下载: 1.Google GIT地址: $ git clone https://android.googlesource.com/kernel/common.git $ g ...
- zynq基础-->linux下软件应用
操作系统:Ubuntu 16.04 LTS 应用软件:Vivado 2016.2 + petalinux 2016.2 参考官方应用手册:ug1144-petalinux-tools-referen ...
随机推荐
- 第一讲 Cadence-于真博士课程简介
第一讲 Cadence-于真博士课程简介 以工程化的思想来学习本课程,比较有效,从一个DSP开发板设计为例开始,做出PCB板,顺带学会Cadence软件操作,而不是仅仅学习软件. 前期准备工作,阅读配 ...
- C语言笔记001-用C语言编写程序
例2-1 在屏幕上显示一个短句"Hello World!". #include <stdio.h> int main(void) { printf("hel ...
- arduino uno+LCD12864(ST7735S)+蓝牙模块实现贪吃蛇
1.前言: 1.1本实验实现的贪吃蛇能穿越边界,结束游戏的唯一条件是贪吃蛇到达指定长度 1.2本实验所用LCD可能不是LCD12864,LCD12864所用库为u8glib,笔者在词库中并没有找到型号 ...
- Swift Charts 报错:Initializer ... requires that .. conform to ‘Identifiable‘
目录 1. 问题描述 2. 解决办法 1. 问题描述 在运行Swift Charts官方折线图示例时,出现了如下错误. Initializer 'init(_:content:)' requires ...
- python教程8-页面爬虫
python爬虫常用requests和beautifulSoup这2个第三方模块.需要先进行手动安装. requests负责下载页面数据,beautifulSoup负责解析页面标签. 关于beauti ...
- 安卓开发封装处理Retrofit协程请求中的异常
上篇文章讲解了怎么使用Kotlin的协程配合Retrofit发起网络请求,使用也是非常方便,但是在处理请求异常还不是很人性化.这篇文章,我们将处理异常的代码进行封装,以便对异常情况返回给页面,提供更加 ...
- VMware Workstation解锁Mac系统
VMware workstation在安装虚拟机的时候,如果是安装Windows.CentOS.Ubuntu等相关系统的话,仅仅需要一个系统镜像就可以顺利安装了. 但是如果想要安装苹果系统Mac的话, ...
- Android 13 - Media框架(7)- NuPlayer::Source
关注公众号免费阅读全文,进入音视频开发技术分享群! Source 在播放器中起着拉流(Streaming)和解复用(demux)的作用,Source 设计的好坏直接影响到播放器的基础功能,我们这一节将 ...
- Newtonsoft.Json解决中文编码问题
Newtonsoft.Json解决中文编码 默认Newtonsoft.Json序列化对象后,返回的中文未进行编码. 需要将编码转换的话,需要 1 2 3 4 5 6 7 var json = Json ...
- 鸿蒙HarmonyOS实战-Web组件(前端函数和应用侧函数相互调用)
前言 前端函数和应用侧函数相互调用是指前端页面中的JavaScript函数和应用程序侧的函数之间进行相互调用. 在前端开发中,常常会使用JavaScript函数来处理用户的交互事件和操作.这些函数可以 ...