summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorCraig Hesling <hesling@chromium.org>2020-06-02 08:47:26 -0700
committerCommit Bot <commit-bot@chromium.org>2020-06-04 20:07:55 +0000
commitf8ba78608c7ab29431d2ad6e043da95d0032b24b (patch)
treedf048e86dc475f5a54d03777fee1a9306b86d4a4 /util
parent4b75792e64ff071581a4d51caa0c88b26e5da851 (diff)
downloadchrome-ec-f8ba78608c7ab29431d2ad6e043da95d0032b24b.tar.gz
util/flash_jlink.py: Allow using PATH to find JLinkExe
Installing Jlink Debian package places JLinkExe in a PATH area. This allow flash_jlink to find the normal path'ed executable in addition to the hand placed binary. BRANCH=none BUG=none TEST=# Assume JLink_Linux_V670e_x86_64 dir does not exist mkdir ./JLink_Linux_V670e_x86_64 touch ./JLink_Linux_V670e_x86_64/JLinkExe chmod +x ./JLink_Linux_V670e_x86_64/JLinkExe ./util/flash_jlink.py # Should fail TEST=# Ensure the proper JLinkExe is in PATH rm -rf ./JLink_Linux_V670e_x86_64 ./util/flash_jlink.py # Should succeed Signed-off-by: Craig Hesling <hesling@chromium.org> Change-Id: Ife0c2b7a47f989877f7b81a81a7dadd2b7cb5c1b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2226879 Commit-Queue: Tom Hughes <tomhughes@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
Diffstat (limited to 'util')
-rwxr-xr-xutil/flash_jlink.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/util/flash_jlink.py b/util/flash_jlink.py
index 00261856a2..826f6eea60 100755
--- a/util/flash_jlink.py
+++ b/util/flash_jlink.py
@@ -8,9 +8,11 @@
This script requires Segger hardware attached via JTAG/SWD.
"""
+
import argparse
import logging
import os
+import shutil
import subprocess
import sys
import tempfile
@@ -67,6 +69,8 @@ def main(argv: list):
parser = argparse.ArgumentParser()
default_jlink = './JLink_Linux_V670e_x86_64/JLinkExe'
+ if shutil.which(default_jlink) is None:
+ default_jlink = 'JLinkExe'
parser.add_argument(
'--jlink', '-j',
help='JLinkExe path (default: ' + default_jlink + ')',
@@ -108,7 +112,7 @@ def main(argv: list):
config = BOARD_CONFIGS[args.board]
args.image = os.path.realpath(args.image)
- args.jlink = os.path.realpath(args.jlink)
+ args.jlink = args.jlink
cmd_file = create_jlink_command_file(args.image)
flash(args.jlink, args.ip, config.device, config.interface, cmd_file.name)