artiq_flash: determine which firmware to flash by looking at filesystem

Closes #1719
This commit is contained in:
Sebastien Bourdeauducq 2021-07-14 16:43:00 +08:00
parent 5cd721c514
commit 4fb8ea5b73
1 changed files with 11 additions and 7 deletions

View File

@ -446,13 +446,17 @@ def main():
storage_img = args.storage
programmer.write_binary(*config["storage"], storage_img)
elif action == "firmware":
if variant.endswith("satellite"):
firmware = "satman"
else:
firmware = "runtime"
firmware_fbi = artifact_path(variant_dir, "software", firmware, firmware + ".fbi")
programmer.write_binary(*config["firmware"], firmware_fbi)
firmware_fbis = []
for firmware in "satman", "runtime":
filename = artifact_path(variant_dir, "software", firmware, firmware + ".fbi")
if os.path.exists(filename):
firmware_fbis.append(filename)
if not firmware_fbis:
raise FileNotFoundError("no firmware found")
if len(firmware_fbis) > 1:
raise ValueError("more than one firmware file, please clean up your build directory. "
"Found firmware files: {}".format(" ".join(firmware_fbis)))
programmer.write_binary(*config["firmware"], firmware_fbis[0])
elif action == "load":
if args.target == "sayma":
gateware_bit = artifact_path(variant_dir, "gateware", "top.bit")