Commit 98c5a3ef authored by Matthieu Cattin's avatar Matthieu Cattin

test02: Save eeprom content before test and restore it after. Test area at offset 0x1000.

parent 4bf4e899
......@@ -27,13 +27,17 @@ test02: Test EEPROM access
Note: Requires to run first to load the gateware!
def pattern_compare(fmc, pattern):
print "Write data pattern to EEPROM\n"
def pattern_compare(fmc, offset, pattern):
print "Write data pattern to EEPROM at offset 0x%4X\n" % offset
#print [hex(a) for a in pattern]
fmc.eeprom_24aa64.wr_page(offset, pattern)
print "Read back data from EEPROM\n"
rd_pattern = fmc.sys_i2c_eeprom_read(0x0, len(pattern))
#rd_pattern = fmc.sys_i2c_eeprom_read(0x0, len(pattern))
#print [hex(a) for a in rd_pattern]
rd_pattern = fmc.eeprom_24aa64.rd_seq(offset, len(pattern))
print "Data comparison:"
print "written read => result"
mismatch = 0
......@@ -55,6 +59,7 @@ def main (default_directory='.'):
PATTERN_A = [0x55, 0xAA, 0x00, 0xFF]
PATTERN_B = [0xAA, 0x55, 0xFF, 0x00]
start_test_time = time.time()
......@@ -91,11 +96,18 @@ def main (default_directory='.'):
if(EEPROM_ADDR != periph_addr[0]):
error = "Wrong device mounted on system management I2C bus or soldering issues, address is:0x%.2X expected:0x%.2X" % (periph_addr[0],EEPROM_ADDR)
# Save content of the area used for the test
print('Saving test area eeprom content.')
area_content = fmc.eeprom_24aa64.rd_seq(WRITE_OFFSET, len(PATTERN_A))
print [("0x%02X"%a) for a in area_content]
# Write, read back and compare two different patterns
mismatch = 0
mismatch += pattern_compare(fmc, PATTERN_A)
mismatch += pattern_compare(fmc, PATTERN_B)
mismatch += pattern_compare(fmc, WRITE_OFFSET, PATTERN_A)
mismatch += pattern_compare(fmc, WRITE_OFFSET, PATTERN_B)
except FmcAdc100mOperationError as e:
raise PtsError("EEPROM write/read/compare test failed: %s" % e)
......@@ -104,6 +116,10 @@ def main (default_directory='.'):
print('Data comparison OK.')
# Restores the saved content to the area used for test
print('\nRestoring test area eeprom content.')
fmc.eeprom_24aa64.wr_page(WRITE_OFFSET, area_content)
print ""
print "==> End of test%02d" % TEST_NB
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