Commit 4c799bc0 authored by Theodor-Adrian Stana's avatar Theodor-Adrian Stana

sw: Finished work on flash test

parent 3344589e
......@@ -53,7 +53,6 @@ from ptsexcept import *
from vv_pts import *
from ptsdefine import *
##-------------------------------------------------------------------------------------------------
## main --
##-------------------------------------------------------------------------------------------------
......@@ -61,23 +60,93 @@ from ptsdefine import *
def main(bus,tname,inf,log):
"""
tests : EEPROM chip IC62
uses : release.bit and flash_test.py
tests : Flash chip IC62
uses : golden-v0.0_release-v1.0.bit and flashtest.py
"""
pel = PTS_ERROR_LOGGER(inf,log)
try:
# Get board ID and convert it to string
bid = bus.vv_read(0x00)
bid = binascii.unhexlify("%s" % "{0:x}".format(bid))
# and now check if appropriate
if (bid == "T485"):
msg = "Board ID '%s' correct\n" % bid
msg = "Board ID correct: %s\n" % bid
inf.write(msg)
else:
msg = "ERROR: Board ID (%s) incorrect, check IC62" % bid
pel.set(msg)
# Get gateware version and convert it to major-minor float number
gwvers = bus.vv_read(0x04) & 0xff
maj = float(gwvers >> 4)
min = float(gwvers & 0x0f)
if min < 10:
p = 1 # decimal precision for printing below
min /= 10
else:
p = 2 # decimal precision for printing below
min /= 100
gwvers = maj + min
# and now check if appropriate
if (gwvers == 1.0):
msg = "Release gateware version correct: %2.*f\n" % (p, gwvers)
inf.write(msg)
else:
msg = "ERROR: Board ID incorrect, check IC62"
msg = "ERROR: Release gateware version (%2.*f) incorrect - expected 1.0" % (p, gwvers)
pel.set(msg)
# Fall-back to golden addres by performing IPROG from wrong address
print("Trying fallback to golden gateware...")
bus.vv_write(0x108, 0x44 | (0x0b << 24))
bus.vv_write(0x10c, 0x180000 | (0x0b << 24)) # release bitstream at 0x170000
bus.vv_write(0x100, 0x10000)
try:
# This write will issue IPROG and an NACK, so we avoid the exception here
bus.vv_write(0x100, 0x20000)
except:
pass
# Try to read out gateware version and time out after 60 seconds
t0 = time.time()
t1 = t0 + 60
while (1):
try:
if (time.time() >= t1):
msg = "ERROR: Timeout, fallback unsuccessful"
print msg
pel.set(msg)
break
# Read gateware version after fall-back
gwvers = bus.vv_read(0x04) & 0xff
maj = float(gwvers >> 4)
min = float(gwvers & 0x0f)
if min < 10:
p = 1 # decimal precision for printing below
min /= 10
else:
p = 2 # decimal precision for printing below
min /= 100
gwvers = maj + min
# and now check if appropriate
if (gwvers == 0.0):
msg = "Golden gateware version correct: %2.*f\n" % (p, gwvers)
inf.write(msg)
else:
msg = "ERROR: Golden gateware version (%2.*f) incorrect - expected 0.0" % (p, gwvers)
pel.set(msg)
# FPGA up from booting, end the loop
break
except:
continue
return pel.get()
except BusException, e:
......@@ -87,6 +156,7 @@ def main(bus,tname,inf,log):
raise PtsError("SKT Warning: %s" % (e))
if __name__ == '__main__':
bus = SKT(ELMASLOT)
os.chdir("log")
logname = glob.glob('*.log')
......@@ -94,20 +164,31 @@ if __name__ == '__main__':
log = open(logname[0],'a')
inf = open(infname[0],'a')
log.write("Run:1 Begin: test08\n")
inf.write("Run:1 Begin: test08\n")
msg = "Run:1 Begin: test08"
print msg
log.write(msg + '\n')
inf.write(msg + '\n')
try:
ret = main(bus, 'test08', inf, log)
if (ret == 0):
log.write("PASS: test08\n")
else:
log.write("FAIL: test08->flashtest.py\n")
print main.__doc__
ret = main(bus, 'test08', inf, log)
if (ret == 0):
msg = "PASS: test08"
log.write(msg + '\n')
inf.write(msg + '\n')
print msg
else:
msg = "FAIL: test08->flashtest.py\n"
log.write(msg + '\n')
inf.write(msg + '\n')
print msg
except Exception as e:
msg = "FAIL: test08->flashtest.py (%s)" % e
log.write(msg + '\n')
inf.write(msg + '\n')
print msg
log.write("Run:1 End: test08\n")
inf.write("Run:1 End: test08\n")
msg = "FAIL: test08->flashtest.py (%s)" % e
log.write(msg + '\n')
inf.write(msg + '\n')
print msg
msg = "Run:1 End: test08"
print msg
log.write(msg + '\n')
inf.write(msg + '\n')
......@@ -192,7 +192,7 @@ if __name__ == '__main__':
time.sleep(5)
# .. and run the flash test
cmd = "python ./flashtest.py"
cmd = "xterm -e python ./flashtest.py"
subprocess.call(cmd, shell=True, stdout=fnull, stderr=fnull)
# After all testing has finished, grep the log files for PASS and FAIL messages and print the outcomes to the console
......@@ -234,3 +234,4 @@ if __name__ == '__main__':
sys.exit(1)
else:
ok = raw_input("--> To exit PTS, type 'ok': ")
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