]>
iEval git - yule.git/blob - iCEburn.py
3 from libiceblink
import ICE40Board
, M25P10
6 ap
= argparse
.ArgumentParser()
7 ap
.add_argument("-e", "--erase", action
="store_true")
8 ap
.add_argument("-v", "--verbose", action
="store_true")
9 ap
.add_argument("-w", "--write", type=argparse
.FileType("rb"))
10 args
= ap
.parse_args()
15 print("Found iCE40 board serial: %s" % board
.get_serial())
18 sp
= board
.get_spi_port(0)
20 with board
.get_gpio() as gpio
:
21 # Force the FPGA into reset so we may drive the IOs
22 gpio
.ice40SetReset(True)
24 with board
.get_spi_port(0) as sp
:
32 # Verify that we're talking to the part we think we are
33 assert flash
.getID() == b
'\x20\x20\x11'
38 print("Erasing flash...")
44 data
= args
.write
.read()
47 print("Writing image...")
49 for addr
in range(0, len(data
), 256):
50 buf
= data
[addr
:addr
+256]
51 flash
.pageProgram(addr
, buf
)
54 print("Verifying written image...")
56 buf
= flash
.read(0, len(data
))
57 assert len(buf
) == len(data
)
60 for i
,(a
,b
) in enumerate(zip(buf
, data
)):
62 print ("verification failure at %06x: %02x != %02x" %
67 print("Too many verification failures, bailing")
70 # Release the FPGA reset
71 gpio
.ice40SetReset(False)
74 if __name__
== "__main__":
This page took 0.045366 seconds and 4 git commands to generate.