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 <jiaxun.yang@flygoat.com>
This commit is contained in:
Jiaxun Yang 2024-03-07 19:54:04 +00:00
parent 18720e29cc
commit a7d441488c
2 changed files with 8 additions and 3 deletions

View File

@ -24,6 +24,7 @@ class GenericProgrammer:
self.flash_proxy_repos = [ self.flash_proxy_repos = [
"https://github.com/quartiq/bscan_spi_bitstreams/raw/master/", "https://github.com/quartiq/bscan_spi_bitstreams/raw/master/",
] ]
self.config_dirs = ["prog"]
self.config_repos = [ self.config_repos = [
"https://raw.githubusercontent.com/litex-hub/litex-boards/master/litex_boards/prog/", "https://raw.githubusercontent.com/litex-hub/litex-boards/master/litex_boards/prog/",
] ]
@ -65,9 +66,11 @@ class GenericProgrammer:
if os.path.exists(fullname): if os.path.exists(fullname):
return self.config return self.config
# Search in local config directory # Search in local config directory
fullname = tools.cygpath(os.path.join(self.prog_local, self.config)) for d in self.config_dirs:
if os.path.exists(fullname): fulldir = os.path.abspath(os.path.expanduser(d))
return fullname fullname = tools.cygpath(os.path.join(fulldir, self.config))
if os.path.exists(fullname):
return fullname
# Search in repositories and download it # Search in repositories and download it
import requests import requests
os.makedirs(self.prog_local, exist_ok=True) os.makedirs(self.prog_local, exist_ok=True)

View File

@ -17,6 +17,8 @@ class OpenOCD(GenericProgrammer):
def __init__(self, config, flash_proxy_basename=None): def __init__(self, config, flash_proxy_basename=None):
GenericProgrammer.__init__(self, flash_proxy_basename) GenericProgrammer.__init__(self, flash_proxy_basename)
self.config = config 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): def load_bitstream(self, bitstream):
config = self.find_config() config = self.find_config()