artiq_flash: cleanup Sayma RTM management, support flashing AMC with RTM disconnected

This commit is contained in:
Sebastien Bourdeauducq 2020-04-14 18:22:06 +08:00
parent ea79ba4622
commit 77e6fdb7a7
1 changed files with 25 additions and 19 deletions

View File

@ -72,11 +72,11 @@ Prerequisites:
parser.add_argument("-d", "--dir", help="look for board binaries in this directory") parser.add_argument("-d", "--dir", help="look for board binaries in this directory")
parser.add_argument("--srcbuild", help="board binaries directory is laid out as a source build tree", parser.add_argument("--srcbuild", help="board binaries directory is laid out as a source build tree",
default=False, action="store_true") default=False, action="store_true")
parser.add_argument("--force-rtm", help="force RTM actions on boards/variants that normally do not have a RTM", parser.add_argument("--no-rtm-jtag", help="do not attempt JTAG to the RTM",
default=False, action="store_true") default=False, action="store_true")
parser.add_argument("action", metavar="ACTION", nargs="*", parser.add_argument("action", metavar="ACTION", nargs="*",
default="gateware rtm_gateware bootloader firmware start".split(), default=[],
help="actions to perform, default: %(default)s") help="actions to perform, default: flash everything")
return parser return parser
@ -233,7 +233,7 @@ class ProgrammerXC7(Programmer):
"xc7_program xc7.tap") "xc7_program xc7.tap")
class ProgrammerSayma(Programmer): class ProgrammerAMCRTM(Programmer):
_sector_size = 0x10000 _sector_size = 0x10000
def __init__(self, client, preinit_script): def __init__(self, client, preinit_script):
@ -270,7 +270,7 @@ class ProgrammerSayma(Programmer):
add_commands(self._script, "xcu_program xcu.tap") add_commands(self._script, "xcu_program xcu.tap")
class ProgrammerMetlino(Programmer): class ProgrammerAMC(Programmer):
_sector_size = 0x10000 _sector_size = 0x10000
def __init__(self, client, preinit_script): def __init__(self, client, preinit_script):
@ -316,7 +316,7 @@ def main():
"firmware": ("spi0", 0x450000), "firmware": ("spi0", 0x450000),
}, },
"sayma": { "sayma": {
"programmer": ProgrammerSayma, "programmer": ProgrammerAMCRTM,
"gateware": ("spi0", 0x000000), "gateware": ("spi0", 0x000000),
"bootloader": ("spi1", 0x000000), "bootloader": ("spi1", 0x000000),
"storage": ("spi1", 0x040000), "storage": ("spi1", 0x040000),
@ -324,7 +324,7 @@ def main():
"rtm_gateware": ("spi1", 0x200000), "rtm_gateware": ("spi1", 0x200000),
}, },
"metlino": { "metlino": {
"programmer": ProgrammerMetlino, "programmer": ProgrammerAMC,
"gateware": ("spi0", 0x000000), "gateware": ("spi0", 0x000000),
"bootloader": ("spi1", 0x000000), "bootloader": ("spi1", 0x000000),
"storage": ("spi1", 0x040000), "storage": ("spi1", 0x040000),
@ -343,7 +343,7 @@ def main():
if bin_dir is None: if bin_dir is None:
bin_dir = os.path.join(artiq_dir, "board-support") bin_dir = os.path.join(artiq_dir, "board-support")
needs_artifacts = any( needs_artifacts = not args.action or any(
action in args.action action in args.action
for action in ["gateware", "rtm_gateware", "bootloader", "firmware", "load", "rtm_load"]) for action in ["gateware", "rtm_gateware", "bootloader", "firmware", "load", "rtm_load"])
variant = args.variant variant = args.variant
@ -381,12 +381,22 @@ def main():
else: else:
rtm_variant_dir = "sayma-rtm" rtm_variant_dir = "sayma-rtm"
if not args.action:
if args.target == "sayma" and variant != "simplesatellite" and variant != "master":
args.action = "gateware rtm_gateware bootloader firmware start".split()
else:
args.action = "gateware bootloader firmware start".split()
if args.host is None: if args.host is None:
client = LocalClient() client = LocalClient()
else: else:
client = SSHClient(args.host, args.jump) client = SSHClient(args.host, args.jump)
programmer = config["programmer"](client, preinit_script=args.preinit_command) if args.target == "sayma" and args.no_rtm_jtag:
programmer_cls = ProgrammerAMC
else:
programmer_cls = config["programmer"]
programmer = programmer_cls(client, preinit_script=args.preinit_command)
def artifact_path(this_variant_dir, *path_filename): def artifact_path(this_variant_dir, *path_filename):
if args.srcbuild: if args.srcbuild:
@ -420,8 +430,6 @@ def main():
artifact_path(variant_dir, "gateware", "top.bit")) artifact_path(variant_dir, "gateware", "top.bit"))
programmer.write_binary(*config["gateware"], gateware_bin) programmer.write_binary(*config["gateware"], gateware_bin)
elif action == "rtm_gateware": elif action == "rtm_gateware":
if args.force_rtm or (
args.target == "sayma" and variant != "simplesatellite" and variant != "master"):
rtm_gateware_bin = convert_gateware( rtm_gateware_bin = convert_gateware(
artifact_path(rtm_variant_dir, "gateware", "top.bit"), header=True) artifact_path(rtm_variant_dir, "gateware", "top.bit"), header=True)
programmer.write_binary(*config["rtm_gateware"], programmer.write_binary(*config["rtm_gateware"],
@ -448,8 +456,6 @@ def main():
gateware_bit = artifact_path(variant_dir, "gateware", "top.bit") gateware_bit = artifact_path(variant_dir, "gateware", "top.bit")
programmer.load(gateware_bit, 0) programmer.load(gateware_bit, 0)
elif action == "rtm_load": elif action == "rtm_load":
if args.force_rtm or (
args.target == "sayma" and variant != "simplesatellite" and variant != "master"):
rtm_gateware_bit = artifact_path(rtm_variant_dir, "gateware", "top.bit") rtm_gateware_bit = artifact_path(rtm_variant_dir, "gateware", "top.bit")
programmer.load(rtm_gateware_bit, 0) programmer.load(rtm_gateware_bit, 0)
elif action == "start": elif action == "start":