Commit 8f2b83fe authored by Theodor-Adrian Stana's avatar Theodor-Adrian Stana

fixed sector erase error in multiboot and added multiboot support in gateware sub-proj

parent 1c09a3a4
conv-ttl-blo-gw @ 5b6e568a
Subproject commit bfa6c70eec6fe363e70c99ffab3266e0a6bd92a5
Subproject commit 5b6e568a54976df6d864eca3ce525d93e3840ae2
......@@ -41,6 +41,13 @@ sys.path.append("../vbcp")
from vbcp import *
from vbcpexcept import *
MB_BASE = 0x40
MB_CR_OFS = 0x00
MB_SR_OFS = 0x04
MB_GBBAR_OFS = 0x08
MB_MBBAR_OFS = 0x0C
MB_FAR_OFS = 0x10
# This function handles the OR-ing together of the data bytes and the control
# byte in FAR.
#
......@@ -58,15 +65,15 @@ def spi_transfer(nbytes, cs, dat):
# write - we send up to three data bytes in one FAR register write
# writemregs - we send up to 24 data bytes in eight FAR register writes
if isinstance(dat,int):
ctb.write(0x90, (ctrl << 24) | dat)
ctb.write(MB_BASE+MB_FAR_OFS, (ctrl << 24) | dat)
else:
for i in xrange(len(dat)):
wval.append((ctrl << 24) | dat[i])
ctb.writemregs(0x90, wval)
ctb.writemregs(MB_BASE+MB_FAR_OFS, wval)
# Read the data and prepare the return value
while (retval & (1 << 28) == 0):
retval = ctb.read(0x90)
retval = ctb.read(MB_BASE+MB_FAR_OFS)
return retval & 0xFFFFFF
......@@ -134,7 +141,7 @@ def flash_read(addr, nrbytes):
# Read bytes in groups of three
for i in range(nrbytes):
ret.append(spi_transfer(3,1,0))
ret.append(spi_transfer(1,1,0))
spi_transfer(1,0,0)
return ret
......@@ -143,6 +150,7 @@ def flash_read(addr, nrbytes):
def flash_serase(addr):
spi_transfer(1,1,0x06)
spi_transfer(1,0,0)
spi_transfer(1,1,0xD8)
# send address in reverse order
addr = ((addr & 0xff0000) >> 16) | (((addr & 0xff00) >> 8) << 8) | ((addr & 0xff) << 16)
spi_transfer(3,1,addr)
......@@ -173,9 +181,8 @@ if __name__ == "__main__":
# Wait for proper slot number
while 1:
try:
slot = 4
#slot = raw_input("Slot no.? ")
#slot = int(slot)
slot = raw_input("Slot no.? ")
slot = int(slot)
ctb = VBCP(ip, user, pwd, slot)
break
except TypeError as e:
......@@ -217,15 +224,18 @@ if __name__ == "__main__":
print "WRITE"
# Prepare time arrays, to calculate average time each operation takes
addr = 0
addr = multiboot_addr
tdat = []
twr = []
twa = []
te = []
tp = []
# Open bitstream file
f = open("conv.txt",'r')
tw0 = time.time()
# Each line in the input file contains the data for one page
for fdata in f:
print addr
......@@ -271,6 +281,7 @@ if __name__ == "__main__":
tdat.append(t2-t1)
twr.append(t4-t3)
twa.append(t5-t4)
tp.append(t5-t3)
#if (addr == 0x10000):
# break
......@@ -278,25 +289,27 @@ if __name__ == "__main__":
#print data
#print len(data)
tw1 = time.time()
# Close file handle
f.close()
# Phew! We're ready, so calculate the mean time it took for each process
print "DONE!"
print "read1 time: %2.6f" % float(tr1-tr0)
print "read2 time: %2.6f" % float(tr3-tr2)
print "data time: %2.6f" % float(sum(tdat)/len(tdat))
print "erase time: %2.6f" % float(sum(te)/len(te))
print "write time: %2.6f" % float(sum(twr)/len(twr)) #(t4-t3)
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
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_CR_OFS, 0x10000)
try:
ctb.write(0x88, 0x44 | (0x0b << 24))
ctb.write(0x8c, multiboot_addr | (0x0b << 24))
ctb.write(0x80, 0x10000)
ctb.write(0x80, 0x20000)
ctb.write(MB_BASE+MB_CR_OFS, 0x20000)
except NAckError:
pass
......@@ -307,12 +320,12 @@ if __name__ == "__main__":
# and wait for the FPGA to gracefully respond, or die trying
while (1):
try:
if ((ctb.read(0x4) & 0xFFFF) == 0x0201):
print "IPROG successful!"
break
if (time.time() >= t1):
print "Timeout, IPROG unsuccessful!"
break
if ((ctb.read(0x4) & 0xFFFF) == 0x0200):
print "IPROG successful!"
break
except NAckError:
continue
......
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