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 # Script for running the RTEMS testsuite
# #
# Author: André Filipe Pereira Rocha # Author: André Rocha <afpr@gmv.com>
# Stefan Hepp <stefan@stefant.org> # 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 cdlevel=0
javatoolsflag=0
xilinxfpgaflag=0
toolsflag=1
valuesflag=1
bitflag=0
resumeflag=0
genflag=0
cleanflag=0
partest= partest=
sim= sim=
simargs=() simargs=()
bsp= 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) tests=(itrontests libtests mptests psxtests samples sptests tmitrontests tmtests)
simulators=(ML605 pasim patex tsim-leon3)
runtests=() runtests=()
resumetests=()
# test counters
failtests=0 failtests=0
successtests=0 successtests=0
noexectests=0 noexectests=0
noresulttests=0 noresulttests=0
resumeflag=0
resumetests=() # defaults are set after options are read
genflag=0 bitfile=
biturl=
resultsdir=
log=
# timeout 360s = 6 mins
timeout=360
# string helpers
checklog=" [check log for more information]"
logseparator=">--------------------------------------------------------------------------<\n"
function usage() { function usage() {
cat <<EOT 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 -h Display help contents
-c Clean files created during testsuite runs -c Clean files created during testsuite runs
-r Resume test execution -r Resume test execution
-g Regenerate .scn files -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 -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) -t <tests> Tests to be executed (itrontests, libtests, mptests, psxtests, samples, sptests, tmitrontests, tmtests)
-s <source dir> Directory containing the testsuites sources -s <source dir> Directory containing the testsuites sources
-b <build dir> Build directory of the testsuites -b <build dir> Build directory of the testsuites
-i <patmos dir> Directory containing the patmos repository
-o <report dir> Report output directory -o <report dir> Report output directory
-l <log file> Override the default log file -l <log file> Override the default log file
-m <simulator> Override the default simulator (pasim) -m <simulator> Override the default simulator (ML605), available simulators are: ML605, pasim, patex, tsim-leon3
-x <bsp> Override the default BSP (pasim) -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 EOT
} }
@@ -65,7 +98,7 @@ function writeFile() {
if [[ ! -f $1 ]]; then if [[ ! -f $1 ]]; then
touch $1 touch $1
fi fi
echo $2 >> $1 echo -e $2 >> $1
} }
function addSimArg() { function addSimArg() {
@@ -75,23 +108,29 @@ function addSimArg() {
fi fi
} }
function checkDefaults() { # function arguments:
if [[ "$resultsdir" == "" ]]; then # 1 - makefile target
resultsdir=$sourcedir/results function useMakefile() {
fi curdir=$(pwd)
if [[ "$log" == "" ]]; then cd $(dirname $makefile)
log=$resultsdir/testsuite-log.txt make COM_PORT=$comport $1 >> $log 2>&1
else cd $curdir
log=$resultsdir/$(basename $log) }
fi
if [[ "$sim" == "" ]];then # function arguments:
sim="pasim" # 1 - comment on configuration
addSimArg "--interrupt=1" function configureXilinxFPGA() {
addSimArg "--freq=5" local tmp_script=tmp-impact.sh
fi rm -rf $tmp_script
if [[ "$bsp" == "" ]];then touch $tmp_script
bsp="pasim" 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
fi 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() { function testsOnResume() {
@@ -117,54 +156,87 @@ function runTest() {
local bin=$(find $testsuitedir -iname "$1.exe") local bin=$(find $testsuitedir -iname "$1.exe")
if [[ $bin ]]; then if [[ $bin ]]; then
local retcode local retcode
local tmplog=$resultsdir/$1-tmp.txt
local exelog=$resultsdir/$1-exe.txt
local testlog=$resultsdir/$1-log.txt
case $sim in case $sim in
pasim|patex) 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=$? retcode=$?
;; ;;
tsim-leon3) tsim-leon3)
echo -e "load $bin\ngo\nquit\n" >> tsim-script.txt 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=$? retcode=$?
sed -i '1,24d;$d' $resultsdir/$1-tmp.txt sed -i '1,24d;$d' $tmplog
rm -rf tsim-script.txt 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 esac
sed -i "s/\r//" $resultsdir/$1-tmp.txt sed -i "s/\r//" $tmplog
if [[ $genflag == 1 ]]; then if [[ $genflag == 1 ]]; then
cp -f $resultsdir/$1-tmp.txt $1.scn cp -f $tmplog $1.scn
writeFile $log "$3: generating file $1.scn" writeFile $log "$3: generating file $1.scn"
echo "$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 else
if [[ $retcode != 0 ]]; then if [[ $retcode != 0 ]]; then
writeFile $log "$3: Test executed: Failed with return code $retcode!" 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)" echo "$(tput setaf 1)$3: Test executed: Failed with return code $retcode!$(tput setaf 7)"
let failtests+=1 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, #timeout, kill processes hanging port and reconfigure FPGA
# should be fixed (?), for now we just ignore this if [[ $sim == "ML605" && $retcode == 124 ]]; then
diff --ignore-blank-lines $resultsdir/$1-tmp.txt $1.scn > $resultsdir/$1-log.txt lsof | grep $comport | awk 'NR!=1 {print $3}' | xargs kill
if [[ -s $resultsdir/$1-log.txt ]]; then configureXilinxFPGA " [reconfiguration due to timeout]"
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
fi fi
else else
writeFile $resultsdir/$2-log.txt "##### $3 #####" if [[ $sim != "pasim" ]]; then
cat $resultsdir/$1-tmp.txt >> $resultsdir/$2-log.txt rm -rf $exelog
writeFile $resultsdir/$2-log.txt "##### $3 #####" else
writeFile $log "$3: Test executed: check $2-log.txt" mv $exelog $resultsdir/$1-stats.txt
echo "$3: Test executed: check $2-log.txt" fi
let noresulttests+=1
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 fi
rm -rf $resultsdir/$1-tmp.txt rm -rf $tmplog
fi fi
elif [[ $(find -maxdepth 1 -iname "*.scn" ) && $genflag == 0 ]]; then elif [[ $(find -maxdepth 1 -iname "*.scn" ) && $genflag == 0 ]]; then
writeFile $log "$3: Test not executed: $1.exe file not found" writeFile $log "$3: Test not executed: $1.exe file not found"
@@ -205,7 +277,7 @@ function recurseDirs
done 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 case "$opt" in
h|H) h|H)
usage 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" log="$OPTARG"
;; ;;
c|C) c|C)
checkDefaults cleanflag=1
cleanFiles
exit 1
;; ;;
r|R) r|R)
resumeflag=1 resumeflag=1
checkDefaults
testsOnResume $log
;; ;;
s|S) s|S)
sourcedir="$OPTARG" sourcedir=${OPTARG%/}
;; ;;
b|B) b|B)
builddir="$OPTARG" builddir=${OPTARG/%"/"/}
builddir=${builddir/%"/"/}
;; ;;
o|O) o|O)
resultsdir="$OPTARG" resultsdir=${OPTARG%/}
;; ;;
m|M) m|M)
sim="$OPTARG" containsElement "$OPTARG" "${simulators[@]}"
simargs=() if [[ $? == 1 ]]; then
sim="$OPTARG"
simargs=()
else
echo "Invalid simulator: $OPTARG"
usage
exit 1
fi
;; ;;
x|X) x|X)
bsp="$OPTARG" 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) g|G)
genflag=1 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" echo "Invalid option: -$OPTARG"
usage 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 esac
done 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 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." makefile=$patmosdir/Makefile
exit 1
if [[ "$bitfile" == "" ]]; then
bitfile=$resultsdir/t-crest.bit
fi fi
if [[ ! -d $testsuitedir ]]; then
echo "Invalid testsuite dir. Check if the specified BSP is correct." if [[ "$sim" == "" ]]; then
exit 1 sim="ML605"
elif [[ "$sim" == "pasim" ]]; then
addSimArg "--interrupt=1"
addSimArg "--freq=5"
addSimArg "-v"
fi fi
cd $sourcedir
if [[ $resumeflag == 0 ]]; then if [[ $resumeflag == 0 ]]; then
rm -rf $log rm -rf $log
fi else
if [[ ! -d $resultsdir ]]; then testsOnResume $log
mkdir $resultsdir
fi 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) recurseDirs $(ls -1)
if [[ $genflag == 0 ]]; then if [[ $genflag == 0 ]]; then