cc3200: Improve uniflash script and make it a bit more verbose.
This commit is contained in:
parent
b864e7afe4
commit
ec8589e4c9
@ -22,6 +22,27 @@ def print_exception(e):
|
|||||||
print ('Exception: {}, on line {}'.format(e, sys.exc_info()[-1].tb_lineno))
|
print ('Exception: {}, on line {}'.format(e, sys.exc_info()[-1].tb_lineno))
|
||||||
|
|
||||||
|
|
||||||
|
def execute(command):
|
||||||
|
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
|
cmd_log = ""
|
||||||
|
|
||||||
|
# Poll process for new output until finished
|
||||||
|
while True:
|
||||||
|
nextline = process.stdout.readline()
|
||||||
|
if nextline == '' and process.poll() != None:
|
||||||
|
break
|
||||||
|
sys.stdout.write(nextline)
|
||||||
|
sys.stdout.flush()
|
||||||
|
cmd_log += nextline
|
||||||
|
|
||||||
|
output = process.communicate()[0]
|
||||||
|
exitCode = process.returncode
|
||||||
|
|
||||||
|
if exitCode == 0:
|
||||||
|
return cmd_log
|
||||||
|
else:
|
||||||
|
raise ProcessException(command, exitCode, output)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
cmd_parser = argparse.ArgumentParser(description='Flash the WiPy and optionally run a small test on it.')
|
cmd_parser = argparse.ArgumentParser(description='Flash the WiPy and optionally run a small test on it.')
|
||||||
cmd_parser.add_argument('-u', '--uniflash', default=None, help='the path to the uniflash cli executable')
|
cmd_parser.add_argument('-u', '--uniflash', default=None, help='the path to the uniflash cli executable')
|
||||||
@ -30,7 +51,7 @@ def main():
|
|||||||
cmd_parser.add_argument('-s', '--servicepack', default=None, help='the path to the servicepack file')
|
cmd_parser.add_argument('-s', '--servicepack', default=None, help='the path to the servicepack file')
|
||||||
args = cmd_parser.parse_args()
|
args = cmd_parser.parse_args()
|
||||||
|
|
||||||
result = 1
|
output = ""
|
||||||
com_port = 'com=' + str(args.port)
|
com_port = 'com=' + str(args.port)
|
||||||
servicepack_path = 'spPath=' + args.servicepack
|
servicepack_path = 'spPath=' + args.servicepack
|
||||||
|
|
||||||
@ -38,19 +59,23 @@ def main():
|
|||||||
if args.uniflash == None or args.config == None:
|
if args.uniflash == None or args.config == None:
|
||||||
raise ValueError('uniflash path and config path are mandatory')
|
raise ValueError('uniflash path and config path are mandatory')
|
||||||
if args.servicepack == None:
|
if args.servicepack == None:
|
||||||
subprocess.check_call([args.uniflash, '-config', args.config, '-setOptions', com_port, '-operations', 'format', 'program'], stderr=subprocess.STDOUT)
|
output += execute([args.uniflash, '-config', args.config, '-setOptions', com_port, '-operations', 'format', 'program'])
|
||||||
else:
|
else:
|
||||||
subprocess.check_call([args.uniflash, '-config', args.config, '-setOptions', com_port, servicepack_path, '-operations', 'format', 'servicePackUpdate', 'program'], stderr=subprocess.STDOUT)
|
output += execute([args.uniflash, '-config', args.config, '-setOptions', com_port, servicepack_path, '-operations', 'format', 'servicePackUpdate', 'program'])
|
||||||
result = 0
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print_exception(e)
|
print_exception(e)
|
||||||
|
output = ""
|
||||||
finally:
|
finally:
|
||||||
if result:
|
if "Finish Executing operation: program" in output:
|
||||||
print ("ERROR: Programming failed!")
|
print("======================================")
|
||||||
|
print("Board programmed OK")
|
||||||
|
print("======================================")
|
||||||
|
sys.exit(0)
|
||||||
else:
|
else:
|
||||||
print ("Board programmed OK")
|
print("======================================")
|
||||||
sys.exit(result)
|
print("ERROR: Programming failed!")
|
||||||
|
print("======================================")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
Loading…
Reference in New Issue
Block a user