61 lines
1.8 KiB
Python
61 lines
1.8 KiB
Python
import argparse
|
|
import tempfile
|
|
import subprocess
|
|
|
|
|
|
def get_load_cmd(platform, variant):
|
|
return \
|
|
'''target create xc7.spi0.proxy testee -chain-position xc7.tap
|
|
flash bank spi0 jtagspi 0 0 0 0 xc7.spi0.proxy 0x2
|
|
gdb_port disabled
|
|
tcl_port disabled
|
|
telnet_port disabled
|
|
set error_msg "Trying to use configured scan chain anyway"
|
|
if {[string first $error_msg [capture "init"]] != -1} {
|
|
puts "Found error and exiting"
|
|
exit}
|
|
xadc_report xc7.tap
|
|
pld load 0 {bscan_spi_xc7a100t.bit}
|
|
flash probe spi0
|
|
flash erase_sector spi0 0 42
|
|
flash write_bank spi0 {''' + "{}".format(get_bitstream_path(platform, variant)) + '''} 0x0
|
|
flash verify_bank spi0 {''' + "{}".format(get_bitstream_path(platform, variant)) + '''} 0x0
|
|
xc7_program xc7.tap
|
|
exit'''
|
|
|
|
def get_build_dir(platform, variant):
|
|
return "{}_{}_build".format(platform, variant)
|
|
|
|
def get_bitstream_path(platform, variant):
|
|
return get_build_dir(platform, variant)+"/top.bit"
|
|
|
|
def run(platform, script):
|
|
# Dump script to a temp file
|
|
with tempfile.NamedTemporaryFile(mode="w", delete=False) as f:
|
|
f.write(script)
|
|
|
|
board_path = {
|
|
"kasli": "board/kasli.cfg",
|
|
"efc": "efc.cfg",
|
|
}
|
|
subprocess.run([
|
|
"openocd", "-f", board_path[platform], "-f", f.name
|
|
])
|
|
|
|
supported_platform = [ "kasli", "efc" ]
|
|
supported_variants = [ "master", "satellite" ]
|
|
|
|
if __name__ == "__main__":
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("platform")
|
|
parser.add_argument("variant")
|
|
args = parser.parse_args()
|
|
|
|
if args.platform not in supported_platform:
|
|
raise ValueError("Unsupported platform")
|
|
if args.variant not in supported_variants:
|
|
raise ValueError("Unsupported variant")
|
|
|
|
script = get_load_cmd(args.platform, args.variant)
|
|
run(args.platform, script)
|