【分享】PetaLinux工程更新HDF文件的脚本

作者:hankf,Xilinx Employee

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

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

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

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

#!/bin/sh

echo -e "\nBegin to run script: $0"

# 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 projects:
# Vivado_Project_ver1\ Vivado_Project.sdk; Vivado_Project_ver2\ Vivado_Project.sdk;
# Vivado_Project_ver3\ Vivado_Project.sdk
#
# You can use following command to swith the vivado project:
# peta-update-hdf.sh Vivado_Project Vivado_Project_ver1
# peta-update-hdf.sh Vivado_Project Vivado_Project_ver2
# peta-update-hdf.sh Vivado_Project Vivado_Project_ver3

echo -e "Example usage: $0 Vivado_Project_name Vivado_Project_directory"
echo -e "Vivado Project name: $1"
echo -e "Vivado Project directory: $2"

date_time=`date +%0m%0d-%0k%0M`
echo "Date-Time is $date_time"

echo -e "\nBackup files to directory: ./backup/hdf-$date_time"
mkdir -p ./backup/hdf-$date_time

mv -f *.hdf ./backup/hdf-$date_time/
mv -f *.bit ./backup/hdf-$date_time/
mv -f *.ltx ./backup/hdf-$date_time/
ls -l ./backup/hdf-$date_time/

echo -e "\nVivado Project SDK directory: $2/$1.sdk/ files:"
ls -l $2/$1.sdk/*.hdf
echo "ls $2/$1.sdk/ -l" >> hdf_list.txt
ls -l $2/$1.sdk/ >> hdf_list.txt
cp $2/$1.sdk/*.hdf ./

echo -e "\nVivado Project impl directory: $2/$1.runs/impl_1/ files:"
ls -l $2/$1.runs/impl_1/*.bit
ls -l $2/$1.runs/impl_1/*.ltx
cp $2/$1.runs/impl_1/*.bit ./
cp $2/$1.runs/impl_1/*.ltx ./

echo -e "\nCurrent directory files:"
ls -l *.hdf
ls -l *.bit
ls -l *.ltx

echo "petalinux-config --oldconfig --get-hw-description=$2/$1.sdk/"
echo "petalinux-config --oldconfig --get-hw-description=$2/$1.sdk/" >> hdf_list.txt
petalinux-config --oldconfig --get-hw-description=$2/$1.sdk/

# Create New Project from bsp
# petalinux-create -t project -s 

# Create New empty Project
# petalinux-create --type project --template zynqMP --name project-name

最新文章

最新文章