Commit 0139063e authored by Matthieu Cattin's avatar Matthieu Cattin

test31: Improve checking of bad eeprom data.

parent cb18d605
......@@ -131,20 +131,22 @@ def main (default_directory='.'):
for i in range(serial_length):
serial += chr(eeprom_data_read[i+serial_offset])
print("Serial number read from bad EEPROM image: %s"%serial)
if serial == '':
raise PtsCritical("Invalid serial number read in EEPROM!")
BAK_CALIBR_BIN_FILENAME = "calibr_bak/calibr_" + serial + ".bin"
BAK_CALIBR_BIN_FILENAME = os.path.join(default_directory, BAK_CALIBR_BIN_FILENAME)
# Check that the manufacturing date is valid
first_prod_date = datetime.datetime(2013, 3, 4)
diff_date = first_prod_date - ref_date
first_prod_date_min = int(diff_date.total_seconds()//60)
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
raise PtsCritical("No manufacturing date found in the EEPROM!")
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
raise PtsCritical("Date found in the EEPROM is in the future!")
elif(mfg_date_min < first_prod_date_min):
print("Date found in the EEPROM is older than the first production => taking current date: %s\n" % str(current_date))
mfg_date_min = current_date_min
raise PtsCritical("Date found in the EEPROM is older than the first production!")
else:
print("Valid manufacturing date found in EEPROM: %s (will be preserved)\n" % str(mfg_date))
......@@ -241,6 +243,19 @@ P1 Bank A nb signal=%d, P1 Bank B nb signal=%d, P2 Bank A nb signal=%d, P2 Bank
cmd = 'sdb-read -e 0x1000 ' + BAD_EEPROM_BIN_FILENAME + ' calibration.sdb > ' + CALIBR_BIN_FILENAME
print("Exctract calibration binary file from bad EEPROM image, cmd: %s"%(cmd))
os.system(cmd)
cmd = "cp " + CALIBR_BIN_FILENAME + " " + BAK_CALIBR_BIN_FILENAME
print("Copy calibration binary, cmd: %s"%(cmd))
#os.system(cmd)
#==================================================
# Check that valid calibration data were extracted
#==================================================
print("\n==================================================")
print("Check calibration data")
calib_data = open(CALIBR_BIN_FILENAME, "rb").read()
print type(calib_data)
if calib_data == '':
raise PtsCritical("Invalid calibration data read in EEPROM!")
#==================================================
# Generate eeprom image with gensdbfs
......@@ -270,11 +285,6 @@ P1 Bank A nb signal=%d, P1 Bank B nb signal=%d, P2 Bank A nb signal=%d, P2 Bank
print("%02x"%(byte)),
print("\n")
##############################################################################################################################################################
sys.exit()
##############################################################################################################################################################
#==================================================
# Erase EEPROM content
#==================================================
......
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