forked from M-Labs/artiq
1
0
Fork 0

artiq_flash: flash RTM firmware

based on whitequark's work in f95fb27

m-labs/artiq#813
This commit is contained in:
Robert Jördens 2018-02-28 16:47:02 +00:00 committed by Robert Jordens
parent 0c49201be7
commit 54984f080b
2 changed files with 44 additions and 27 deletions

View File

@ -278,6 +278,7 @@ def main():
"bootloader": ("spi1", 0x000000), "bootloader": ("spi1", 0x000000),
"storage": ("spi1", 0x040000), "storage": ("spi1", 0x040000),
"firmware": ("spi1", 0x050000), "firmware": ("spi1", 0x050000),
"rtm_gateware": ("spi1", 0x150000),
}, },
}[args.target] }[args.target]
@ -309,18 +310,34 @@ def main():
else: else:
return os.path.join(args.srcbuild, *path_filename) return os.path.join(args.srcbuild, *path_filename)
def convert_gateware(bit_filename, header=False):
bin_handle, bin_filename = tempfile.mkstemp(
prefix="artiq_", suffix="_" + os.path.basename(bit_filename))
with open(bit_filename, "rb") as bit_file, \
open(bin_handle, "wb") as bin_file:
if header:
bin_file.write(b"\x00"*8)
bit2bin(bit_file, bin_file)
if header:
magic = 0x53415231 # "SAR1"
length = bin_file.tell() - 8
bin_file.seek(0)
bin_file.write(magic.to_bytes(4, byteorder="big"))
bin_file.write(length.to_bytes(4, byteorder="big"))
atexit.register(lambda: os.unlink(bin_filename))
return bin_filename
try: try:
for action in args.action: for action in args.action:
if action == "gateware": if action == "gateware":
gateware_bin = artifact_path(variant, "gateware", "top.bin") gateware_bin = convert_gateware(
if not os.access(gateware_bin, os.R_OK): artifact_path(variant, "gateware", "top.bit"))
bin_handle, gateware_bin = tempfile.mkstemp()
gateware_bit = artifact_path(variant, "gateware", "top.bit")
with open(gateware_bit, "rb") as bit_file, open(bin_handle, "wb") as bin_file:
bit2bin(bit_file, bin_file)
atexit.register(lambda: os.unlink(gateware_bin))
programmer.write_binary(*config["gateware"], gateware_bin) programmer.write_binary(*config["gateware"], gateware_bin)
if args.target == "sayma":
rtm_gateware_bin = convert_gateware(
artifact_path("rtm_gateware", "rtm.bit"), header=True)
programmer.write_binary(*config["rtm_gateware"],
rtm_gateware_bin)
elif action == "bootloader": elif action == "bootloader":
bootloader_bin = artifact_path(variant, "software", "bootloader", "bootloader.bin") bootloader_bin = artifact_path(variant, "software", "bootloader", "bootloader.bin")
programmer.write_binary(*config["bootloader"], bootloader_bin) programmer.write_binary(*config["bootloader"], bootloader_bin)

View File

@ -171,7 +171,7 @@ class Standalone(MiniSoC, AMPSoC):
]) ])
self.csr_devices.append("slave_fpga_cfg") self.csr_devices.append("slave_fpga_cfg")
self.config["HAS_SLAVE_FPGA"] = None self.config["HAS_SLAVE_FPGA"] = None
self.config["SLAVE_FPGA_GATEWARE"] = 0xde0000 self.config["SLAVE_FPGA_GATEWARE"] = 0x150000
# AMC/RTM serwb # AMC/RTM serwb
serwb_pll = serwb.phy.SERWBPLL(125e6, 625e6, vco_div=2) serwb_pll = serwb.phy.SERWBPLL(125e6, 625e6, vco_div=2)