Commit 7f6c32bc authored by Benoit Rat's avatar Benoit Rat

dio: add test99 that write valid FRU at the end of the test

Add the serial_prefix for Seven Solutions in order to ease the
operator to write correct value. This serial prefix is only used
when the input serial is composed by 3 digits.
parent aecd624a
......@@ -7,14 +7,16 @@
# Website: http://www.sevensols.com
# Version: 1.0 (Last modifications: 29/4/2012)
LOGDIR=./log_fmcdio5chttla
SCRIPDIR=$(cd $(dirname $0); pwd)
LOGDIR=${SCRIPDIR}/log_fmcdio5chttla
mkdir -p $LOGDIR
sudo rm -fr $LOGDIR/pts*
serial=$1
if [ x$1 = x"" ]; then
echo -n "Please scan CERN serial number bar-code, then press [ENTER]: "
echo -n "Please scan CERN serial number bar-code or write 3 last digits, then press [ENTER]: "
read serial
fi
......@@ -30,7 +32,7 @@ echo $serial >> serial.txt
extra_serial=$2
if [ x$2 = x"" ]; then
echo -n "If needed, input extra serial number and press [ENTER], OR just press [ENTER]: "
echo -n "If needed, input extra/batch serial number (i.e,S04) and press [ENTER], OR just press [ENTER]: "
read extra_serial
fi
......@@ -49,8 +51,12 @@ do
echo "Test series run $nb_test out of $nb_test_limit"
echo " "
## Run the various test
sudo ./pts.py -b FMC-DIO-5chTTLa -s $serial -e $extra_serial -t./test/fmcdio5chttla/python -l $LOGDIR 00 01 02 03 04 05 06 07 08
## Write valid FRU in EEPROM
sudo ./test/fmcdio5chttla/python/test99_eeprom.py -s $serial -e $extra_serial -l $LOGDIR
if [ "$nb_test" != "$nb_test_limit" ]
then
echo " "
......
#! /usr/bin/env python
# coding: utf8
# Copyright Seven Solutions, 2014
# Author: Benoit Rat
# Licence: GPL v2 or later.
# Website: http://www.sevensols.com
import sys
import rr
import os
import getopt
import re
from ptsexcept import *
from dio_fmc import *
from eeprom_24aa64 import *
PYDIR=os.path.dirname(os.path.abspath(__file__))+"/"
PYNAME="test99_eeprom"
"""
test99_eeprom: Write Valid ID to FMC DIO EEPROM at the end of the test
You will also need to compile the library for your system by executing
make -C test/fmceeprom/python/libipmi
Note: Requires test00.py and test02.py to success!
"""
class test99_frueeprom:
FRU_VENDOR="CERN"
FRU_NAME="FmcDio5cha"
FRU_PART="EDA-02408-V2-0"
FRU_OFFSET=0x00
FRU_OUTPUT="/tmp/fmcdio_eeprom.data"
FRU_BIN=PYDIR+"../../fmceeprom/python/fru-generator"
SN_CONFIG=PYDIR + "../serial_prefix.config"
def __init__(self, spec):
""" check FMC PRESENT-pin state """
try:
self.dio = CFmcDio(spec, 0x80000, False, True, False)
except CFmcDioError as e:
err_msg="While fmc-dio-5chttla initialization: "+str(e)
if e.bus_name == "FMC":
raise PtsCritical(err_msg) # Critical error: the fmc-dio-5chttl-board is apparently not present
else:
raise PtsError(err_msg) # Non-critical error: further tests could be performed successfully
def createSN_data(self,sn_input, sn_extra=""):
## If we use only 3 last digits we load the SN using config file
if (re.compile('[0-9]{1,3}').match(sn_input)):
f_serial = open(self.SN_CONFIG, 'r+')
sn_prefix = f_serial.readline()
f_serial.close()
sn_prefix = sn_prefix[:-1] # remove EOL char
if sn_extra != "0000":
print sn_extra
sn_prefix=sn_prefix[:sn_prefix.rfind("-")]+"-"+sn_extra #Remove the last part behind '-' (i.e, -S02)
serial = sn_prefix +"_"+ sn_input
else:
serial=sn_input
print "serial number: %s"%serial
############################################################################
# Format FMC EEPROM data
############################################################################
print "Creating FMC EEPROM data"
cmd="python %s -v %s -n %s -p %s -s %s -o %s" % (self.FRU_BIN,self.FRU_VENDOR, self.FRU_NAME, self.FRU_PART,serial,self.FRU_OUTPUT)
print cmd
os.system(cmd)
def writecheckdata(self):
############################################################################
# Write data to FMC EEPROM
############################################################################
fin = open(self.FRU_OUTPUT,"rb")
fru_data=list(bytearray(fin.read()))
fru_data_bsize=len(fru_data)
#print fru_data
print "Writing FMC EEPROM FRU data (%d bytes)" % (fru_data_bsize)
for i in range(fru_data_bsize/32):
#print "%d [%d:%d]" %(i,i*32,(i+1)*32)
print ".",
self.dio.wr_eeprom(self.FRU_OFFSET+i*32,fru_data[i*32:(i+1)*32])
time.sleep(0.1)
if (i+1)*32<fru_data_bsize:
i=i+1
#print "%d [%d:%d]" %(i,i*32,(i+1)*32)
self.dio.wr_eeprom(self.FRU_OFFSET+i*32,fru_data[i*32:])
############################################################################
# Verify EEPROM data
############################################################################
time.sleep(0.1)
if fru_data_bsize != 0:
eeprom_content_read = self.dio.rd_eeprom(self.FRU_OFFSET,fru_data_bsize)
error = 0
for i in range(fru_data_bsize):
if fru_data[i] != eeprom_content_read[i]:
print "[ERROR] eeprom data corruption @ addr:%d expect:0x%.2X (%c) read:0x%.2X (%c)"%(i, fru_data[i], fru_data[i], eeprom_content_read[i], eeprom_content_read[i])
error += 1
if error == 0:
print "Data verification OK!"
def main(argv0, argv):
SERIAL=000
EXTRA=0000
try:
opts,args = getopt.getopt(sys.argv[1:],"s:e:l:h",["help"])
except getopt.GetoptError as e:
print "%s: wrong arguments %s " % (PYNAME,e)
for opt, arg in opts:
if opt == '-s':
SERIAL = arg
if opt == '-e':
EXTRA = arg
default_directory=PYDIR
# Configure the FPGA using the program fpga_loader
path_fpga_loader = '../firmwares/fpga_loader'
path_firmware = '../firmwares/spec_top.bin'
firmware_loader = os.path.join(default_directory, path_fpga_loader)
bitstream = os.path.join(default_directory, path_firmware)
print "Loading firmware: %s" % (firmware_loader + ' ' + bitstream)
os.system( firmware_loader + ' ' + bitstream )
# Load board library and open the corresponding device
print "Loading hardware access library and opening device\n"
spec = rr.Gennum()
print PYNAME + " start"
init_test_time = time.time()
print "Configuring and checking fmc-dio-5chttla devices"
test=test99_frueeprom(spec)
test.createSN_data(SERIAL,EXTRA)
ret_error=test.writecheckdata()
end_test_time = time.time()
print "\nEnd of " + PYNAME
print "RESULT: [{}]".format("FAIL" if ret_error and ret_error[0]=="E" else ("OK with warnings" if ret_error and ret_error[0]=="W" else "OK"))
print PYNAME + ' elapsed time: {:.2f} seconds'.format(end_test_time-init_test_time)
if ret_error:
if ret_error[0]=="W": # Warning message returned by test funciton
raise PtsWarning(ret_error[1])
else: # Error message returned by test funciton
raise PtsError(ret_error[1])
if __name__ == "__main__":
main(sys.argv[0], sys.argv[1:])
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