Merge pull request #1901 from FlyGoat/zynq7000_openocd

Zynq7000 litex_server OpenOCD JTAG fixes
This commit is contained in:
Gwenhael Goavec-Merou 2024-03-20 16:41:22 +01:00 committed by GitHub
commit 46ff7cdee5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 5 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()
@ -40,6 +42,12 @@ class OpenOCD(GenericProgrammer):
]) ])
self.call(["openocd", "-f", config, "-c", script]) self.call(["openocd", "-f", config, "-c", script])
def get_tap_name(self, config):
cfg_str = open(config).read()
if "zynq_7000" in cfg_str:
return "zynq_pl.bs"
return "$_CHIPNAME.tap"
def get_ir(self, chain, config): def get_ir(self, chain, config):
cfg_str = open(config).read() cfg_str = open(config).read()
# Lattice ECP5. # Lattice ECP5.
@ -98,6 +106,7 @@ class OpenOCD(GenericProgrammer):
- TX valid : bit 9 - TX valid : bit 9
""" """
config = self.find_config() config = self.find_config()
tap_name = self.get_tap_name(config)
ir = self.get_ir(chain, config) ir = self.get_ir(chain, config)
endstate = self.get_endstate(config) endstate = self.get_endstate(config)
cfg = """ cfg = """
@ -185,8 +194,9 @@ proc jtagstream_serve {tap port} {
write_to_file("stream.cfg", cfg) write_to_file("stream.cfg", cfg)
script = "; ".join([ script = "; ".join([
"init", "init",
"irscan $_CHIPNAME.tap {:d}".format(ir), "poll off",
"jtagstream_serve $_CHIPNAME.tap {:d}".format(port), "irscan {} {:d}".format(tap_name, ir),
"jtagstream_serve {} {:d}".format(tap_name, port),
"exit", "exit",
]) ])
self.call(["openocd", "-f", config, "-f", "stream.cfg", "-c", script]) self.call(["openocd", "-f", config, "-f", "stream.cfg", "-c", script])