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 = [
"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)

View File

@ -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()
@ -40,6 +42,12 @@ class OpenOCD(GenericProgrammer):
])
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):
cfg_str = open(config).read()
# Lattice ECP5.
@ -98,6 +106,7 @@ class OpenOCD(GenericProgrammer):
- TX valid : bit 9
"""
config = self.find_config()
tap_name = self.get_tap_name(config)
ir = self.get_ir(chain, config)
endstate = self.get_endstate(config)
cfg = """
@ -185,8 +194,9 @@ proc jtagstream_serve {tap port} {
write_to_file("stream.cfg", cfg)
script = "; ".join([
"init",
"irscan $_CHIPNAME.tap {:d}".format(ir),
"jtagstream_serve $_CHIPNAME.tap {:d}".format(port),
"poll off",
"irscan {} {:d}".format(tap_name, ir),
"jtagstream_serve {} {:d}".format(tap_name, port),
"exit",
])
self.call(["openocd", "-f", config, "-f", "stream.cfg", "-c", script])