From a7d441488c784859813579321581c80dc7fc10ba Mon Sep 17 00:00:00 2001 From: Jiaxun Yang Date: Thu, 7 Mar 2024 19:54:04 +0000 Subject: [PATCH] build/openocd: Allow config file to be searched from local dirs To sort out path for boards using OpenOCD config file shipped with OpenOCD itself. Signed-off-by: Jiaxun Yang --- litex/build/generic_programmer.py | 9 ++++++--- litex/build/openocd.py | 2 ++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/litex/build/generic_programmer.py b/litex/build/generic_programmer.py index de968f60d..4c7f602d8 100644 --- a/litex/build/generic_programmer.py +++ b/litex/build/generic_programmer.py @@ -24,6 +24,7 @@ class GenericProgrammer: self.flash_proxy_repos = [ "https://github.com/quartiq/bscan_spi_bitstreams/raw/master/", ] + self.config_dirs = ["prog"] self.config_repos = [ "https://raw.githubusercontent.com/litex-hub/litex-boards/master/litex_boards/prog/", ] @@ -65,9 +66,11 @@ class GenericProgrammer: if os.path.exists(fullname): return self.config # Search in local config directory - fullname = tools.cygpath(os.path.join(self.prog_local, self.config)) - if os.path.exists(fullname): - return fullname + for d in self.config_dirs: + fulldir = os.path.abspath(os.path.expanduser(d)) + fullname = tools.cygpath(os.path.join(fulldir, self.config)) + if os.path.exists(fullname): + return fullname # Search in repositories and download it import requests os.makedirs(self.prog_local, exist_ok=True) diff --git a/litex/build/openocd.py b/litex/build/openocd.py index 166fb2e26..b95d9f1a2 100644 --- a/litex/build/openocd.py +++ b/litex/build/openocd.py @@ -17,6 +17,8 @@ class OpenOCD(GenericProgrammer): def __init__(self, config, flash_proxy_basename=None): GenericProgrammer.__init__(self, flash_proxy_basename) self.config = config + self.config_dirs.append("/usr/share/openocd/scripts") + self.config_dirs.append("/usr/local/share/openocd/scripts") def load_bitstream(self, bitstream): config = self.find_config()