PetaLinux工程更新HDF文件的脚本

背景

工程师可能同时使用多个Vivado工程,以便测试不同的硬件配置。所以需要让一个PetaLinux工程支持多个Vivado工程。

Vivado工程更改后,PetaLinux工程需要更新HDF文件。另外最好在PetaLinux工程里记录使用的所有硬件相关文件,比如bit、HDF文件等。以便将来检查对应的硬件设计。

下面是一个脚本,可以自动备份以前的硬件相关文件,再从Vivado工程取得最新的硬件相关文件;并且执行命令,让PetaLinux工程更新HDF文件。脚本需要两个参数,第一个是Vivado工程的名字,第二个是Vivado工程的目录。

使用这个脚本,可以更方便的让一个PetaLinux工程,支持多个Vivado工程。

##
#    Copyright By Schips, All Rights Reserved
#    https://gitee.com/schips/
#
#    File Name:  petalinuxProject_updateHDF.sh
#    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
#       peta-update-hdf.sh petalinux_Project petalinux_Project/backup/hdf-xx
#!/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

参考链接

https://forums.xilinx.com/t5/嵌入式-工具-软件开发/分享-PetaLinux工程更新HDF文件的脚本/td-p/999662

上一篇:java包装类


下一篇:在Linux环境下GDAL对HDF格式的支持研究