2
0
mirror of https://github.com/m-labs/artiq.git synced 2024-12-27 04:08:27 +08:00

coremgmt frontend: add artiq flash like source tree support

This commit is contained in:
occheung 2024-09-03 12:37:32 +08:00
parent d935c22aad
commit 1874438890

View File

@ -97,6 +97,10 @@ def get_argparser():
p_directory = t_flash.add_argument("directory", metavar="DIRECTORY", type=str, p_directory = t_flash.add_argument("directory", metavar="DIRECTORY", type=str,
help="directory that contains the binaries") help="directory that contains the binaries")
p_srcbuild = t_flash.add_argument("--srcbuild",
help="board binaries directory is laid out as a source build tree",
default=False, action="store_true")
# misc debug # misc debug
t_debug = tools.add_parser("debug", t_debug = tools.add_parser("debug",
help="specialized debug functions") help="specialized debug functions")
@ -156,6 +160,15 @@ def main():
mgmt.config_erase() mgmt.config_erase()
if args.tool == "flash": if args.tool == "flash":
def artifact_path(this_binary_dir, *path_filename):
if args.srcbuild:
# source tree - use path elements to locate file
return os.path.join(this_binary_dir, *path_filename)
else:
# flat tree - all files in the same directory, discard path elements
*_, filename = path_filename
return os.path.join(this_binary_dir, filename)
def convert_gateware(bit_filename): def convert_gateware(bit_filename):
bin_handle, bin_filename = tempfile.mkstemp( bin_handle, bin_filename = tempfile.mkstemp(
prefix="artiq_", suffix="_" + os.path.basename(bit_filename)) prefix="artiq_", suffix="_" + os.path.basename(bit_filename))
@ -164,12 +177,13 @@ def main():
atexit.register(lambda: os.unlink(bin_filename)) atexit.register(lambda: os.unlink(bin_filename))
return bin_filename return bin_filename
gateware = convert_gateware(os.path.join(args.directory, "top.bit")) gateware = convert_gateware(
bootloader = os.path.join(args.directory, "bootloader.bin") artifact_path(args.directory, "gateware", "top.bit"))
bootloader = artifact_path(args.directory, "software", "bootloader", "bootloader.bin")
firmwares = [] firmwares = []
for firmware in "satman", "runtime": for firmware in "satman", "runtime":
filename = os.path.join(args.directory, firmware + ".fbi") filename = artifact_path(args.directory, "software", firmware, firmware + ".fbi")
if os.path.exists(filename): if os.path.exists(filename):
firmwares.append(filename) firmwares.append(filename)
if not firmwares: if not firmwares: