forked from M-Labs/artiq
1
0
Fork 0

artiq_flash: make the proxy action unnecessary.

This commit is contained in:
whitequark 2018-01-27 15:43:27 +00:00
parent d58393a1e5
commit eed2db3a98
1 changed files with 50 additions and 46 deletions

View File

@ -8,6 +8,7 @@ import shutil
import re
import atexit
from functools import partial
from collections import defaultdict
from artiq import __artiq_dir__ as artiq_dir
from artiq.tools import verbosity_args, init_logger
@ -62,7 +63,7 @@ Prerequisites:
parser.add_argument("--srcbuild", help="look for bitstream, bootloader and firmware in this "
"ARTIQ source build tree")
parser.add_argument("action", metavar="ACTION", nargs="*",
default="proxy gateware bootloader firmware start".split(),
default="gateware bootloader firmware start".split(),
help="actions to perform, default: %(default)s")
return parser
@ -104,6 +105,7 @@ class Programmer:
self._client = client
self._board_script = []
self._preinit_script = preinit_script
self._loaded = defaultdict(lambda: None)
self._script = []
def _transfer_script(self, script):
@ -125,6 +127,12 @@ class Programmer:
tap=tap, name=name, ir=0x02 + index)
def load(self, bitfile, pld):
os.stat(bitfile) # check for existence
if self._loaded[pld] == bitfile:
return
self._loaded[pld] = bitfile
bitfile = self._client.transfer_file(bitfile)
add_commands(self._script,
"pld load {pld} {filename}",
@ -134,6 +142,8 @@ class Programmer:
raise NotImplementedError
def flash_binary(self, bankname, address, filename):
self.load_proxy()
size = os.path.getsize(filename)
filename = self._client.transfer_file(filename)
add_commands(self._script,
@ -269,10 +279,6 @@ def main():
bin_name += "-" + variant
bin_dir = os.path.join(artiq_dir, "binaries", bin_name)
if args.srcbuild is None and not os.path.exists(bin_dir) and args.action != ["start"]:
raise SystemExit("Binaries directory '{}' does not exist"
.format(bin_dir))
if args.host is None:
client = LocalClient()
else:
@ -287,13 +293,9 @@ def main():
else:
return os.path.join(args.srcbuild, *path_filename)
for action in args.action:
if action == "proxy":
try:
programmer.load_proxy()
except FileNotFoundError as e:
raise SystemExit(e)
elif action == "gateware":
for action in args.action:
if action == "gateware":
gateware_bin = artifact_path("gateware", "top.bin")
if not os.access(gateware_bin, os.R_OK):
bin_handle, gateware_bin = tempfile.mkstemp()
@ -331,6 +333,8 @@ def main():
programmer.start()
else:
raise ValueError("invalid action", action)
except FileNotFoundError as e:
raise SystemExit(e)
if args.dry_run:
print("\n".join(programmer.script()))