diff options
author | Tom Hughes <tomhughes@chromium.org> | 2020-06-05 10:58:17 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-06-16 02:12:04 +0000 |
commit | b30fe9b01bea50b1321bfc9045e0190074e03b5b (patch) | |
tree | 97ca3fa4f0b972bae7a5b9ef7d51567dc166aed6 | |
parent | ac4562e9be368bca4ba00622a2ca2b2378e0decf (diff) | |
download | chrome-ec-b30fe9b01bea50b1321bfc9045e0190074e03b5b.tar.gz |
util/flash_jlink.py: Exit with error code
When flashing fails, the script will exit with non-zero exit code.
BRANCH=none
BUG=b:151105339
TEST=Stop JLinkRemoteServerCLExe:
./util/flash_jlink.py --board bloonchipper --image \
./build/bloonchipper/flash_write_protect/flash_write_protect.bin
echo $?
1
Signed-off-by: Tom Hughes <tomhughes@chromium.org>
Change-Id: I75052eb52d0690e7a6ba3ae9e5ccbf877bee2cd2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2233781
Commit-Queue: Craig Hesling <hesling@chromium.org>
Reviewed-by: Craig Hesling <hesling@chromium.org>
-rwxr-xr-x | util/flash_jlink.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/util/flash_jlink.py b/util/flash_jlink.py index cf7c570fdb..f40a70b3ff 100755 --- a/util/flash_jlink.py +++ b/util/flash_jlink.py @@ -17,7 +17,9 @@ import subprocess import sys import tempfile +# Commands are documented here: https://wiki.segger.com/J-Link_Commander JLINK_COMMANDS = ''' +exitonerror 1 r loadfile {FIRMWARE} r @@ -67,7 +69,9 @@ def flash(jlink_exe, ip, device, interface, cmd_file): '-CommandFile', cmd_file, ]) logging.debug('Running command: "%s"', ' '.join(cmd)) - subprocess.run(cmd) + completed_process = subprocess.run(cmd) + logging.debug('JLink return code: %d', completed_process.returncode) + return completed_process.returncode def main(argv: list): @@ -121,8 +125,10 @@ def main(argv: list): args.jlink = args.jlink cmd_file = create_jlink_command_file(args.image) - flash(args.jlink, args.ip, config.device, config.interface, cmd_file.name) + ret_code = flash(args.jlink, args.ip, config.device, config.interface, + cmd_file.name) cmd_file.close() + return ret_code if __name__ == '__main__': |