|
@@ -114,23 +114,32 @@ def main():
|
114
|
114
|
lpc.prepare_write()
|
115
|
115
|
lpc.erase()
|
116
|
116
|
|
117
|
|
- # Write the files to flash
|
|
117
|
+ # Load the files
|
118
|
118
|
ih = intelhex.IntelHex()
|
119
|
119
|
for f in args.file:
|
120
|
120
|
ih.fromfile(f, format="hex")
|
121
|
121
|
|
|
122
|
+ # Write the files to flash
|
122
|
123
|
try:
|
123
|
124
|
lpc.flash_hex(ih, verbose=True)
|
124
|
125
|
except ISPError as e:
|
125
|
126
|
if e.args[0] == ReturnCode.CODE_READ_PROTECTION_ENABLED:
|
126
|
127
|
print("Error: code read protection is enabled")
|
|
128
|
+ print("Unable to flash, exiting")
|
127
|
129
|
sys.exit(2)
|
128
|
130
|
|
129
|
|
- # TODO: Verify that the flash has been written correctly if we've been
|
130
|
|
- # asked to
|
|
131
|
+ # Verify that the flash has been written correctly if we've been asked to
|
|
132
|
+ if args.verify:
|
|
133
|
+ try:
|
|
134
|
+ lpc.verify(ih, verbose=True)
|
|
135
|
+ except ISPError as e:
|
|
136
|
+ if e.args[0] == ReturnCode.CODE_READ_PROTECTION_ENABLED:
|
|
137
|
+ print("Error: code read protection is enabled")
|
|
138
|
+ print("Unalbe to verify, continuing")
|
131
|
139
|
|
132
|
140
|
# Start the program if we haven't been asked not to
|
133
|
141
|
if not args.no_start:
|
|
142
|
+ print("Starting program")
|
134
|
143
|
lpc.go()
|
135
|
144
|
|
136
|
145
|
lpc.close()
|