1
0
mirror of https://github.com/antonblanchard/microwatt.git synced 2026-04-06 13:11:50 +00:00
Files
antonblanchard.microwatt/openocd/flash-arty
Boris Shingarov ed5807381e Recognize version string "0.12" in recent OpenOCD master
Starting from 5e7612eb4, OpenOCD identifies itself as 0.12.
This causes Microwatt's flash-arty script to fail.  Because neither
the cfg nor the proxy bitstream are affected, we can keep treating
everything as indistinguishable from 0.11.  This patch simply tests
for "0.12" as an alias; it would probably be better to replace this
confusing terminology with something like "single-tap/multi-tap".

Signed-off-by: Boris Shingarov <shingarov@labware.com>
2022-09-24 07:15:48 -04:00

58 lines
1.9 KiB
Python
Executable File

#!/usr/bin/python3
import argparse
import os
import subprocess
import sys
BASE = os.path.dirname(os.path.abspath(__file__))
def flash(cable, config, flash_proxy, address, data, filetype="", 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, filetype),
"fpga_program",
"exit"
])
print(script)
subprocess.call(["openocd", "-f", cable, "-f", config, "-c", script])
def get_version():
a = subprocess.run(["openocd", "-v"], capture_output=True)
if a.returncode != 0:
return ""
if a.stderr.count(b"0.10"):
return ""
if a.stderr.count(b"0.11"):
return "_openocd_v0.11"
if a.stderr.count(b"0.12"):
return "_openocd_v0.11"
parser = argparse.ArgumentParser()
parser.add_argument("file", help="file to write to flash")
parser.add_argument("-a", "--address", help="offset in flash", type=lambda x: int(x,0), default=0)
parser.add_argument("-f", "--fpga", help="a35, a100 or a200", default="a35")
parser.add_argument("-t", "--filetype", help="file type such as 'bin'", default="")
parser.add_argument("-c", "--cable", help="cable type such as 'arty'", default="arty")
args = parser.parse_args()
version = get_version()
if args.fpga.lower() == "a35":
proxy = "bscan_spi_xc7a35t{}.bit".format(version)
elif args.fpga.lower() == "a100":
proxy = "bscan_spi_xc7a100t{}.bit".format(version)
elif args.fpga.lower() == "a200":
proxy = "bscan_spi_xc7a200t{}.bit".format(version)
else:
print("error: specify a35, a100 or a200 when flashing")
sys.exit()
proxy = os.path.join(BASE, proxy)
config = os.path.join(BASE, "xilinx-xc7{}.cfg".format(version))
cable = os.path.join(BASE, "{}.cfg".format(args.cable))
flash(cable, config, proxy, args.address, args.file, args.filetype.lower())