Commit 70996edc authored by Benoit Rat's avatar Benoit Rat

script: add function to ease writting eeprom

parent cf5c34c4
......@@ -133,6 +133,48 @@ checkdrv()
}
weeprom()
{
##Compile the fru generator lib
if ! (test -f ${scriptdir}/../spec-sw/fmc-bus/tools/libipmi/libipmi.so); then
make -C ${scriptdir}/../spec-sw/fmc-bus/tools/libipmi/
fi
i=0
cd /sys/bus/fmc/devices/
echo "Found" $(ls | grep fmc- | wc -w) "FMC board(s) with empty EEPROM"
for fmc in $(ls | grep fmc-); do
i=$(($i + 1))
sn=$(eval echo "\${${i}}")
##echo "#$i: fmc=$fmc S/N=$sn"
##Ask user about the SN
while [ "x"$(echo $sn | grep "^\([0-9]\{1,2\}-\)\?[0-9]\{1,3\}$") = "x" ]; do
read -p "Enter S/N for board ${fmc} in the format xx-XXX (or 0) : " sn
done
## Parse it
if (echo ${sn} | grep "-" > /dev/null); then
sn=$(echo ${sn} | awk -F"-" '{ print "7S-DIO-v2-S" $1 "-" $2 }')
else
sn=$(printf "7S-DIO-v2-S00-%03d" ${sn})
fi
echo "Writing eeprom with S/N: ${sn} ..."
## Write EEPROM file
${scriptdir}/../spec-sw/fmc-bus/tools/fru-generator \
-v "CERN" -n "FmcDio5cha" -p "EDA-02408-V2-0" -s ${sn} > /tmp/fmc-dio-eeprom.bin
## Write to device
cat /tmp/fmc-dio-eeprom.bin > /sys/bus/fmc/devices/${fmc}/eeprom
if [ $? -eq 0 ]; then echo "Done"; fi
done
}
done
}
### Load module
loadmodule()
{
......@@ -208,6 +250,7 @@ Options:
-f|--fetch) Fetch files only
-i|--install) Install the gateware for the driver (require sudo)
-l|--load) Load modules in kernel (require sudo)
-w|--weeprom [sn1 [sn2] ...]) Write fmc eeprom with the given serial number for each slots
--insert) Insert modules in kernel (require sudo)
--report) Make everything and generate report.log
EOF
......@@ -229,6 +272,7 @@ while [ $# -gt 0 ]; do # Until you run out of parameters . . .
-f|--fetch) fetch; exit;;
-i|--install) insthdl; exit;;
-l|--load) loadmodule; exit;;
-w|--weeprom) weeprom $2 $3 $4 $5 $6; exit;;
--insert) insertmodule; exit;;
--report) reportlog; exit;;
*) help;;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment