mirror of https://github.com/m-labs/artiq.git
artiq_flash: add srcbuild option to look into MiSoC source build trees. Closes #868
This commit is contained in:
parent
5e251cd85c
commit
71db953ea0
|
@ -45,6 +45,8 @@ Prerequisites:
|
||||||
"when several are connected.")
|
"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("--srcbuild", help="look for bitstream, BIOS and runtime in this "
|
||||||
|
"ARTIQ source build tree")
|
||||||
parser.add_argument("action", metavar="ACTION", nargs="*",
|
parser.add_argument("action", metavar="ACTION", nargs="*",
|
||||||
default="proxy gateware bios runtime start".split(),
|
default="proxy gateware bios runtime start".split(),
|
||||||
help="actions to perform, default: %(default)s")
|
help="actions to perform, default: %(default)s")
|
||||||
|
@ -220,7 +222,7 @@ def main():
|
||||||
else:
|
else:
|
||||||
bin_dir = os.path.join(artiq_dir, "binaries",
|
bin_dir = os.path.join(artiq_dir, "binaries",
|
||||||
"{}-{}".format(opts.target, adapter))
|
"{}-{}".format(opts.target, adapter))
|
||||||
if not os.path.exists(bin_dir) and opts.action != ["start"]:
|
if opts.srcbuild is None and not os.path.exists(bin_dir) and opts.action != ["start"]:
|
||||||
raise SystemExit("Binaries directory '{}' does not exist"
|
raise SystemExit("Binaries directory '{}' does not exist"
|
||||||
.format(bin_dir))
|
.format(bin_dir))
|
||||||
|
|
||||||
|
@ -241,22 +243,38 @@ def main():
|
||||||
raise SystemExit(
|
raise SystemExit(
|
||||||
"proxy gateware bitstream {} not found".format(config["proxy_bitfile"]))
|
"proxy gateware bitstream {} not found".format(config["proxy_bitfile"]))
|
||||||
elif action == "gateware":
|
elif action == "gateware":
|
||||||
bin = os.path.join(bin_dir, "top.bin")
|
if opts.srcbuild is None:
|
||||||
|
path = bin_dir
|
||||||
|
else:
|
||||||
|
path = os.path.join(opts.srcbuild, "gateware")
|
||||||
|
bin = os.path.join(path, "top.bin")
|
||||||
if not os.access(bin, os.R_OK):
|
if not os.access(bin, os.R_OK):
|
||||||
bin_handle, bin = tempfile.mkstemp()
|
bin_handle, bin = tempfile.mkstemp()
|
||||||
bit = os.path.join(bin_dir, "top.bit")
|
bit = os.path.join(path, "top.bit")
|
||||||
with open(bit, "rb") as f, open(bin_handle, "wb") as g:
|
with open(bit, "rb") as f, open(bin_handle, "wb") as g:
|
||||||
bit2bin(f, g)
|
bit2bin(f, g)
|
||||||
conv = True
|
conv = True
|
||||||
programmer.flash_binary(*config["gateware"], bin)
|
programmer.flash_binary(*config["gateware"], bin)
|
||||||
elif action == "bios":
|
elif action == "bios":
|
||||||
programmer.flash_binary(*config["bios"], os.path.join(bin_dir, "bios.bin"))
|
if opts.srcbuild is None:
|
||||||
|
path = bin_dir
|
||||||
|
else:
|
||||||
|
path = os.path.join(opts.srcbuild, "software", "bios")
|
||||||
|
programmer.flash_binary(*config["bios"], os.path.join(path, "bios.bin"))
|
||||||
elif action == "runtime":
|
elif action == "runtime":
|
||||||
programmer.flash_binary(*config["runtime"], os.path.join(bin_dir, "runtime.fbi"))
|
if opts.srcbuild is None:
|
||||||
|
path = bin_dir
|
||||||
|
else:
|
||||||
|
path = os.path.join(opts.srcbuild, "software", "runtime")
|
||||||
|
programmer.flash_binary(*config["runtime"], os.path.join(path, "runtime.fbi"))
|
||||||
elif action == "storage":
|
elif action == "storage":
|
||||||
programmer.flash_binary(*config["storage"], opts.storage)
|
programmer.flash_binary(*config["storage"], opts.storage)
|
||||||
elif action == "load":
|
elif action == "load":
|
||||||
programmer.load(os.path.join(bin_dir, "top.bit"))
|
if opts.srcbuild is None:
|
||||||
|
path = bin_dir
|
||||||
|
else:
|
||||||
|
path = os.path.join(opts.srcbuild, "gateware")
|
||||||
|
programmer.load(os.path.join(path, "top.bit"))
|
||||||
elif action == "start":
|
elif action == "start":
|
||||||
programmer.start()
|
programmer.start()
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue