diff --git a/src/SUMMARY.md b/src/SUMMARY.md index 2228032..36189e7 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -18,6 +18,7 @@ - [Sinara 9805 RF Power Amplifier Booster](./hw/booster.md) - [Sinara 8451 Thermostat](./hw/thermostat.md) - [Software/Support](./sw_sup/software_support.md) + - [Building legacy firmware](./sw_sup/artiq_legacy.md) - [Networking](./sw_sup/networking.md) - [DRTIO](./sw_sup/drtio.md) - [UART Logs](./sw_sup/uart_logs.md) diff --git a/src/extra/prep_pkg.py b/src/extra/prep_pkg.py new file mode 100644 index 0000000..e382963 --- /dev/null +++ b/src/extra/prep_pkg.py @@ -0,0 +1,35 @@ +import shutil +import os +import argparse +import zipfile + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("-v", default=None, help="Variant name") + parser.add_argument("-d", default="./artiq_kasli", help="path to built") + parser.add_argument("-o", default=None, help="output zip (default: kasli-.zip") + args = parser.parse_args() + if not args.v: + raise ValueError("need to specify variant!!") + basepath = os.path.abspath(args.d) + tempdir = os.path.join(basepath, "kasli-{}".format(args.v)) + try: + os.mkdir(tempdir) + except FileExistsError: + pass + shutil.copyfile(os.path.join(basepath, args.v, "gateware/top.bit"), os.path.join(tempdir, "top.bit")) + shutil.copyfile(os.path.join(basepath, args.v, "software/bootloader/bootloader.bin"), os.path.join(tempdir, "bootloader.bin")) + try: + shutil.copyfile(os.path.join(basepath, args.v, "software/runtime/runtime.elf"), os.path.join(tempdir, "runtime.elf")) + shutil.copyfile(os.path.join(basepath, args.v, "software/runtime/runtime.fbi"), os.path.join(tempdir, "runtime.fbi")) + except FileNotFoundError: + shutil.copyfile(os.path.join(basepath, args.v, "software/satman/satman.elf"), os.path.join(tempdir, "satman.elf")) + shutil.copyfile(os.path.join(basepath, args.v, "software/satman/satman.fbi"), os.path.join(tempdir, "satman.fbi")) + output = args.o if args.o else "kasli-{}".format(args.v) + + shutil.make_archive(output, "zip", tempdir) + shutil.rmtree(tempdir) + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/src/sw_sup/artiq_legacy.md b/src/sw_sup/artiq_legacy.md new file mode 100644 index 0000000..8e3a4b5 --- /dev/null +++ b/src/sw_sup/artiq_legacy.md @@ -0,0 +1,64 @@ +# Building ARTIQ-6 and earlier + +Pre-flake ARTIQ (that is 6 and earlier) requires slightly different steps for building. + +## Initial setup + +The following steps need to be done only once. + +First we will need to specify older nixpkg version - 21.05. Open ``~/.nix-channels`` with your favorite text editor. + +If there are any ``nixpkgs`` present already, comment them out with ``#``. + +Then add the following line: + +``` +https://nixos.org/channels/nixos-21.05 nixpkgs +``` + +Save and exit. + +Now, we need special ``nix-scripts`` to configure building environment, and a local copy of the artiq repository, in legacy release. + +```shell +mkdir artiq-legacy +cd artiq-legacy +git clone https://git.m-labs.hk/M-Labs/nix-scripts +git clone https://github.com/m-labs/artiq/ +cd artiq +git checkout release-6 # or release-5... +cd .. +``` + +## Setting up the environment and building firmware + +Within ``fish`` shell (others may not work correctly), set up the ARTIQ build environment: + +```shell +nix-shell -I artiqSrc= nix-scripts/artiq-fast/shell-dev.nix +``` + +Then build the required firmware as usual: + +```shell +python -m artiq.gateware.targets.kasli_generic .json +``` + +If you are building legacy ARTIQ for local use and you want to flash it, use: +```shell +artiq_flash -V -d artiq_kasli --srcbuild +``` + +There's a slight discrepancy from usual command - ``-V `` option is not present in ARTIQ-7+, but it is necessary here. + +If you want to send the binaries to a customer, there's no need packing up the whole build directory - only ``top.bit``, ``bootloader.bin`` and ``runtime.elf/fbi`` or ``satman.elf/fbi`` are necessary. You can use the ``prep_pkg.py`` script from extras to package them up neatly into a zip file for distributions: + +```shell +python prep_pkg.py -v -d artiq_kasli/ +``` + +Then the customer can use ``artiq_flash`` easily, after extracting the contents: + +```shell +artiq_flash -V -d . +``` \ No newline at end of file