build/lattice/programmer: make OpenOCDJTAGProgrammer closer to OpenOCD programmer.

This commit is contained in:
Florent Kermarrec 2020-05-05 12:17:12 +02:00
parent 9a7f9cb87b
commit 85ac5ef133
1 changed files with 9 additions and 12 deletions

View File

@ -25,34 +25,31 @@ class LatticeProgrammer(GenericProgrammer):
# OpenOCDJTAGProgrammer --------------------------------------------------------------------------------
class OpenOCDJTAGProgrammer(GenericProgrammer):
def __init__(self, openocd_config, flash_proxy_basename=None):
GenericProgrammer.__init__(self, flash_proxy_basename=flash_proxy_basename)
self.openocd_config = openocd_config
def __init__(self, config, flash_proxy_basename=None):
GenericProgrammer.__init__(self, flash_proxy_basename)
self.config = config
def load_bitstream(self, bitstream_file):
config = self.find_config()
svf_file = bitstream_file.replace(".bit", ".svf")
subprocess.call(["openocd", "-f", self.openocd_config , "-c", "transport select jtag; init; svf quiet progress \"{}\"; exit".format(svf_file)])
subprocess.call(["openocd", "-f", config, "-c", "transport select jtag; init; svf quiet progress \"{}\"; exit".format(svf_file)])
def flash(self, address, data, verify=True):
if self.flash_proxy_basename is None:
flash_proxy = None
else:
flash_proxy = self.find_flash_proxy()
config = self.find_config()
flash_proxy = self.find_flash_proxy()
script = "; ".join([
"transport select jtag",
"target create ecp5.spi0.proxy testee -chain-position ecp5.tap",
"flash bank spi0 jtagspi 0 0 0 0 ecp5.spi0.proxy 0x32",
"init",
"svf quiet progress \"{}\"".format(flash_proxy) if flash_proxy is not None else "",
"svf quiet progress \"{}\"".format(flash_proxy),
"reset halt",
"flash probe spi0",
"flash write_image erase \"{0}\" 0x{1:x}".format(data, address),
"flash verify_bank spi0 \"{0}\" 0x{1:x}" if verify else "".format(data, address),
"exit"
])
subprocess.call(["openocd", "-f", self.openocd_config, "-c", script])
subprocess.call(["openocd", "-f", config, "-c", script])
# IceStormProgrammer -------------------------------------------------------------------------------