From 11a8b84355d7a73e9b6ae72f20617e0a23fb30e7 Mon Sep 17 00:00:00 2001 From: whitequark Date: Sat, 27 Jan 2018 19:53:43 +0000 Subject: [PATCH] Merge the build trees of sayma_amc and sayma_rtm targets. This also makes them a single artiq_flash target, and a single conda package. --- .gitignore | 1 + artiq/frontend/artiq_devtool.py | 29 ++++++++++--------- artiq/frontend/artiq_flash.py | 15 ++++------ artiq/gateware/targets/sayma_amc.py | 3 +- artiq/gateware/targets/sayma_rtm.py | 6 ++-- conda/artiq-sayma-standalone/build.sh | 13 +++++++++ .../meta.yaml | 4 +-- conda/artiq-sayma_amc-standalone/build.sh | 9 ------ conda/artiq-sayma_amc-standalone/meta.yaml | 24 --------------- conda/artiq-sayma_rtm/build.sh | 11 ------- 10 files changed, 41 insertions(+), 74 deletions(-) create mode 100644 conda/artiq-sayma-standalone/build.sh rename conda/{artiq-sayma_rtm => artiq-sayma-standalone}/meta.yaml (88%) delete mode 100644 conda/artiq-sayma_amc-standalone/build.sh delete mode 100644 conda/artiq-sayma_amc-standalone/meta.yaml delete mode 100644 conda/artiq-sayma_rtm/build.sh diff --git a/.gitignore b/.gitignore index 91ffc1c07..0fc39b517 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ __pycache__/ /artiq/binaries /artiq/firmware/target/ /misoc_*/ +/artiq_*/ /artiq/test/results /artiq/examples/*/results diff --git a/artiq/frontend/artiq_devtool.py b/artiq/frontend/artiq_devtool.py index 04b112728..9d76f65a0 100755 --- a/artiq/frontend/artiq_devtool.py +++ b/artiq/frontend/artiq_devtool.py @@ -31,7 +31,7 @@ def get_argparser(): parser.add_argument("-t", "--target", metavar="TARGET", type=str, default="kc705", help="target to build, one of: " - "kc705 kasli sayma_rtm sayma_amc") + "kc705 kasli sayma") parser.add_argument("-g", "--build-gateware", default=False, action="store_true", help="build gateware, not just software") @@ -71,14 +71,10 @@ def main(): def build_dir(*path, target=args.target): return os.path.join("/tmp", target, *path) - extra_build_args = [] if args.target == "kc705": board_type, firmware = "kc705", "runtime" - elif args.target == "sayma_amc": - board_type, firmware = "sayma_amc", "runtime" - extra_build_args += ["--rtm-csr-csv", build_dir("sayma_rtm_csr.csv", target="sayma_rtm")] - elif args.target == "sayma_rtm": - board_type, firmware = "sayma_rtm", None + elif args.target == "sayma": + board_type, firmware = "sayma", "runtime" else: raise NotImplementedError("unknown target {}".format(args.target)) @@ -132,6 +128,13 @@ def main(): logger.error(on_failure) sys.exit(1) + def build(target, *extra_args, output_dir=build_dir()): + build_args = ["python3", "-m", "artiq.gateware.targets." + target, *extra_args] + if not args.build_gateware: + build_args.append("--no-compile-gateware") + build_args += ["--output-dir", output_dir] + command(*build_args, on_failure="Build failed") + def flash(*steps): lock() @@ -147,13 +150,11 @@ def main(): for action in args.actions: if action == "build": logger.info("Building target") - - build_args = ["python3", "-m", "artiq.gateware.targets." + args.target] - if not args.build_gateware: - build_args.append("--no-compile-gateware") - build_args += ["--output-dir", build_dir()] - build_args += extra_build_args - command(*build_args, on_failure="Build failed") + if args.target == "sayma": + build("sayma_rtm", output_dir=build_dir("rtm")) + build("sayma_amc", "--rtm-csr-csv", build_dir("rtm", "rtm_csr.csv")) + else: + build(args.target) elif action == "clean": logger.info("Cleaning build directory") diff --git a/artiq/frontend/artiq_flash.py b/artiq/frontend/artiq_flash.py index e1ced8702..6f6ebc8ce 100755 --- a/artiq/frontend/artiq_flash.py +++ b/artiq/frontend/artiq_flash.py @@ -51,7 +51,7 @@ Prerequisites: help="SSH host where the development board is located") parser.add_argument("-t", "--target", default="kc705", help="target board, default: %(default)s, one of: " - "kc705 kasli sayma_amc sayma_rtm") + "kc705 kasli sayma") parser.add_argument("-V", "--variant", default=None, help="board variant") parser.add_argument("-I", "--preinit-command", default=[], action="append", @@ -263,7 +263,7 @@ def main(): "storage": ("spi0", 0x440000), "firmware": ("spi0", 0x450000), }, - "sayma_amc": { + "sayma": { "programmer": ProgrammerSayma, "variants": ["standalone", "master", "satellite"], "gateware": ("spi0", 0x000000), @@ -271,10 +271,6 @@ def main(): "storage": ("spi1", 0x040000), "firmware": ("spi1", 0x050000), }, - "sayma_rtm": { - "programmer": ProgrammerSayma, - "gateware": ("spi1", 0x150000), - }, }[args.target] variant = args.variant @@ -332,10 +328,9 @@ def main(): firmware_fbi = artifact_path("software", firmware, firmware + ".fbi") programmer.write_binary(*config["firmware"], firmware_fbi) elif action == "load": - if args.target == "sayma_rtm": - gateware_bit = artifact_path("top.bit") - programmer.load(gateware_bit, 0) - elif args.target == "sayma_amc": + if args.target == "sayma": + rtm_gateware_bit = artifact_path("rtm", "rtm.bit") + programmer.load(rtm_gateware_bit, 0) gateware_bit = artifact_path("gateware", "top.bit") programmer.load(gateware_bit, 1) else: diff --git a/artiq/gateware/targets/sayma_amc.py b/artiq/gateware/targets/sayma_amc.py index 43307c2f9..938d054a2 100755 --- a/artiq/gateware/targets/sayma_amc.py +++ b/artiq/gateware/targets/sayma_amc.py @@ -439,12 +439,13 @@ def main(): description="Sayma AMC gateware and firmware builder") builder_args(parser) soc_sdram_args(parser) + parser.set_defaults(output_dir="artiq_sayma") parser.add_argument("-V", "--variant", default="standalone", help="variant: " "standalone/master/satellite " "(default: %(default)s)") parser.add_argument("--rtm-csr-csv", - default=os.path.join("artiq_sayma_rtm", "sayma_rtm_csr.csv"), + default=os.path.join("artiq_sayma", "rtm", "rtm_csr.csv"), help="CSV file listing remote CSRs on RTM (default: %(default)s)") parser.add_argument("--without-sawg", default=False, action="store_true", diff --git a/artiq/gateware/targets/sayma_rtm.py b/artiq/gateware/targets/sayma_rtm.py index 6f7c9ee1c..cf4ad3fdf 100755 --- a/artiq/gateware/targets/sayma_rtm.py +++ b/artiq/gateware/targets/sayma_rtm.py @@ -190,7 +190,7 @@ class SaymaRTM(Module): def main(): parser = argparse.ArgumentParser( description="ARTIQ device binary builder for Kasli systems") - parser.add_argument("--output-dir", default="artiq_sayma_rtm", + parser.add_argument("--output-dir", default="artiq_sayma/rtm", help="output directory for generated " "source files and binaries") parser.add_argument("--no-compile-gateware", action="store_true", @@ -205,11 +205,11 @@ def main(): top = SaymaRTM(platform) os.makedirs(args.output_dir, exist_ok=True) - with open(os.path.join(args.output_dir, "sayma_rtm_csr.csv"), "w") as f: + with open(os.path.join(args.output_dir, "rtm_csr.csv"), "w") as f: f.write(get_csr_csv(top.csr_regions)) if not args.no_compile_gateware: - platform.build(top, build_dir=args.output_dir) + platform.build(top, build_dir=args.output_dir, build_name="rtm") if __name__ == "__main__": diff --git a/conda/artiq-sayma-standalone/build.sh b/conda/artiq-sayma-standalone/build.sh new file mode 100644 index 000000000..a333452d1 --- /dev/null +++ b/conda/artiq-sayma-standalone/build.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +SOC_PREFIX=$PREFIX/lib/python3.5/site-packages/artiq/binaries/sayma-standalone +mkdir -p $SOC_PREFIX + +$PYTHON -m artiq.gateware.targets.sayma_rtm +cp artiq_sayma/rtm_gateware/rtm.bit $SOC_PREFIX + +$PYTHON -m artiq.gateware.targets.sayma_amc -V standalone \ + --rtm-csr-csv artiq_sayma/rtm/sayma_rtm_csr.csv +cp artiq_sayma/gateware/top.bit $SOC_PREFIX +cp artiq_sayma/software/bootloader/bootloader.bin $SOC_PREFIX +cp artiq_sayma/software/runtime/runtime.{elf,fbi} $SOC_PREFIX diff --git a/conda/artiq-sayma_rtm/meta.yaml b/conda/artiq-sayma-standalone/meta.yaml similarity index 88% rename from conda/artiq-sayma_rtm/meta.yaml rename to conda/artiq-sayma-standalone/meta.yaml index 0aed97148..cb717d376 100644 --- a/conda/artiq-sayma_rtm/meta.yaml +++ b/conda/artiq-sayma-standalone/meta.yaml @@ -1,5 +1,5 @@ package: - name: artiq-sayma_rtm + name: artiq-sayma-standalone version: {{ environ.get("GIT_DESCRIBE_TAG", "") }} source: @@ -20,4 +20,4 @@ requirements: about: home: https://m-labs.hk/artiq license: LGPL - summary: 'Bitstream and CSR map for Sayma RTM' + summary: 'AMC and RTM bitstream, BIOS and runtime for stand-alone Sayma AMC' diff --git a/conda/artiq-sayma_amc-standalone/build.sh b/conda/artiq-sayma_amc-standalone/build.sh deleted file mode 100644 index 918638a50..000000000 --- a/conda/artiq-sayma_amc-standalone/build.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -SOC_PREFIX=$PREFIX/lib/python3.5/site-packages/artiq/binaries/sayma_amc-standalone -mkdir -p $SOC_PREFIX - -V=1 $PYTHON -m artiq.gateware.targets.sayma_amc -V standalone --rtm-csr-csv $SP_DIR/artiq/binaries/sayma_rtm/sayma_rtm_csr.csv -cp misoc_standalone_sayma_amc/gateware/top.bit $SOC_PREFIX -cp misoc_standalone_sayma_amc/software/bootloader/bootloader.bin $SOC_PREFIX -cp misoc_standalone_sayma_amc/software/runtime/runtime.{elf,fbi} $SOC_PREFIX diff --git a/conda/artiq-sayma_amc-standalone/meta.yaml b/conda/artiq-sayma_amc-standalone/meta.yaml deleted file mode 100644 index 832f7326a..000000000 --- a/conda/artiq-sayma_amc-standalone/meta.yaml +++ /dev/null @@ -1,24 +0,0 @@ -package: - name: artiq-sayma_amc-standalone - version: {{ environ.get("GIT_DESCRIBE_TAG", "") }} - -source: - git_url: ../.. - -build: - noarch: python - ignore_prefix_files: True - number: {{ environ.get("GIT_DESCRIBE_NUMBER", 0) }} - string: py_{{ environ.get("GIT_DESCRIBE_NUMBER", 0) }}+git{{ environ.get("GIT_FULL_HASH", "")[:8] }} - -requirements: - build: - - artiq-dev {{ "{tag} py_{number}+git{hash}".format(tag=environ.get("GIT_DESCRIBE_TAG"), number=environ.get("GIT_DESCRIBE_NUMBER"), hash=environ.get("GIT_FULL_HASH", "")[:8]) if "GIT_DESCRIBE_TAG" in environ else "" }} - - artiq-sayma_rtm {{ "{tag} py_{number}+git{hash}".format(tag=environ.get("GIT_DESCRIBE_TAG"), number=environ.get("GIT_DESCRIBE_NUMBER"), hash=environ.get("GIT_FULL_HASH", "")[:8]) if "GIT_DESCRIBE_TAG" in environ else "" }} - run: - - artiq {{ "{tag} py_{number}+git{hash}".format(tag=environ.get("GIT_DESCRIBE_TAG"), number=environ.get("GIT_DESCRIBE_NUMBER"), hash=environ.get("GIT_FULL_HASH", "")[:8]) if "GIT_DESCRIBE_TAG" in environ else "" }} - -about: - home: https://m-labs.hk/artiq - license: LGPL - summary: 'Bitstream, BIOS and runtime for stand-alone Sayma AMC' diff --git a/conda/artiq-sayma_rtm/build.sh b/conda/artiq-sayma_rtm/build.sh deleted file mode 100644 index 5b9476ac7..000000000 --- a/conda/artiq-sayma_rtm/build.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -BUILD_SETTINGS_FILE=$HOME/.m-labs/build_settings.sh -[ -f $BUILD_SETTINGS_FILE ] && . $BUILD_SETTINGS_FILE - -SOC_PREFIX=$PREFIX/lib/python3.5/site-packages/artiq/binaries/sayma_rtm -mkdir -p $SOC_PREFIX - -$PYTHON -m artiq.gateware.targets.sayma_rtm -cp artiq_sayma_rtm/top.bit $SOC_PREFIX -cp artiq_sayma_rtm/sayma_rtm_csr.csv $SOC_PREFIX