-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathflash_ppk.py
executable file
·32 lines (31 loc) · 1.11 KB
/
flash_ppk.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
from pynrfjprog import API, Hex
if __name__ == "__main__":
hexfile = "ppk_110.hex"
success = False
retries = 5
# Open connection to debugger and rtt
nrfjprog = API.API('NRF52')
nrfjprog.open()
nrfjprog.connect_to_emu_without_snr()
while(success is False or retries == 0):
try:
nrfjprog.recover()
print "PPK erased"
success = True
except:
print "failed, retrying"
retries -= 1
pass
try:
application = Hex.Hex(hexfile)
for segment in application:
nrfjprog.write(segment.address, segment.data, True)
print "PPK reprogrammed"
nrfjprog.sys_reset()
nrfjprog.go()
nrfjprog.rtt_start()
print "PPK ready to go"
except Exception as e:
print str(e)
print "Unable to flash " + hexfile + ", make sure this file is found in working directory."
raw_input("Press any key to finish...")