forked from pfalcon/PySWD
-
Notifications
You must be signed in to change notification settings - Fork 3
/
test.py
executable file
·35 lines (29 loc) · 968 Bytes
/
test.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
#!/usr/bin/python
import NUC1XX
import PirateSWD
import SWDCommon
import sys
def readWholeFile(filename):
flashfile = open(filename, 'rb')
return flashfile.read()
if __name__ == '__main__':
filename = sys.argv[1]
flash_data = readWholeFile(filename)
pirate = PirateSWD.PirateSWD('/dev/ttyUSB0', vreg=True)
debugport = SWDCommon.DebugPort(pirate)
nuc1xx = NUC1XX.NUC1XX(debugport)
nuc1xx.halt()
nuc1xx.changeBS()
nuc1xx.reset()
nuc1xx.registerUnlock()
nuc1xx.enableISP()
nuc1xx.writeBinToFlash(flash_data)
print 'config0 register: %x' % nuc1xx.readConfig()
nuc1xx.changeCBS()
print 'config0 register: %x' % nuc1xx.readConfig()
#nuc1xx.eraseFlash()
#nuc1xx.readFlash(0x00000000)
#nuc1xx.writeFlash(0x00000000, 0xdeadbeef)
#nuc1xx.readFlash(0x00100000, len(flash_data))
#nuc1xx.readFlash(0x00000000)
# vim: set tabstop=4 softtabstop=4 shiftwidth=4 textwidth=80 smarttab expandtab: