--- /dev/null
+#!/usr/bin/python3
+
+import argparse
+import os
+import subprocess
+import sys
+
+BASE = os.path.dirname(os.path.abspath(__file__))
+CONFIG = os.path.join(BASE, "xilinx-xc7.cfg")
+
+def flash(config, flash_proxy, address, data, set_qe=False):
+ script = "; ".join([
+ "init",
+ "jtagspi_init 0 {{{}}}".format(flash_proxy),
+ "jtagspi set_qe 0 1" if set_qe else "",
+ "jtagspi_program {{{}}} 0x{:x}".format(data, address),
+ "fpga_program",
+ "exit"
+ ])
+ subprocess.call(["openocd", "-f", config, "-c", script])
+
+parser = argparse.ArgumentParser()
+parser.add_argument("file", help="file to write to flash")
+parser.add_argument("-a", "--address", help="offset in flash", type=int, default=0)
+parser.add_argument("-f", "--fpga", help="a35 or a100", default="a35")
+args = parser.parse_args()
+
+if args.fpga.lower() == "a35":
+ proxy = "bscan_spi_xc7a35t.bit"
+elif args.fpga.lower() == "a100":
+ proxy = "bscan_spi_xc7a100t.bit"
+else:
+ print("error: specify a35 or a100 when flashing")
+ sys.exit()
+
+proxy = os.path.join(BASE, proxy)
+
+flash(CONFIG, proxy, args.address, args.file)
--- /dev/null
+interface ftdi
+ftdi_vid_pid 0x0403 0x6010
+ftdi_channel 0
+ftdi_layout_init 0x00e8 0x60eb
+reset_config none
+
+source [find cpld/xilinx-xc7.cfg]
+source [find cpld/jtagspi.cfg]
+adapter_khz 25000
+
+proc fpga_program {} {
+ global _CHIPNAME
+ xc7_program $_CHIPNAME.tap
+}