forked from flowswitch/ht4032l-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfpga_upd.py
41 lines (29 loc) · 779 Bytes
/
fpga_upd.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
"""FX2 firmware load example"""
from sys import argv, exit
from HT4032L import loader
KnownFlashes = { (0xC2, 0x20, 0x13) : "MX25L4005" }
if len(argv)!=2:
exit("Usage: "+argv[0]+" <fpga.bin>")
la = loader()
print "Using", la.driver.name
la.open()
print "Loading SPI flash loader..."
la.LoadFX2("SpiLoader.bin")
fid = la.GetSpiFlashID()
if fid==(0,0,0):
la.close()
exit("Invalid flash ID !")
if not fid in KnownFlashes:
la.close()
exit("Unsupported flash ID: %02X, %02X, %02X !" % fid)
print KnownFlashes[fid], "detected"
print "Erasing..."
if not la.EraseSpiFlash():
la.close()
exit("Erase failed !")
print "Programming..."
if not la.ProgramSpiFlash(argv[1]):
la.close()
exit("Program failed !")
print "Done. Cycle LA power to load new firmware."
la.close()