Commit 052d64d9 authored by Matthieu Cattin's avatar Matthieu Cattin

test23: now uses gensdbfs to generate the eeprom image.

parent baecd175
......@@ -31,6 +31,7 @@ from fmc_adc import *
"""
test23: Write IPMI information and calibration data to FMC EEPROM.
This is done using gensdbfs tool.
Serial number and calibration data are taken from text files.
Note: Requires test00.py to run first to load the firmware!
......@@ -46,7 +47,11 @@ def main (default_directory='.'):
SERIAL_FILENAME = os.path.join(default_directory, SERIAL_FILENAME)
CALIBR_FILENAME = "calibration_data.txt"
CALIBR_FILENAME = os.path.join(default_directory, CALIBR_FILENAME)
EEPROM_BIN_FILENAME = "eeprom_content.out"
IPMI_BIN_FILENAME = "sdbfs/ipmi.sdb"
IPMI_BIN_FILENAME = os.path.join(default_directory, IPMI_BIN_FILENAME)
CALIBR_BIN_FILENAME = "sdbfs/calibration.sdb"
CALIBR_BIN_FILENAME = os.path.join(default_directory, CALIBR_BIN_FILENAME)
EEPROM_BIN_FILENAME = "sdbfs/eeprom_content.out"
EEPROM_BIN_FILENAME = os.path.join(default_directory, EEPROM_BIN_FILENAME)
EEPROM_SIZE = 8192 # in Bytes
......@@ -93,7 +98,7 @@ def main (default_directory='.'):
print "Current date/time: %d minutes (since 0:00 1/1/96)\n" % current_date
#==================================================
# Read calibration data from file
# Read calibration data from text file
# This file must be written by the test performing the calibration
f_calibr = open(CALIBR_FILENAME, 'r+')
calibr_data = []
......@@ -105,6 +110,14 @@ def main (default_directory='.'):
#for data in calibr_data:
# print "0x%02X" % (data)
#==================================================
# Write calibration data to binary file
# This file will be feed to gensdbfs
f_bin_calibr = open(CALIBR_BIN_FILENAME, 'wb')
for byte in calibr_data:
f_bin_calibr.write(chr(byte))
f_bin_calibr.close()
################################################################################
# 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).
......@@ -174,35 +187,45 @@ def main (default_directory='.'):
oem = OEMRecord(0, 0, 3, 0, 68, 0, 0, 0, 0, 0, 0)
#==================================================
# Internal Use Area
# Takes an array of byte as parameter
iua = InternalUseArea(calibr_data)
#==================================================
# Write eeprom content to a binary file
ipmi_open_file(EEPROM_BIN_FILENAME)
ipmi_set(bia, dcload, dcout, oem, iua)
# Write ipmi content to a binary file
ipmi_open_file(IPMI_BIN_FILENAME)
ipmi_set(bia, dcload, dcout, oem)
ipmi_write()
ipmi_close_file()
#==================================================
# Read eeprom content from binary file
f_eeprom = open(EEPROM_BIN_FILENAME, "rb")
eeprom_data = []
byte = f_eeprom.read(1) # reads one byte
# Read impi content from binary file
f_ipmi = open(IPMI_BIN_FILENAME, "rb")
ipmi_data = []
byte = f_ipmi.read(1) # reads one byte
while byte:
eeprom_data.append(ord(byte))
byte = f_eeprom.read(1) # reads one byte
f_eeprom.close()
ipmi_data.append(ord(byte))
byte = f_ipmi.read(1) # reads one byte
f_ipmi.close()
#print "Raw EEPROM data:"
#for data in eeprom_data:
#for data in ipmi_data:
# print "0x%02X" % (data)
#==================================================
# Generate eeprom image with gensdbfs
os.system('gensdbfs sdbfs ' + EEPROM_BIN_FILENAME)
#==================================================
# Read eeprom content from binary file
f_bin_eeprom = open(EEPROM_BIN_FILENAME, "rb")
eeprom_data = []
byte = f_bin_eeprom.read(1) # reads one byte
while byte:
eeprom_data.append(ord(byte))
byte = f_bin_eeprom.read(1) # reads one byte
f_bin_eeprom.close()
#==================================================
# Write content to EEPROM via I2C
print "Write EEPROM content.\n"
fmc.sys_i2c_eeprom_write(eeprom_data)
if eeprom_data != []:
fmc.sys_i2c_eeprom_write(eeprom_data)
#==================================================
# Read back EEPROM content via I2C
......
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