mirror of https://github.com/m-labs/artiq.git
artiq_flash: add preinit-command option
This commit is contained in:
parent
6089d44fd0
commit
4a57b52241
|
@ -5,6 +5,7 @@ import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import tempfile
|
import tempfile
|
||||||
import shutil
|
import shutil
|
||||||
|
from functools import partial
|
||||||
|
|
||||||
from artiq import __artiq_dir__ as artiq_dir
|
from artiq import __artiq_dir__ as artiq_dir
|
||||||
from artiq.frontend.bit2bin import bit2bin
|
from artiq.frontend.bit2bin import bit2bin
|
||||||
|
@ -38,8 +39,10 @@ Prerequisites:
|
||||||
help="target board, default: %(default)s")
|
help="target board, default: %(default)s")
|
||||||
parser.add_argument("-m", "--adapter", default=None,
|
parser.add_argument("-m", "--adapter", default=None,
|
||||||
help="target adapter, default: board-dependent")
|
help="target adapter, default: board-dependent")
|
||||||
parser.add_argument("--target-file", default=None,
|
parser.add_argument("--preinit-command", default=[], action="append",
|
||||||
help="use alternative OpenOCD target file")
|
help="add a pre-initialization OpenOCD command. "
|
||||||
|
"Useful for selecting a development board "
|
||||||
|
"when several are connected.")
|
||||||
parser.add_argument("-f", "--storage", help="write file to storage area")
|
parser.add_argument("-f", "--storage", help="write file to storage area")
|
||||||
parser.add_argument("-d", "--dir", help="look for files in this directory")
|
parser.add_argument("-d", "--dir", help="look for files in this directory")
|
||||||
parser.add_argument("action", metavar="ACTION", nargs="*",
|
parser.add_argument("action", metavar="ACTION", nargs="*",
|
||||||
|
@ -67,10 +70,15 @@ def proxy_path():
|
||||||
|
|
||||||
|
|
||||||
class Programmer:
|
class Programmer:
|
||||||
def __init__(self, target_file):
|
def __init__(self, target_file, preinit_commands):
|
||||||
self.target_file = target_file
|
self.target_file = target_file
|
||||||
|
self.preinit_commands = preinit_commands
|
||||||
self.prog = []
|
self.prog = []
|
||||||
|
|
||||||
|
def init(self):
|
||||||
|
self.prog.extend(self.preinit_commands)
|
||||||
|
self.prog.append("init")
|
||||||
|
|
||||||
def load(self, bitfile):
|
def load(self, bitfile):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
@ -96,9 +104,10 @@ class Programmer:
|
||||||
|
|
||||||
|
|
||||||
class ProgrammerJtagSpi7(Programmer):
|
class ProgrammerJtagSpi7(Programmer):
|
||||||
def __init__(self, target_file):
|
def __init__(self, target, preinit_commands):
|
||||||
Programmer.__init__(self, target_file)
|
Programmer.__init__(self, os.path.join("board", target + ".cfg"),
|
||||||
self.prog.append("init")
|
preinit_commands)
|
||||||
|
self.init()
|
||||||
|
|
||||||
def load(self, bitfile):
|
def load(self, bitfile):
|
||||||
self.prog.append("pld load 0 " + bitfile)
|
self.prog.append("pld load 0 " + bitfile)
|
||||||
|
@ -117,10 +126,9 @@ class ProgrammerJtagSpi7(Programmer):
|
||||||
|
|
||||||
|
|
||||||
class ProgrammerSayma(Programmer):
|
class ProgrammerSayma(Programmer):
|
||||||
def __init__(self, target_file):
|
def __init__(self, preinit_commands):
|
||||||
# TODO: use target_file
|
|
||||||
# TODO: support Sayma RTM
|
# TODO: support Sayma RTM
|
||||||
Programmer.__init__(self, None)
|
Programmer.__init__(self, None, preinit_commands)
|
||||||
self.proxy_loaded = False
|
self.proxy_loaded = False
|
||||||
self.prog += [
|
self.prog += [
|
||||||
"interface ftdi",
|
"interface ftdi",
|
||||||
|
@ -149,9 +157,8 @@ class ProgrammerSayma(Programmer):
|
||||||
"target create amc_xcu.proxy testee -chain-position amc_xcu.tap",
|
"target create amc_xcu.proxy testee -chain-position amc_xcu.tap",
|
||||||
"flash bank amc_xcu.spi0 jtagspi 0 0 0 0 amc_xcu.proxy $XILINX_USER1 $AMC_DR_LEN",
|
"flash bank amc_xcu.spi0 jtagspi 0 0 0 0 amc_xcu.proxy $XILINX_USER1 $AMC_DR_LEN",
|
||||||
"flash bank amc_xcu.spi1 jtagspi 0 0 0 0 amc_xcu.proxy $XILINX_USER2 $AMC_DR_LEN",
|
"flash bank amc_xcu.spi1 jtagspi 0 0 0 0 amc_xcu.proxy $XILINX_USER2 $AMC_DR_LEN",
|
||||||
|
|
||||||
"init"
|
|
||||||
]
|
]
|
||||||
|
self.init()
|
||||||
|
|
||||||
def load(self, bitfile):
|
def load(self, bitfile):
|
||||||
self.prog.append("pld load 0 " + bitfile)
|
self.prog.append("pld load 0 " + bitfile)
|
||||||
|
@ -180,7 +187,7 @@ def main():
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
"kc705": {
|
"kc705": {
|
||||||
"programmer_factory": ProgrammerJtagSpi7,
|
"programmer_factory": partial(ProgrammerJtagSpi7, "kc705"),
|
||||||
"proxy_bitfile": "bscan_spi_xc7k325t.bit",
|
"proxy_bitfile": "bscan_spi_xc7k325t.bit",
|
||||||
"adapters": ["nist_clock", "nist_qc2"],
|
"adapters": ["nist_clock", "nist_qc2"],
|
||||||
"gateware": (0, 0x000000),
|
"gateware": (0, 0x000000),
|
||||||
|
@ -216,11 +223,7 @@ def main():
|
||||||
raise SystemExit("Binaries directory '{}' does not exist"
|
raise SystemExit("Binaries directory '{}' does not exist"
|
||||||
.format(bin_dir))
|
.format(bin_dir))
|
||||||
|
|
||||||
if opts.target_file is None:
|
programmer = config["programmer_factory"](opts.preinit_command)
|
||||||
target_file = os.path.join("board", opts.target + ".cfg")
|
|
||||||
else:
|
|
||||||
target_file = opts.target_file
|
|
||||||
programmer = config["programmer_factory"](target_file)
|
|
||||||
|
|
||||||
conv = False
|
conv = False
|
||||||
for action in opts.action:
|
for action in opts.action:
|
||||||
|
|
Loading…
Reference in New Issue