Commit 6c44b76e authored by Matthieu Cattin's avatar Matthieu Cattin

test23: Fix bug in mfg date check, more verbose to log.

Was keeping mfg date even if it was 0xffffff (uninitialised eeprom), or bigger than current date.
parent 47acd171
......@@ -43,6 +43,8 @@ def main (default_directory='.'):
# Constants declaration
TEST_NB = 23
EXPECTED_BITSTREAM_TYPE = 0x1
MANUFACTURER = "CERN"
PRODUCT_NAME = "FmcAdc100m14b4cha"
PART_NUMBER = "EDA-02063-V5-0"
SERIAL_FILENAME = "../../../serial.txt"
SERIAL_FILENAME = os.path.join(default_directory, SERIAL_FILENAME)
......@@ -91,11 +93,12 @@ def main (default_directory='.'):
#==================================================
# Calculate number of minutes since 0:00 1/1/96
now_date = datetime.datetime.now()
current_date = datetime.datetime.now()
ref_date = datetime.datetime(1996, 1, 1)
diff_date = now_date - ref_date
current_date = int(diff_date.total_seconds()//60)
print "Current date/time: %d minutes (since 0:00 1/1/96)\n" % current_date
diff_date = current_date - ref_date
current_date_min = int(diff_date.total_seconds()//60)
print("Current date/time: %s"%(str(current_date)))
print(" -> 0x%06X = %d minutes (since 0:00 1/1/96)\n" % (current_date_min, current_date_min))
#==================================================
# Read calibration data from text file
......@@ -140,38 +143,70 @@ def main (default_directory='.'):
f_eeprom.close()
# Get manufacturing date from EEPROM data, if exists
print "Get manufacturing date from EEPROM."
eeprom_data = open(EEPROM_BIN_FILENAME, "rb").read()
mfg_date = ipmi_get_mfg_date(eeprom_data)
mfg_date_min = ipmi_get_mfg_date(eeprom_data)
ref_date = datetime.datetime(1996, 1, 1)
mfg_date = ref_date + datetime.timedelta(minutes=mfg_date_min)
print("Mfg date read from eeprom: %s"%(str(mfg_date)))
print(" -> 0x%06X = %d minutes (since 0:00 1/1/96)\n"%(mfg_date_min, mfg_date_min))
# No manufacturing date present in EEPROM, put the current date
if(mfg_date == 0):
print "No manufacturing date found in the EEPROM, taking current date: %d" % current_date
mfg_date = current_date
if(mfg_date_min == 0 | mfg_date_min == 0xffffff):
print("No manufacturing date found in the EEPROM => taking current date: %s\n" % str(current_date))
mfg_date_min = current_date_min
elif(mfg_date_min > current_date_min):
print("Date found in the EEPROM is in the future => taking current date: %s\n" % str(current_date))
mfg_date_min = current_date_min
else:
print "Manufacturing date found in EEPROM: %d (will be preserved)\n" % mfg_date
print("Valid manufacturing date found in EEPROM: %s (will be preserved)\n" % str(mfg_date))
#==================================================
# Create Board Info Area
# 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, ...)
print "EEPROM content generated: %s\n" % now_date
fru = "%s" % now_date
bia = BoardInfoArea(mfg_date, "CERN", "FmcAdc100m14b4cha", serial, PART_NUMBER, fru)
print("EEPROM content generation date: %s\n" % str(current_date))
print("IPMI: Board Info Area")
print(" - Mfg. Date/Time : 0x%06X" % mfg_date_min)
print(" - Board Manufacturer : %s" % MANUFACTURER)
print(" - Board Product Name : %s" % PRODUCT_NAME)
print(" - Board Serial Number: %s" % serial)
print(" - Board Part Number : %s" % PART_NUMBER)
print(" - FRU File ID : %s" % str(current_date))
print("")
fru = "%s" % str(current_date)
bia = BoardInfoArea(mfg_date_min, MANUFACTURER, PRODUCT_NAME, serial, PART_NUMBER, fru)
#==================================================
# Multirecords Area
print("IPMI: Multi-record area")
# output number, vnom, vmin, vmax, ripple, imin, imax
dcload0 = DCLoadRecord(0, 2.5, 2.375, 2.625, 0.0, 0, 4000) # VADJ
dcload1 = DCLoadRecord(1, 3.3, 3.135, 3.465, 0.0, 0, 3000) # P3V3
dcload2 = DCLoadRecord(2, 12.0, 11.4, 12.6, 0.0, 0, 1000) # P12V
vnom=2.5; vmin=2.375; vmax=2.625; ripple=0.0; imin=0; imax=4000
print(" - DC Load (VADJ): vnom=%2.3fV, vmin=%2.3fV, vmax=%2.3fV, ripple=%2.3fV, imin=%dmA, imax=%dmA"%(vnom, vmin, vmax, ripple, imin, imax))
dcload0 = DCLoadRecord(0, vnom, vmin, vmax, ripple, imin, imax) # VADJ
vnom=3.3; vmin=3.135; vmax=3.465; ripple=0.0; imin=0; imax=3000
print(" - DC Load (P3V3): vnom=%2.3fV, vmin=%2.3fV, vmax=%2.3fV, ripple=%2.3fV, imin=%dmA, imax=%dmA"%(vnom, vmin, vmax, ripple, imin, imax))
dcload1 = DCLoadRecord(1, vnom, vmin, vmax, ripple, imin, imax) # P3V3
vnom=12.0; vmin=11.4; vmax=12.6; ripple=0.0; imin=0; imax=1000
print(" - DC Load (P12V): vnom=%2.3fV, vmin=%2.3fV, vmax=%2.3fV, ripple=%2.3fV, imin=%dmA, imax=%dmA"%(vnom, vmin, vmax, ripple, imin, imax))
dcload2 = DCLoadRecord(2, vnom, vmin, vmax, ripple, imin, imax) # P12V
dcload = [ dcload0, dcload1, dcload2 ]
# output number, vnom, vmin, vmax, ripple, imin, imax
dcout0 = DCOutputRecord(3, 0.0, 0.0, 0.0, 0.0, 0, 0) # VIO_B_M2C
dcout1 = DCOutputRecord(4, 0.0, 0.0, 0.0, 0.0, 0, 0) # VREF_A_M2C
dcout2 = DCOutputRecord(5, 0.0, 0.0, 0.0, 0.0, 0, 0) # VREF_B_M2C
vnom=0.0; vmin=0.0; vmax=0.0; ripple=0.0; imin=0; imax=0
print(" - DC Out (VIO_B_M2C): vnom=%2.3fV, vmin=%2.3fV, vmax=%2.3fV, ripple=%2.3fV, imin=%dmA, imax=%dmA"%(vnom, vmin, vmax, ripple, imin, imax))
dcout0 = DCOutputRecord(3, vnom, vmin, vmax, ripple, imin, imax) # VIO_B_M2C
print(" - DC Out (VREF_A_M2C): vnom=%2.3fV, vmin=%2.3fV, vmax=%2.3fV, ripple=%2.3fV, imin=%dmA, imax=%dmA"%(vnom, vmin, vmax, ripple, imin, imax))
dcout1 = DCOutputRecord(4, vnom, vmin, vmax, ripple, imin, imax) # VREF_A_M2C
print(" - DC Out (VREF_B_M2C): vnom=%2.3fV, vmin=%2.3fV, vmax=%2.3fV, ripple=%2.3fV, imin=%dmA, imax=%dmA"%(vnom, vmin, vmax, ripple, imin, imax))
dcout2 = DCOutputRecord(5, vnom, vmin, vmax, ripple, imin, imax) # VREF_B_M2C
dcout = [ dcout0, dcout1, dcout2 ]
# module size : 0=single width, 1=double width
......@@ -185,10 +220,14 @@ def main (default_directory='.'):
# nb GBT P1 : number
# nb GBT P2 : number
# max TCK freq : frequency in MHz
oem = OEMRecord(0, 0, 3, 0, 68, 0, 0, 0, 0, 0, 0)
size=0; p1_size=0; p2_size=3; clk_dir=0; sig_p1_a=68; sig_p1_b=0; sig_p2_a=0; sig_p2_b=0; gbt_p1=0; gbt_p2=0; tck=0
print(" - OEM: Module Size=%d, P1 Connector Size=%d, P2 Connector Size=%d, Clock Direction=%d, \
P1 Bank A nb signal=%d, P1 Bank B nb signal=%d, P2 Bank A nb signal=%d, P2 Bank B nb signal=%d, P1 GBT nb=%d, P2 GBT nb=%d, TCK max freq=%d\n"%(size, p1_size, p2_size, clk_dir, sig_p1_a, sig_p1_b, sig_p2_a, sig_p2_b, gbt_p1, gbt_p2, tck))
oem = OEMRecord(size, p1_size, p2_size, clk_dir, sig_p1_a, sig_p1_b, sig_p2_a, sig_p2_b, gbt_p1, gbt_p2, tck)
#==================================================
# Write ipmi content to a binary file
print("Generate binary file with IPMI crap.\n")
ipmi_open_file(IPMI_BIN_FILENAME)
ipmi_set(bia, dcload, dcout, oem)
ipmi_write()
......@@ -211,7 +250,7 @@ def main (default_directory='.'):
#==================================================
# Generate eeprom image with gensdbfs
cmd = "gensdbfs " + SDBFS_DIR + " " + EEPROM_BIN_FILENAME
print("Generate eeprom image, cmd: %s"%(cmd))
print("Generate eeprom image, cmd: %s\n"%(cmd))
os.system(cmd)
#==================================================
......@@ -230,6 +269,16 @@ def main (default_directory='.'):
byte = f_bin_eeprom.read(1) # reads one byte
f_bin_eeprom.close()
#==================================================
# Dump EEPROM content to log
print("Content to be written to the eeprom (length=0x%X (%d)):"%(len(eeprom_data), len(eeprom_data)))
for i in range(len(eeprom_data)/16):
print("0x%04X"%(i*16)),
for j in range(16):
print("%02X"%eeprom_data[(i*16)+j]),
print("")
print("")
#==================================================
# Write content to EEPROM via I2C
print "Write EEPROM content.\n"
......@@ -250,7 +299,7 @@ def main (default_directory='.'):
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 => ",
print "EEPROM content comparison => ",
if(mismatch == 0):
print "OK"
else:
......
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