commit 398b448a8c6b992f1aa366a99ffbae90fbdfa097 Author: Sebastien Bourdeauducq Date: Thu Oct 15 16:05:00 2020 +0800 initial commit diff --git a/artiq_netboot/__init__.py b/artiq_netboot/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/artiq_netboot/artiq_netboot.py b/artiq_netboot/artiq_netboot.py new file mode 100755 index 0000000..4f72b2c --- /dev/null +++ b/artiq_netboot/artiq_netboot.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python3 + +import argparse +import socket +import struct +import os + + +def send_file(sock, filename): + with open(filename, "rb") as input_file: + sock.sendall(struct.pack(">I", os.fstat(input_file.fileno()).st_size)) + while True: + data = input_file.read(4096) + if not data: + break + sock.sendall(data) + sock.sendall(b"OK") + + +def main(): + parser = argparse.ArgumentParser(description="ARTIQ netboot tool") + parser.add_argument("hostname", metavar="HOSTNAME", + help="hostname of the target board") + parser.add_argument("-f", "--firmware", nargs=1, + help="firmware to load") + # Note that on softcore systems, the main gateware cannot be replaced + # with -g. This option is used for loading the RTM FPGA from the AMC + # on Sayma, and the PL on Zynq. + parser.add_argument("-g", "--gateware", nargs=1, + help="gateware to load") + parser.add_argument("-b", "--boot", action="store_true", + help="boot the device") + args = parser.parse_args() + + sock = socket.create_connection((args.hostname, 4269)) + try: + if args.firmware is not None: + sock.sendall(b"F") + send_file(sock, args.firmware[0]) + if args.gateware is not None: + sock.sendall(b"G") + send_file(sock, args.gateware[0]) + if args.boot: + sock.sendall(b"B") + finally: + sock.close() + + +if __name__ == "__main__": + main() diff --git a/setup.py b/setup.py new file mode 100755 index 0000000..75d7b7b --- /dev/null +++ b/setup.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python3 + +from setuptools import setup, find_packages + +setup( + name="artiq_netboot", + author="M-Labs", + description="Simple netboot tool compatible with ARTIQ/MiSoC and SZL bootloaders", + license="LGPLv3+", + packages=find_packages(), + entry_points={ + "console_scripts": ["artiq_client = artiq.frontend.artiq_client:main"], + } +)