diff options
author | Fabio Baltieri <fabiobaltieri@google.com> | 2023-03-30 14:19:19 +0000 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-04-03 19:03:12 +0000 |
commit | 720ea2078d362e819e32975bbd8ec4b5018309c6 (patch) | |
tree | 4809a8e0dace238256fbea9bda31c1d33ea324d9 /util/ec_openocd.py | |
parent | f75387f0d65f24288316300534b45ff85c2e2aa9 (diff) | |
download | chrome-ec-720ea2078d362e819e32975bbd8ec4b5018309c6.tar.gz |
ec_openocd: add automatic fallback to gdb-multiarch
Update the script to check for the board specific gdb executable, but
fallback to the generic multiarch one, since that's what seems to be on
debian machines these days.
BRANCH=none
BUG=b:276311425
TEST=./util/ec_openocd.py --board rex flash
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Change-Id: I32a87a95287a4d2be9f14c82eef869d1a85cac51
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4386294
Reviewed-by: Robert Zieba <robertzieba@google.com>
Diffstat (limited to 'util/ec_openocd.py')
-rwxr-xr-x | util/ec_openocd.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/util/ec_openocd.py b/util/ec_openocd.py index 6183540353..e0c3dc657e 100755 --- a/util/ec_openocd.py +++ b/util/ec_openocd.py @@ -6,6 +6,7 @@ import argparse import dataclasses +import distutils.spawn import pathlib import socket import subprocess @@ -17,6 +18,9 @@ import time Flashes and debugs the EC through openocd """ +# GDB variant to use if the board specific one is not found +FALLBACK_GDB_VARIANT = "gdb-multiarch" + @dataclasses.dataclass class BoardInfo: @@ -55,8 +59,20 @@ def create_gdb_args(board, port, executable): raise RuntimeError(f"Unsupported board {board}") board_info = boards[board] + + if distutils.spawn.find_executable(board_info.gdb_variant): + gdb_path = board_info.gdb_variant + elif distutils.spawn.find_executable(FALLBACK_GDB_VARIANT): + print( + f"GDB executable {board_info.gdb_variant} not found, " + f"using {FALLBACK_GDB_VARIANT} instead" + ) + gdb_path = FALLBACK_GDB_VARIANT + else: + raise RuntimeError("No GDB executable found in the system") + args = [ - board_info.gdb_variant, + gdb_path, executable, # GDB can't autodetect these according to OpenOCD "-ex", |