PetaLinux工程更新HDF文件的脚本
工程师可能同时使用多个Vivado工程,以便测试不同的硬件配置。如果能够让一个PetaLinux工程支持多个Vivado工程,那对开发来说是非常方便的。
Vivado工程更改后,PetaLinux工程需要更新HDF文件。另外最好在PetaLinux工程里记录使用的所有硬件相关文件,比如bit、HDF文件等。以便将来检查对应的硬件设计。
下面是一个脚本,可以自动备份以前的硬件相关文件,再从Hareware Description(由Vivado导出)工程取得最新的硬件相关文件;并且执行命令,让PetaLinux工程更新HDF文件。
用法:
需要两个参数,第一个是PetaLinux工程的名字,第二个是Hareware Description工程的目录。
使用这个脚本,可以更方便地让一个PetaLinux工程,支持多个Hareware Description。
##
# Copyright By Schips, All Rights Reserved
# https://gitee.com/schips/
#
# File Name: update_petalinux_project_with_hw
# Created : 2020-08-05 08:55:56
#
##
# Engineer may have several Vivado project that has same name.
# But each project may have different configuration.
# So each project is located in different directory.
# For example, there are three hardware Description directory:
# hardwareDescription_v1;
# hardwareDescription_v2;
# vivado_project/xx.sdk;
# You can use following command to swith the hardware platform for petalinx project:
# peta-update-hdf.sh petalinux_Project hardwareDescription_v1
# peta-update-hdf.sh petalinux_Project hardwareDescription_v2
# ...
# peta-update-hdf.sh petalinux_Project vivado_project/xx.sdk
#!/bin/sh
help () {
echo "ERROR : Invalid arguments"
echo " eg:"
echo " $0 VivadoProject HdfDirectory"
exit
}
if [ ! -d "$1" ]; then
help
fi
if [ ! -d "$2" ]; then
help
fi
command -v petalinux-config >/dev/null 2>&1 || { echo >&2 "Aborted : Require "petalinux-config" but not found."; exit 1; }
#BASE=`pwd`
PETALINUX_PROJECT=`cd $1 && pwd`
HDF_DIR=`cd $2 && pwd`
date_time=`date +%0k%0M-%0m:%0d`
BACKUPDIR=${PETALINUX_PROJECT}/backup/hdf-$date_time
## 打印操作信息
echo "========================================================"
echo "Date-Time : $date_time"
echo -e "Vivado Project : $PETALINUX_PROJECT"
echo -e "HDF Directory : $HDF_DIR"
echo -e "Backup files to directory: ${BACKUPDIR}"
## 对原工程创建 备份的目录
mkdir -p ${BACKUPDIR}
## 备份
echo "========================================================"
echo 'Backupping {hdf,bit}'
cp $PETALINUX_PROJECT/project-spec/hw-description/*.hdf ${BACKUPDIR} -v
#mv -f *.hdf ${BACKUPDIR}/
cp $PETALINUX_PROJECT/project-spec/hw-description/*.bit ${BACKUPDIR} -v
#mv -f *.bit ${BACKUPDIR}/
## 不需要(也没有)
#mv -f *.ltx ${BACKUPDIR}/
## 打印备份结果
echo 'Backupped {hdf,bit} '
echo ${BACKUPDIR}
ls -l ${BACKUPDIR}
#ls -l ${HDF_DIR}/*.hdf
echo "========================================================"
echo "Updating HDF"
echo "petalinux-config --oldconfig --get-hw-description=${HDF_DIR}/"
#cp ${HDF_DIR}/*.hdf /tmp/PETALINUX_PROJECT -v
#cp ${HDF_DIR}/*.bit /tmp/PETALINUX_PROJECT -v
cd ${PETALINUX_PROJECT} && petalinux-config --oldconfig --get-hw-description=${HDF_DIR}/
ret=$?
#cd $BASE
exit $ret