Commit 0e40da5a authored by Matthieu Cattin's avatar Matthieu Cattin

test23: Use EDA number as part_number, use current date as FRU.

Improve content comparison report.
parent ab45ec95
...@@ -40,6 +40,7 @@ def main (default_directory='.'): ...@@ -40,6 +40,7 @@ def main (default_directory='.'):
# Constants declaration # Constants declaration
TEST_NB = 23 TEST_NB = 23
EXPECTED_BITSTREAM_TYPE = 0x1 EXPECTED_BITSTREAM_TYPE = 0x1
PART_NUMBER = "EDA-02063-V5-0"
SERIAL_FILENAME = "../../../serial.txt" SERIAL_FILENAME = "../../../serial.txt"
SERIAL_FILENAME = os.path.join(default_directory, SERIAL_FILENAME) SERIAL_FILENAME = os.path.join(default_directory, SERIAL_FILENAME)
CALIBR_FILENAME = "calibration_data.txt" CALIBR_FILENAME = "calibration_data.txt"
...@@ -87,7 +88,7 @@ def main (default_directory='.'): ...@@ -87,7 +88,7 @@ def main (default_directory='.'):
ref_date = datetime.datetime(1996, 1, 1) ref_date = datetime.datetime(1996, 1, 1)
diff_date = now_date - ref_date diff_date = now_date - ref_date
current_date = int(diff_date.total_seconds()//60) current_date = int(diff_date.total_seconds()//60)
print "Mfg date/time: %d minutes (since 0:00 1/1/96)\n" % current_date print "Current date/time: %d minutes (since 0:00 1/1/96)\n" % current_date
#================================================== #==================================================
# Read calibration data from file # Read calibration data from file
...@@ -98,32 +99,32 @@ def main (default_directory='.'): ...@@ -98,32 +99,32 @@ def main (default_directory='.'):
calibr_data.append(0xFF & int(line, 16)) calibr_data.append(0xFF & int(line, 16))
calibr_data.append(0xFF & (int(line, 16) >> 8)) calibr_data.append(0xFF & (int(line, 16) >> 8))
f_calibr.close() f_calibr.close()
print "Raw calibration data:" #print "Raw calibration data:"
for data in calibr_data: #for data in calibr_data:
print "0x%02X" % (data) # print "0x%02X" % (data)
################################################################################ ################################################################################
# CHECK IF A MANUFACTURING DATE IS PRESENT IN THE EEPROM. # Check if a manufacturing date is present in the EEPROM.
# IF NOT, PUT THE CURRENT DATE (IT MEANS IT'S THE FIRST TIME THE TEST IS RUN). # If not, put the current date (it means it's the first time the test is run).
# IF A DATE IS PRESENT, KEEP IT. # If a date is present, keep it.
# EEPROM clear code used to test the test! # EEPROM clear code used to test the test!
#eeprom_data = [0x0] * EEPROM_SIZE #eeprom_data = [0x0] * EEPROM_SIZE
#fmc.sys_i2c_eeprom_write(eeprom_data) #fmc.sys_i2c_eeprom_write(eeprom_data)
# Read entire EEPROM # Read entire EEPROM
print "Read EEPROM content." #print "Read EEPROM content."
eeprom_data_read = fmc.sys_i2c_eeprom_read(0, EEPROM_SIZE) eeprom_data_read = fmc.sys_i2c_eeprom_read(0, EEPROM_SIZE)
# Write EEPROM data to binary file # Write EEPROM data to binary file
print "Write EEPROM content to file (binary)." #print "Write EEPROM content to file (binary)."
f_eeprom = open(EEPROM_BIN_FILENAME, "wb") f_eeprom = open(EEPROM_BIN_FILENAME, "wb")
for byte in eeprom_data_read: for byte in eeprom_data_read:
f_eeprom.write(chr(byte)) f_eeprom.write(chr(byte))
f_eeprom.close() f_eeprom.close()
# Get manufacturing date from EEPROM data, if exists # Get manufacturing date from EEPROM data, if exists
print "Get manufacturing date from binary file." print "Get manufacturing date from EEPROM."
eeprom_data = open(EEPROM_BIN_FILENAME, "rb").read() eeprom_data = open(EEPROM_BIN_FILENAME, "rb").read()
mfg_date = ipmi_get_mfg_date(eeprom_data) mfg_date = ipmi_get_mfg_date(eeprom_data)
...@@ -132,13 +133,15 @@ def main (default_directory='.'): ...@@ -132,13 +133,15 @@ def main (default_directory='.'):
print "No manufacturing date found in the EEPROM, taking current date: %d" % current_date print "No manufacturing date found in the EEPROM, taking current date: %d" % current_date
mfg_date = current_date mfg_date = current_date
else: else:
print "Manufacturing date found in EEPROM: %d" % mfg_date print "Manufacturing date found in EEPROM: %d (will be preserved)\n" % mfg_date
#================================================== #==================================================
# Create Board Info Area # Create Board Info Area
# FRU field is used to store the date of generation of the eeprom content # FRU field is used to store the date of generation of the eeprom content
# This could be used later to determine if the content has to be udated (bug fix, ...) # This could be used later to determine if the content has to be udated (bug fix, ...)
bia = BoardInfoArea(mfg_date, "CERN", "FmcAdc100m14b4cha", serial, "part number", "fru") print "EEPROM content generated: %s\n" % now_date
fru = "%s" % now_date
bia = BoardInfoArea(mfg_date, "CERN", "FmcAdc100m14b4cha", serial, PART_NUMBER, fru)
#================================================== #==================================================
# Multirecords Area # Multirecords Area
...@@ -196,12 +199,13 @@ def main (default_directory='.'): ...@@ -196,12 +199,13 @@ def main (default_directory='.'):
#================================================== #==================================================
# Write content to EEPROM via I2C # Write content to EEPROM via I2C
print "Write EEPROM content.\n"
fmc.sys_i2c_eeprom_write(eeprom_data) fmc.sys_i2c_eeprom_write(eeprom_data)
#================================================== #==================================================
# Read back EEPROM content via I2C # Read back EEPROM content via I2C
eeprom_data_read = fmc.sys_i2c_eeprom_read(0, len(eeprom_data)) eeprom_data_read = fmc.sys_i2c_eeprom_read(0, len(eeprom_data))
print "EEPROM content comparision" mismatch = 0
for i in range(len(eeprom_data)): for i in range(len(eeprom_data)):
wr_data = eeprom_data[i] wr_data = eeprom_data[i]
rd_data = eeprom_data_read[i] rd_data = eeprom_data_read[i]
...@@ -209,10 +213,18 @@ def main (default_directory='.'): ...@@ -209,10 +213,18 @@ def main (default_directory='.'):
check = "OK" check = "OK"
else: else:
check = "FAILED" check = "FAILED"
print "0x%02X 0x%02X => %s" % (wr_data, rd_data, check) mismatch += 1
print "0x%02X 0x%02X => %s" % (wr_data, rd_data, check)
#print "0x%02X 0x%02X => %s" % (wr_data, rd_data, check)
print "EEPROM content comparision => ",
if(mismatch == 0):
print "OK"
else:
print "FAILED"
raise PtsError("EEPROM comparison failed: %d mismatch found." % mismatch)
except FmcAdc100mOperationError as e: except FmcAdc100mOperationError as e:
raise PtsError("test failed: %s" % e) raise PtsError("Test failed: %s" % e)
########################################################################### ###########################################################################
......
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