Commit 22ee294c authored by Pieter Van Trappen's avatar Pieter Van Trappen

fmceeprom - FMC DIO 10i8o modifications done, cli arguments added so it can be…

fmceeprom - FMC DIO 10i8o modifications done, cli arguments added so it can be called easily from pts for each card
parent a02bc9ec
......@@ -5,63 +5,64 @@
# Author: Matthieu Cattin <matthieu.cattin@cern.ch>
# Licence: GPL v2 or later.
# Website: http://www.ohwr.org
# Last modifications: 16/5/2012
# Last modifications: 21/07/2022
# Import system modules
import datetime
import os
import argparse
from fmc_eeprom import *
"""
Tests IPMI formatting library.
def config_parser(parser):
parser.description = "Generate ECA-03287 EEPROM content."
parser.add_argument("serial", nargs="?", default="HCCFFIH01F-CR000001", help="Infor EAM serial number")
parser.add_argument("partno", nargs="?", default="EDA-03287-V5", help="EDA part number")
parser.add_argument("mfg_date", nargs="?", default="18/5/2022", help="Manufacturing date without time")
parser.add_argument("--output", nargs="?", default="eeprom.out", help="EEPROM content (sysfs) file")
parser.set_defaults(handler=main)
"""
def parse_cmd():
parser = argparse.ArgumentParser()
config_parser(parser)
args = parser.parse_args()
args.handler(args)
def main (default_directory='.'):
# Constants declaration
PART_NUMBER = "EDA-02063-V5-0"
SERIAL = "HCCFFIA___-CR000003"
EEPROM_BIN_FILENAME = "eeprom_content.out"
EEPROM_BIN_FILENAME = os.path.join(default_directory, EEPROM_BIN_FILENAME)
EEPROM_SIZE = 8192 # in Bytes
#==================================================
# Serial number
serial = SERIAL
print("Board's serial number: %s\n" % serial)
def main(main_args):
PRODUCT = "FmcDio10i8o"
#==================================================
# Calculate number of minutes since 0:00 1/1/96
now_date = datetime.datetime.now()
mfg_date = datetime.datetime.strptime(main_args.mfg_date, "%d/%m/%Y")
print(f"Manufacturing date/time: {mfg_date}")
ref_date = datetime.datetime(1996, 1, 1)
diff_date = now_date - ref_date
diff_date = mfg_date - ref_date
total_seconds = diff_date.days * 86400 + diff_date.seconds
current_date = int(total_seconds//60)
print("Current date/time: %d minutes (since 0:00 1/1/96)\n" % current_date)
# Manufacturiing date = current date
print("Manufacturing date : %d 0x%06X" % (current_date, current_date))
mfg_date = current_date
mfg_date_min = int(total_seconds//60)
print(f"Manufacturing date in minutes: {mfg_date_min} 0x{mfg_date_min:06x}")
#==================================================
# 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)
now_date = datetime.datetime.now()
print(f"EEPROM content generated: {now_date}")
fru = str(now_date)
product = PRODUCT
print(f"Board's product name: {product}")
serial = main_args.serial
print(f"Board's serial number: {serial}")
partno = main_args.partno
print(f"Board's part number: {partno}")
bia = BoardInfoArea(mfg_date_min, "CERN", product, serial, partno, fru)
#==================================================
# Multirecords 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
dcload0 = DCLoadRecord(0, 2.5, 1.8, 2.5, 0.010, 0, 800) # VADJ
dcload1 = DCLoadRecord(1, 3.3, 3.135, 3.465, 0.010, 0, 3000) # P3V3
dcload2 = DCLoadRecord(2, 12.0, 11.4, 12.6, 0.010, 0, 1000) # P12V
dcload = [ dcload0, dcload1, dcload2 ]
# output number, vnom, vmin, vmax, ripple, imin, imax
......@@ -70,6 +71,7 @@ def main (default_directory='.'):
dcout2 = DCOutputRecord(5, 0.0, 0.0, 0.0, 0.0, 0, 0) # VREF_B_M2C
dcout = [ dcout0, dcout1, dcout2 ]
# OEM Record Subtype 0
# module size : 0=single width, 1=double width
# P1 size : 0=LPC, 1=HPC
# P2 size : 0=LPC, 1=HPC, 3=not fitted
......@@ -81,7 +83,9 @@ def main (default_directory='.'):
# nb GBT P1 : number
# nb GBT P2 : number
# max TCK freq : frequency in MHz
oem = OEMRecord(0, 1, 3, 1, 68, 0, 0, 0, 0, 0, 0)
oem = OEMRecord(0, 0, 3, 1, 68, 0, 0, 0, 0, 0, 0)
# OEM Record Subtype 1 (I2C Device Defenition), optional - not used
#==================================================
# Internal Use Area
......@@ -91,15 +95,18 @@ def main (default_directory='.'):
#==================================================
# Write eeprom content to a binary file
ipmi_open_file(EEPROM_BIN_FILENAME)
eeprom_fn = main_args.output
print(f"Writing to {eeprom_fn}..")
ipmi_open_file(eeprom_fn)
#ipmi_set(bia, dcload, dcout, oem, iua)
ipmi_set(bia, dcload, dcout, oem)
ipmi_write()
ipmi_close_file()
print("Done!\n")
#==================================================
# Read eeprom content from binary file
f_eeprom = open(EEPROM_BIN_FILENAME, "rb")
f_eeprom = open(eeprom_fn, "rb")
eeprom_data = []
byte = f_eeprom.read(1) # reads one byte
while byte:
......@@ -118,20 +125,5 @@ def main (default_directory='.'):
if i%8 == 0:
print("")
print("\n")
dsum = 0
for data in eeprom_data[158:162]:
dsum += data
print(("0x%02X 0x%X" % (data, dsum)))
print(("\n\nsum: 0x%02X" % dsum))
checksum = (0xff & (1 + ~dsum))
print(("calculated checksum: 0x%02X" % checksum))
print(("data checksum : 0x%02X" % eeprom_data[162]))
print("")
print(("check data: 0x%02X" % (dsum + eeprom_data[162])))
print(("check data: 0x%02X" % (dsum + checksum)))
if __name__ == '__main__' :
main()
parse_cmd()
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