Added ML605 FPGA as default simulator

This commit is contained in:
afpr
2014-05-07 17:44:48 +01:00
parent bf5ce8e1e1
commit 94f57561dd

View File

@@ -3,50 +3,83 @@
#
# Script for running the RTEMS testsuite
#
# Author: André Filipe Pereira Rocha
# Author: André Rocha <afpr@gmv.com>
# Stefan Hepp <stefan@stefant.org>
#
#################################################
# files and dirs
curdir=$(pwd)
sourcedir=$curdir/testsuites
builddir=$curdir/../rtems-build
patmosdir=~/t-crest/build-rtems/patmos
ise_ds_path="/opt/Xilinx/14.7/ISE_DS"
comport=/dev/ttyUSB1
makefile=
# script flow helpers
cdlevel=0
javatoolsflag=0
xilinxfpgaflag=0
toolsflag=1
valuesflag=1
bitflag=0
resumeflag=0
genflag=0
cleanflag=0
partest=
sim=
simargs=()
bsp=
sourcedir=$(pwd)/testsuites
builddir=$(pwd)/../rtems-build
# defaults are set after options are read
resultsdir=
log=
# script lists
tests=(itrontests libtests mptests psxtests samples sptests tmitrontests tmtests)
simulators=(ML605 pasim patex tsim-leon3)
runtests=()
resumetests=()
# test counters
failtests=0
successtests=0
noexectests=0
noresulttests=0
resumeflag=0
resumetests=()
genflag=0
# defaults are set after options are read
bitfile=
biturl=
resultsdir=
log=
# timeout 360s = 6 mins
timeout=360
# string helpers
checklog=" [check log for more information]"
logseparator=">--------------------------------------------------------------------------<\n"
function usage() {
cat <<EOT
Usage: $0 [-h] [-c] [-r] [-g] [-p <sim args>] [-t <tests>] [-s <source dir>] [-b <build dir>] [-o <report dir>] [-l <log file>] [-m <simulator>] [-x <bsp>]
Usage: $0 [-h] [-c] [-r] [-g] [-j] [-f] [-p <sim args>] [-t <tests>] [-s <source dir>] [-b <build dir>] [-i <patmos dir>] [-o <report dir>] [-l <log file>] [-m <simulator>] [-x <bsp>] [-u <com port>] [-d <bit file>] [-e <bit file>] [-v <path Xilinx>] [-z <timeout>]
-h Display help contents
-c Clean files created during testsuite runs
-r Resume test execution
-g Regenerate .scn files
-j Build javatools
-f Configure Xilinx ML605 FPGA
-p <sim args> Pass additional arguments to the simulator. Arguments should be passed between quotation marks
-t <tests> Tests to be executed (itrontests, libtests, mptests, psxtests, samples, sptests, tmitrontests, tmtests)
-s <source dir> Directory containing the testsuites sources
-b <build dir> Build directory of the testsuites
-i <patmos dir> Directory containing the patmos repository
-o <report dir> Report output directory
-l <log file> Override the default log file
-m <simulator> Override the default simulator (pasim)
-x <bsp> Override the default BSP (pasim)
-m <simulator> Override the default simulator (ML605), available simulators are: ML605, pasim, patex, tsim-leon3
-x <bsp> Override the default BSP (tcrest)
-u <com port> Specify the communication port
-d <bit file> Download Xilinx bitfile
-e <bit file> Path to Xilinx bitfile
-v <path Xilinx> Path to Xilinx ISE DS folder
-z <timeout> Timeout, in seconds, for downloading elf files to FPGA (360s)
EOT
}
@@ -65,7 +98,7 @@ function writeFile() {
if [[ ! -f $1 ]]; then
touch $1
fi
echo $2 >> $1
echo -e $2 >> $1
}
function addSimArg() {
@@ -75,23 +108,29 @@ function addSimArg() {
fi
}
function checkDefaults() {
if [[ "$resultsdir" == "" ]]; then
resultsdir=$sourcedir/results
fi
if [[ "$log" == "" ]]; then
log=$resultsdir/testsuite-log.txt
else
log=$resultsdir/$(basename $log)
fi
if [[ "$sim" == "" ]];then
sim="pasim"
addSimArg "--interrupt=1"
addSimArg "--freq=5"
fi
if [[ "$bsp" == "" ]];then
bsp="pasim"
fi
# function arguments:
# 1 - makefile target
function useMakefile() {
curdir=$(pwd)
cd $(dirname $makefile)
make COM_PORT=$comport $1 >> $log 2>&1
cd $curdir
}
# function arguments:
# 1 - comment on configuration
function configureXilinxFPGA() {
local tmp_script=tmp-impact.sh
rm -rf $tmp_script
touch $tmp_script
echo -e "source $ise_ds_path/settings32.sh\nexport LD_PRELOAD=/opt/libusb/libusb-driver.so\nimpact -batch <<EOF\ncleancablelock\nsetMode -bs\nsetCable -port auto\nIdentify -inferir\nidentifyMPM\nassignfile -p 2 -file $bitfile\nprogram -p 2\nexit\nEOF" >> $tmp_script
chmod 777 $tmp_script
echo "Configuring ML605...$1$checklog"
writeFile $log $logseparator
./$tmp_script >> $log 2>&1
writeFile $log $logseparator
rm -rf tmp-impact.sh
rm -rf _impactbatch.log
}
function testsOnResume() {
@@ -117,54 +156,87 @@ function runTest() {
local bin=$(find $testsuitedir -iname "$1.exe")
if [[ $bin ]]; then
local retcode
local tmplog=$resultsdir/$1-tmp.txt
local exelog=$resultsdir/$1-exe.txt
local testlog=$resultsdir/$1-log.txt
case $sim in
pasim|patex)
$sim "${simargs[@]}" -O $resultsdir/$1-tmp.txt $bin > $resultsdir/$1-stats.txt 2>&1
$sim "${simargs[@]}" -O $tmplog $bin > $exelog 2>&1
retcode=$?
;;
tsim-leon3)
echo -e "load $bin\ngo\nquit\n" >> tsim-script.txt
$sim "${simargs[@]}" -c tsim-script.txt > $resultsdir/$1-tmp.txt
$sim "${simargs[@]}" -c tsim-script.txt > $tmplog
retcode=$?
sed -i '1,24d;$d' $resultsdir/$1-tmp.txt
rm -rf tsim-script.txt
sed -i '1,24d;$d' $tmplog
rm -rf tsim-script.txt
;;
ML605)
local patserdow=$(find $patmosdir -iname "patserdow" -type f -executable | head -1)
if [[ $patserdow == "" ]]; then
"Error: patserdow java script not found"
exit 1
fi
#cp $bin "$(dirname bin)/$(basename bin).elf"
timeout --foreground $timeout"s" $patserdow -v $comport $bin > $exelog 2>&1
retcode=$?
sed -i "/\[..........\]/d" $exelog
local tmp=$resultsdir/$1-tmp-tmp.txt
sed -ne '/\<Entry point:\(.*\)\>/,/\<EXIT 0\>/{/\<Entry point:\(.*\)\>/{h;d};H;/\<EXIT 0\>/{x;p}}' $exelog > $tmplog
tail -n +3 $tmplog | head -n -2 > $tmp && mv $tmp $tmplog
;;
esac
sed -i "s/\r//" $resultsdir/$1-tmp.txt
sed -i "s/\r//" $tmplog
if [[ $genflag == 1 ]]; then
cp -f $resultsdir/$1-tmp.txt $1.scn
cp -f $tmplog $1.scn
writeFile $log "$3: generating file $1.scn"
echo "$3: generating file $1.scn"
rm -rf $resultsdir/$1-tmp.txt $resultsdir/$1-stats.txt
rm -rf $tmplog $exelog
else
if [[ $retcode != 0 ]]; then
if [[ $retcode != 0 ]]; then
writeFile $log "$3: Test executed: Failed with return code $retcode!"
echo "$(tput setaf 1)$3: Test executed: Failed with return code $retcode!$(tput setaf 7)"
let failtests+=1
elif [[ $(find -maxdepth 1 -iname "*.scn" ) ]]; then
# TODO for some reasons, the pasim output has two empty lines at the beginning and windows newlines,
# should be fixed (?), for now we just ignore this
diff --ignore-blank-lines $resultsdir/$1-tmp.txt $1.scn > $resultsdir/$1-log.txt
if [[ -s $resultsdir/$1-log.txt ]]; then
writeFile $log "$3: Test executed: Failed!"
cp -f $resultsdir/$1-tmp.txt $resultsdir/$1-out.txt
echo "$(tput setaf 1)$3: Test executed: Failed!$(tput setaf 7)"
let failtests+=1
else
writeFile $log "$3: Test executed: Passed!"
echo "$(tput setaf 2)$3: Test executed: Passed!$(tput setaf 7)"
rm -rf $resultsdir/$1-log.txt
let successtests+=1
#timeout, kill processes hanging port and reconfigure FPGA
if [[ $sim == "ML605" && $retcode == 124 ]]; then
lsof | grep $comport | awk 'NR!=1 {print $3}' | xargs kill
configureXilinxFPGA " [reconfiguration due to timeout]"
fi
else
writeFile $resultsdir/$2-log.txt "##### $3 #####"
cat $resultsdir/$1-tmp.txt >> $resultsdir/$2-log.txt
writeFile $resultsdir/$2-log.txt "##### $3 #####"
writeFile $log "$3: Test executed: check $2-log.txt"
echo "$3: Test executed: check $2-log.txt"
let noresulttests+=1
if [[ $sim != "pasim" ]]; then
rm -rf $exelog
else
mv $exelog $resultsdir/$1-stats.txt
fi
if [[ $(find -maxdepth 1 -iname "*.scn" ) ]]; then
# TODO for some reasons, the pasim output has two empty lines at the beginning and windows newlines,
# should be fixed (?), for now we just ignore this
diff --ignore-space-change $tmplog $1.scn > $testlog
if [[ -s $testlog ]]; then
writeFile $log "$3: Test executed: Failed!"
cp -f $tmplog $resultsdir/$1-out.txt
echo "$(tput setaf 1)$3: Test executed: Failed!$(tput setaf 7)"
let failtests+=1
else
writeFile $log "$3: Test executed: Passed!"
echo "$(tput setaf 2)$3: Test executed: Passed!$(tput setaf 7)"
let successtests+=1
rm -rf $testlog
fi
else
local noresultlog=$resultsdir/$2-log.txt
writeFile $noresultlog "##### $3 #####"
cat $tmplog >> $noresultlog
writeFile $noresultlog "##### $3 #####"
writeFile $log "$3: Test executed: check $2-log.txt"
echo "$3: Test executed: check $2-log.txt"
let noresulttests+=1
fi
fi
rm -rf $resultsdir/$1-tmp.txt
rm -rf $tmplog
fi
elif [[ $(find -maxdepth 1 -iname "*.scn" ) && $genflag == 0 ]]; then
writeFile $log "$3: Test not executed: $1.exe file not found"
@@ -205,7 +277,7 @@ function recurseDirs
done
}
while getopts ":hHp:P:t:T:l:L:cCrRb:B:s:S:o:O:m:M:x:X:gG" opt; do
while getopts ":hHp:P:t:T:l:L:cCrRb:B:s:S:o:O:m:M:x:X:gGjJfFu:U:e:E:d:D:v:V:i:I:z:Z:" opt; do
case "$opt" in
h|H)
usage
@@ -228,28 +300,30 @@ while getopts ":hHp:P:t:T:l:L:cCrRb:B:s:S:o:O:m:M:x:X:gG" opt; do
log="$OPTARG"
;;
c|C)
checkDefaults
cleanFiles
exit 1
cleanflag=1
;;
r|R)
resumeflag=1
checkDefaults
testsOnResume $log
resumeflag=1
;;
s|S)
sourcedir="$OPTARG"
sourcedir=${OPTARG%/}
;;
b|B)
builddir="$OPTARG"
builddir=${builddir/%"/"/}
b|B)
builddir=${OPTARG/%"/"/}
;;
o|O)
resultsdir="$OPTARG"
resultsdir=${OPTARG%/}
;;
m|M)
sim="$OPTARG"
simargs=()
containsElement "$OPTARG" "${simulators[@]}"
if [[ $? == 1 ]]; then
sim="$OPTARG"
simargs=()
else
echo "Invalid simulator: $OPTARG"
usage
exit 1
fi
;;
x|X)
bsp="$OPTARG"
@@ -257,6 +331,31 @@ while getopts ":hHp:P:t:T:l:L:cCrRb:B:s:S:o:O:m:M:x:X:gG" opt; do
g|G)
genflag=1
;;
j|J)
javatoolsflag=1
;;
f|F)
xilinxfpgaflag=1
;;
u|U)
comport="$OPTARG"
;;
e|E)
bitfile="$OPTARG"
;;
d|D)
biturl="$OPTARG"
bitflag=1
;;
v|V)
ise_ds_path=${OPTARG%/}
;;
i|I)
patmosdir=${OPTARG%/}
;;
z|Z)
timeout="$OPTARG"
;;
\?)
echo "Invalid option: -$OPTARG"
usage
@@ -270,25 +369,143 @@ while getopts ":hHp:P:t:T:l:L:cCrRb:B:s:S:o:O:m:M:x:X:gG" opt; do
esac
done
checkDefaults
# check user-specified and default values
if [[ "$resultsdir" == "" ]]; then
resultsdir=$sourcedir/results
fi
# check if user chose to clean results folder
if [[ $cleanflag == 1 ]]; then
cleanFiles
exit 1
fi
# make results dir if it does not exist
if [[ ! -d $resultsdir ]]; then
mkdir -p $resultsdir
fi
# get absolute path of results dir
curdir=$(pwd)
cd $resultsdir
resultsdir=$(pwd)
cd $curdir
# update log file
if [[ "$log" == "" ]]; then
log=$resultsdir/testsuite-log.txt
else
log=$resultsdir/$(basename $log)
fi
if [[ "$bsp" == "" ]]; then
bsp="tcrest"
fi
testsuitedir=$builddir/patmos-unknown-rtems/c/$bsp/testsuites
if [[ ! -d $sourcedir ]]; then
echo "Invalid source dir. Go to RTEMS source dir or specify the testsuites source dir with -s."
exit 1
makefile=$patmosdir/Makefile
if [[ "$bitfile" == "" ]]; then
bitfile=$resultsdir/t-crest.bit
fi
if [[ ! -d $testsuitedir ]]; then
echo "Invalid testsuite dir. Check if the specified BSP is correct."
exit 1
if [[ "$sim" == "" ]]; then
sim="ML605"
elif [[ "$sim" == "pasim" ]]; then
addSimArg "--interrupt=1"
addSimArg "--freq=5"
addSimArg "-v"
fi
cd $sourcedir
if [[ $resumeflag == 0 ]]; then
rm -rf $log
fi
if [[ ! -d $resultsdir ]]; then
mkdir $resultsdir
rm -rf $log
else
testsOnResume $log
fi
# check if files and directories exist
if [[ ! -d $sourcedir ]]; then
echo "Error: $sourcedir not found. Go to RTEMS source dir or specify the testsuites source dir with -s."
valuesflag=0
fi
if [[ ! -d $testsuitedir ]]; then
echo "Error: $testsuite not found. Check if the specified BSP is correct."
valuesflag=0
fi
if [[ ($sim == "ML605" || $javatoolsflag == 1) && ! -d $patmosdir ]]; then
echo "Error: $patmosdir not found. Specify the correct patmos dir with -i."
valuesflag=0
fi
if [[ ($sim == "ML605" || $xilinxfpgaflag == 1) && ! -d $ise_ds_path ]]; then
echo "Error: $ise_ds_path not found. Specify the correct path to Xilinx ISE DS folder with -v."
valuesflag=0
fi
if [[ $sim == "ML605" && ! -c $comport ]]; then
echo "Error: $comport not found. Specify the correct communication port with -u."
valuesflag=0
fi
if [[ ($sim == "ML605" || $xilinxfpgaflag == 1) && ! -f $bitfile && $bitflag == 0 ]]; then
echo "Error: $bitfile not found. Specify the correct path to bitfile or download new bitfile with -d."
valuesflag=0
fi
# check if timeout is number and is positive or zero
if [[ $sim == "ML605" && (! $timeout =~ ^[\-0-9]+$ || $timeout -lt 0) ]]; then
echo "Error: $timeout not valid for timeout. Specify zero or a positive integer with option -z."
valuesflag=0
fi
if [[ $valuesflag == 0 ]]; then
exit 1
fi
# make javatools for downloading elf files to fpga
if [[ $javatoolsflag == 1 ]]; then
# check if Makefile exists
if [[ ! -f $makefile ]]; then
echo "Error: $makefile not found. Check if the specified patmos dir is correct."
exit 1
fi
echo "Making javatools..."
writeFile $log $logseparator
useMakefile "javatools scripttools"
if [[ $? != 0 ]]; then
echo "Error: making javatools$checklog"
toolsflag=0
fi
writeFile $log $logseparator
fi
# download specified bitfile
if [[ $bitflag == 1 ]]; then
echo "Downloading bitfile..."
rm -rf $bitfile
writeFile $log $logseparator
wget $biturl -O $bitfile >> $log 2>&1
if [[ $? != 0 ]]; then
echo "Error: downloading bitfile$checklog"
toolsflag=0
fi
writeFile $log $logseparator
fi
if [[ $toolsflag == 0 ]]; then
exit 1
fi
if [[ $xilinxfpgaflag == 1 || $sim == "ML605" ]]; then
configureXilinxFPGA
fi
cd $sourcedir
recurseDirs $(ls -1)
if [[ $genflag == 0 ]]; then