build/lattice/programmer: make OpenOCDJTAGProgrammer closer to OpenOCD programmer.
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Tue, 5 May 2020 10:17:12 +0000 (12:17 +0200)
committerFlorent Kermarrec <florent@enjoy-digital.fr>
Tue, 5 May 2020 10:17:12 +0000 (12:17 +0200)
litex/build/lattice/programmer.py

index 0095c147f65d5566953df6d1b551db09af600717..e3d7a963d939418ff9866e3f8e2c5289e8e69aad 100644 (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 -------------------------------------------------------------------------------