Commit 6d5780ef authored by Theodor-Adrian Stana's avatar Theodor-Adrian Stana

Updated multiboot and pulse test scripts

Signed-off-by: Theodor-Adrian Stana's avatarTheodor Stana <t.stana@cern.ch>
parent 8f2b83fe
Before using multiboot.py, you must first generate a compatible bitstream file
it can read. This can be done by running the binary converter tool from
Micron. Download the M25P64 VHDL models from:
http://cern.ch/go/xl8m
unzip, and run converter1.1.exe from the "code/" folder.
To run the converter tool on Linux, use Wine.
Then
%> python multiboot.py
Slot no.? <give slot number of CONV-TTL-BLO card here>
Read config reg? (y/n) <'y' to read configuration registers>
Read first page? (y/n) <'y' to read the first page from the MultiBoot address
you will give later>
Write to flash? (y/n) <'y' to write bitstream data>
Are you sure? (y/n) <asks you twice, since writing takes reaaaly long>
Issue IPROG? (y/n)
Multiboot bitstream address(hex): <hex bitstream address, nominally "170000">
<if you answered 'y' on both write questions:>
Input file name: <give here the name of the file you just generated using
converter1.1.exe>
The tool will now start sending your bitstream, outputting the page address
it is currently writing to. Go grab a coffee, since this will take at least
12 mins, maybe even more if your network connection is not that good, or
you're using Windows
This diff is collapsed.
......@@ -171,68 +171,38 @@ def flash_rsr():
return ret
#=============================================================================#
# MAIN "FUNCTION"
if __name__ == "__main__":
ip = "192.168.20.22" # raw_input("Crate IP? ")
user = "admin" # raw_input("Username? ")
pwd = "ADMIN" # raw_input("Password? ")
# Wait for proper slot number
while 1:
try:
slot = raw_input("Slot no.? ")
slot = int(slot)
ctb = VBCP(ip, user, pwd, slot)
break
except TypeError as e:
print "Please input a decimal slot number."
except SlotError as e:
print e.strerror
except KeyboardInterrupt:
sys.exit();
except:
print "Unexpected error: ", sys.exc_info()[0]
# Ask for multiboot address
while 1:
try:
multiboot_addr = raw_input("MultiBoot bitstream address (hex): ")
multiboot_addr = int(multiboot_addr, 16)
print '0x%06x' % multiboot_addr
break
except TypeError as e:
print "Please input a hexadecimal address!"
except KeyboardInterrupt:
sys.exit()
except:
print "Unexpected error: ", sys.exc_info()[0]
ts = time.time()
# Open VBCP connection
ctb.open_conn()
# read from flash
print "BEFORE"
#
# Read from flash
#
def _read(addr):
print "Reading 256 bytes from 0x%06X" % addr
tr0 = time.time()
rd = flash_read(multiboot_addr,256)
rd = flash_read(addr,256)
tr1 = time.time()
rd = "".join(["0x%06X " % b for b in rd])
rd = "".join(["%02X" % b for b in rd])
print rd
#
# Write to flash
#
def _write(addr):
# Ookay, now we start to write the flash
print "WRITE"
print "Writing bitstream..."
# Prepare time arrays, to calculate average time each operation takes
addr = multiboot_addr
tdat = []
twr = []
twa = []
te = []
tp = []
# Open bitstream file
f = open("conv.txt",'r')
# Ask for and open bitstream file
fname = raw_input("Input file name: ")
f = open(fname,'r')
tw0 = time.time()
......@@ -302,11 +272,14 @@ if __name__ == "__main__":
print "wait time: %2.6f" % float(sum(twa)/len(twa)) #(t5-t4)
print "page write time: %2.6f" % float(sum(tp)/len(tp))
print "total write time: %2.6f" % float(tw1-tw0)
# Finally, issue the reprogramming (IPROG) command
#
# Start IPROG sequence
#
def _iprog(addr):
print "Issuing IPROG command..."
ctb.write(MB_BASE+MB_GBBAR_OFS, 0x44 | (0x0b << 24))
ctb.write(MB_BASE+MB_MBBAR_OFS, multiboot_addr | (0x0b << 24))
ctb.write(MB_BASE+MB_MBBAR_OFS, addr | (0x0b << 24))
ctb.write(MB_BASE+MB_CR_OFS, 0x10000)
try:
ctb.write(MB_BASE+MB_CR_OFS, 0x20000)
......@@ -315,7 +288,7 @@ if __name__ == "__main__":
# Set timeout to be sixty seconds from now...
t0 = time.time()
t1 = t0 + 60
t1 = t0 + 20
# and wait for the FPGA to gracefully respond, or die trying
while (1):
......@@ -323,15 +296,126 @@ if __name__ == "__main__":
if (time.time() >= t1):
print "Timeout, IPROG unsuccessful!"
break
if ((ctb.read(0x4) & 0xFFFF) == 0x0200):
if ((ctb.read(0x4) & 0xFFFF) > 0x0200):
print "IPROG successful!"
break
except NAckError:
continue
# Close VBCP connection and print final values
def _rdcfgreg():
print "Press 'q' to end config reg readout"
while 1:
try:
reg = raw_input('Address (hex): ')
reg = int(reg, 16)
if (reg < 0x00) or (reg > 0x22):
raise ValueError
ctb.write(MB_BASE+MB_CR_OFS, (1 << 6) | reg)
val = ctb.read(MB_BASE+MB_SR_OFS)
if (val & (1 << 16)):
print "REG(0x%02X) = 0x%04X" % (reg, val & 0xFFFF)
else:
print "Status invalid!"
except ValueError:
if (reg == 'q'):
break
print "Please input a hex value in the range [0x00, 0x22] or 'q' to quit"
#=============================================================================#
# MAIN "FUNCTION"
if __name__ == "__main__":
ip = "192.168.20.22" # raw_input("Crate IP? ")
user = "admin" # raw_input("Username? ")
pwd = "ADMIN" # raw_input("Password? ")
# Wait for proper slot number
while 1:
try:
slot = raw_input("Slot no.? ")
slot = int(slot)
ctb = VBCP(ip, user, pwd, slot)
break
except TypeError as e:
print "Please input a decimal slot number."
except SlotError as e:
print e.strerror
except KeyboardInterrupt:
sys.exit();
except:
print "Unexpected error: ", sys.exc_info()[0]
# Open VBCP connection
ctb.open_conn()
# Set MB_BASE to value in pulsetest bitstream, if this bitstream is present
if (ctb.read(0x04) & 0xFFFF == 0x9999):
MB_BASE = 0x300;
# Read config reg, if user wants to
while 1:
rdcfgreg = raw_input("Read config reg? (y/n) ")
if (rdcfgreg == 'y'):
_rdcfgreg()
break
elif (rdcfgreg == 'n'):
break
# Ask else to do (read/write/iprog)
while 1:
rd = raw_input("Read first page? (y/n) ")
if (rd == 'y') or (rd == 'n'):
break
while 1:
wr = raw_input("Write to flash? (y/n) ")
if (wr == 'y'):
while 1:
wr = raw_input("Are you sure? (y/n) ")
if (wr == 'y') or (wr == 'n'):
break
break
elif (wr == 'n'):
break
while 1:
iprog = raw_input("Issue IPROG? (y/n) ")
if (iprog == 'y') or (iprog == 'n'):
break
# Ask for multiboot address
while 1:
try:
multiboot_addr = raw_input("MultiBoot bitstream address (hex): ")
multiboot_addr = int(multiboot_addr, 16)
print '0x%06x' % multiboot_addr
break
except ValueError as e:
print "Please input a hexadecimal address!"
except KeyboardInterrupt:
sys.exit()
except:
print "Unexpected error: ", sys.exc_info()[0]
# Now do something based on user selection
# read from flash
if (rd == 'y'):
_read(multiboot_addr)
# write to flash
if (wr == 'y'):
_write(multiboot_addr)
# Finally, issue the reprogramming (IPROG) command
if (iprog == 'y'):
_iprog(multiboot_addr)
# Close VBCP connection
ctb.close_conn()
# Woohoo!
tf = time.time()
print "run time: %2.6f" % float(tf-ts)
This diff is collapsed.
This diff is collapsed.
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