Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
#######################################################################
####################### Make sure that run as root ####################
#######################################################################
if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit
fi
#######################################################################
###################### Setting project paths ##########################
#######################################################################
topdirname="fmcmasterfip"
projectpath="."
LOGDIR="${HOME}/Desktop/pts_log/fmcmasterfip"
#######################################################################
############# Getting absolute path for project #######################
#######################################################################
if [ -n "$1" ]
then
top="$1"
else
prg=$0
if [ ! -e "$prg" ]; then
case $prg in
(*/*) exit 1;;
(*) prg=$(command -v -- "$prg") || exit;;
esac
fi
dir=$(
cd -P -- "$(dirname -- "$prg")" && pwd -P
) || exit
prg=$dir/$(basename -- "$prg") || exit
Marek Gumiński
committed
top=$prg
while true
do
if [ `basename "$top"` == "$topdirname" ]
then
break;
else
top=`dirname "$top"`
fi
done
fi
# path verification
if [ ! -d "${top}/${projectpath}/software" ]; then
echo "Couldn't find project path!"
echo "Please make sure that top directory of PtsFmcMastrefip is called \"${topdirname}\""
exit 1
fi
Marek Gumiński
committed
echo "Identified $top as FMC masterFip top directory"
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#######################################################################
####################### Drivers management ############################
#######################################################################
# remove drivers
# in order to make sure that tests will be run
# with correct driver versions
rmmod fmc_adc_100m14b 2> /dev/null
rmmod zio 2> /dev/null
rmmod rawrabbit 2> /dev/null
rmmod spec 2> /dev/null
rmmod fmc 2> /dev/null
rmmod cp210x 2> /dev/null
sleep 1
# load precompiled drivers with known verson
insmod "${top}/${projectpath}/software/fmc-bus/kernel/fmc.ko"
insmod "${top}/${projectpath}/software/spec-sw/kernel/spec.ko" "fw_name=../../${top}/${projectpath}/gateware/spec-init.bin-2012-12-14"
insmod "${top}/${projectpath}/software/zio/zio.ko"
insmod "${top}/${projectpath}/software/fmc-adc-100m14b4cha-sw/kernel/fmc-adc-100m14b.ko" "gateware=../../${top}/${projectpath}/gateware/syn/spec/spec_top_fmc_masterfip.bin"
modprobe usbserial
insmod "${top}/${projectpath}/software/cp210x/cp210x.ko"
#######################################################################
############################## Logging ################################
#######################################################################
# create log directories
mkdir -p "$LOGDIR"
mkdir -p "$LOGDIR/eeprom"
mkdir -p "$LOGDIR/adcdata"
# get board serial
serial=0000
extra_serial=0000
serial=$1
if [ x$1 = x"" ]; then
echo -n "Please scan CERN serial number bar-code, then press [ENTER]: "
read serial
fi
if [ x$serial = x"" ]; then
serial=0000
fi
extra_serial=$2
if [ x$2 = x"" ]; then
echo -n "If needed input extra serial number and press [ENTER] OR just press [ENTER]: "
read extra_serial
fi
if [ x$extra_serial = x"" ]; then
extra_serial=0000
fi
echo " "
nb_test_limit=2
nb_test=1
# leftovers from previous tests
rm -f "/tmp/mfdata_*"
#######################################################################
############################## Testing ###############################
#######################################################################
while [ "$nb_test" -le "$nb_test_limit" ]
do
echo "--------------------------------------------------------------"
echo "Test series run $nb_test out of $nb_test_limit"
echo " "
# run tests
sudo ${top}/pts/ptsFip.py -b FmcMasterFip -s $serial -e $extra_serial -t../python -l $LOGDIR 00 01 02 04 05 06
# backup eeprom image
if [ -f /tmp/eeprom ]
then
cp "/tmp/eeprom" "${LOGDIR}/eeprom/${serial}_${extra_serial}_eeprom"
else
echo "Did not find eeprom image."
fi
# backup adc samples contents
if [ `ls /tmp/mfdata_* 2>/dev/null | wc -l` -ne 0 ]
then
for f in `ls /tmp/mfdata_*`
do
topic=`sed 's/\/tmp\/mfdata_//' <<< $f`
newname="${serial}_${extra_serial}_${topic}"
cp $f "${LOGDIR}/adcdata/${newname}"
done
echo "ADC samples backed up in ${LOGDIR}/adcdata"
else
echo "Did not find any ADC samples to backup"
fi
# repeat test?
if [ "$nb_test" != "$nb_test_limit" ]
then
echo " "
echo -n "Do you want to run the test series again [y,n]? "
read reply
if [ "$reply" != "y" ]
then
break
fi
fi
nb_test=$(($nb_test+1))
done
echo "--------------------------------------------------------------"
echo " "
echo -n "End of the test, do you want to switch the computer OFF? [y,n]"
read reply
if [ "$reply" = "y" ]
then
sudo poweroff