add impure incremental build process, document

core0-buffer
parent 92ae487143
commit 2439ba1f88
  1. 5
      .gitignore
  2. 23
      README.md
  3. 66
      default.nix
  4. 1
      firmware/cargosha256.nix
  5. 31
      remote_run.sh
  6. 28
      shell.nix
  7. 0
      src/.cargo/config
  8. 0
      src/Cargo.lock
  9. 0
      src/Cargo.toml
  10. 23
      src/Makefile
  11. 0
      src/armv7-none-eabihf.json
  12. 0
      src/libdyld/Cargo.toml
  13. 0
      src/libdyld/src/elf.rs
  14. 0
      src/libdyld/src/file.rs
  15. 0
      src/libdyld/src/image.rs
  16. 0
      src/libdyld/src/lib.rs
  17. 0
      src/libdyld/src/reloc.rs
  18. 0
      src/runtime/Cargo.toml
  19. 0
      src/runtime/build.rs
  20. 0
      src/runtime/link.x
  21. 0
      src/runtime/src/comms.rs
  22. 0
      src/runtime/src/kernel.rs
  23. 0
      src/runtime/src/main.rs
  24. 0
      src/runtime/src/moninj.rs
  25. 0
      src/runtime/src/proto.rs
  26. 0
      src/runtime/src/rtio.rs
  27. 0
      src/szl/Cargo.toml
  28. 0
      src/szl/build.rs
  29. 0
      src/szl/link.x
  30. 0
      src/szl/src/main.rs
  31. 0
      src/szl/src/unlzma.c
  32. 18
      src/zc706.py

5
.gitignore vendored

@ -1,3 +1,8 @@
result
examples/*.elf
__pycache__
src/runtime/src/pl.rs
src/szl/src/payload.bin
src/szl/src/payload.bin.lzma
src/target

@ -0,0 +1,23 @@
Configure Nix channels:
``
nix-channel --add https://nixbld.m-labs.hk/channel/custom/artiq/fast-beta/artiq-fast
nix-channel --update
``
Pure build with Nix:
``
nix-build -A zc706-jtag
./remote_run.sh
``
Impure incremental build:
``
nix-shell
cd src
./zc706.py -g # build gateware
make # build firmware
cd ..
./remote_run.sh -i
``
The impure build process can also be used on non-Nix systems.

@ -6,59 +6,49 @@ let
pkgs = import <nixpkgs> { overlays = [ mozillaOverlay ]; };
artiq-fast = <artiq-fast>;
rustPlatform = (import ./rustPlatform.nix { inherit pkgs; });
buildFirmware = { name, src }:
rustPlatform.buildRustPackage rec {
inherit name;
artiqpkgs = import "${artiq-fast}/default.nix" { inherit pkgs; };
vivado = import "${artiq-fast}/vivado.nix" { inherit pkgs; };
in
rec {
zc706-szl = rustPlatform.buildRustPackage rec {
name = "szl";
version = "0.1.0";
inherit src;
cargoSha256 = (import "${src}/cargosha256.nix");
src = ./src;
cargoSha256 = "199qfs7fbbj8kxkyb0dcns6hdq9hvlppk7l3pnz204j9zkd7dkcp";
nativeBuildInputs = [ pkgs.cargo-xbuild pkgs.llvm_9 pkgs.clang_9 ];
nativeBuildInputs = [
pkgs.gnumake
(pkgs.python3.withPackages(ps: (with artiqpkgs; [ migen migen-axi misoc artiq ])))
pkgs.cargo-xbuild
pkgs.llvm_9
pkgs.clang_9
];
buildPhase = ''
export XARGO_RUST_SRC="${rustPlatform.rust.rustc.src}/src"
export CARGO_HOME=$(mktemp -d cargo-home.XXX)
cargo xbuild --release -p ${name}
make clean
make
'';
doCheck = false;
installPhase = ''
mkdir -p $out $out/nix-support
cp target/armv7-none-eabihf/release/${name} $out/${name}.elf
echo file binary-dist $out/${name}.elf >> $out/nix-support/hydra-build-products
cp target/armv7-none-eabihf/release/szl $out/$szl.elf
echo file binary-dist $out/szl.elf >> $out/nix-support/hydra-build-products
'';
doCheck = false;
dontFixup = true;
};
artiqpkgs = import "${artiq-fast}/default.nix" { inherit pkgs; };
vivado = import "${artiq-fast}/vivado.nix" { inherit pkgs; };
in
rec {
zc706-runtime-src = pkgs.runCommand "zc706-runtime-src"
{ buildInputs = [
(pkgs.python3.withPackages(ps: (with artiqpkgs; [ migen migen-axi misoc artiq ])))
]; }
''
cp --no-preserve=mode,ownership -R ${./firmware} $out
cd $out/runtime/src
python ${./zc706.py} rustif
'';
zc706-runtime = buildFirmware { name = "runtime"; src = zc706-runtime-src; };
zc706-szl-src = pkgs.runCommand "zc706-szl-src"
{ nativeBuildInputs = [ pkgs.llvm_9 ]; }
''
cp --no-preserve=mode,ownership -R ${./firmware} $out
llvm-objcopy -O binary ${zc706-runtime}/runtime.elf $out/szl/src/payload.bin
lzma $out/szl/src/payload.bin
'';
zc706-szl = buildFirmware { name = "szl"; src = zc706-szl-src; };
zc706-gateware = pkgs.runCommand "zc706-gateware"
{ buildInputs = [
(pkgs.python3.withPackages(ps: (with artiqpkgs; [ migen migen-axi misoc artiq ])))
vivado
]; }
{
nativeBuildInputs = [
(pkgs.python3.withPackages(ps: (with artiqpkgs; [ migen migen-axi misoc artiq ])))
vivado
];
}
''
python ${./zc706.py} gateware
python ${./src/zc706.py} -g
mkdir -p $out $out/nix-support
cp build/top.bit $out
echo file binary-dist $out/top.bit >> $out/nix-support/hydra-build-products

@ -1 +0,0 @@
"199qfs7fbbj8kxkyb0dcns6hdq9hvlppk7l3pnz204j9zkd7dkcp"

@ -2,12 +2,29 @@
set -e
TARGET_HOST=$1
target_host="rpi-4.m-labs.hk"
impure=0
TARGET_FOLDER=/tmp/zynq-\$USER
while getopts "h:i" opt; do
case "$opt" in
\?) exit 0
;;
h) target_host=$OPTARG
;;
i) impure=1
;;
esac
done
ssh $TARGET_HOST "mkdir -p $TARGET_FOLDER"
rsync openocd/* $TARGET_HOST:$TARGET_FOLDER
rsync result/szl $TARGET_HOST:$TARGET_FOLDER
rsync result/top.bit $TARGET_HOST:$TARGET_FOLDER
ssh $TARGET_HOST "cd $TARGET_FOLDER; openocd -f zc706.cfg -c 'pld load 0 top.bit; load_image szl; resume 0; exit'"
target_folder=/tmp/zynq-\$USER
ssh $target_host "mkdir -p $target_folder"
rsync openocd/* $target_host:$target_folder
if [ $impure -eq 1 ]; then
rsync src/target/armv7-none-eabihf/release/szl $target_host:$target_folder
rsync src/build/top.bit $target_host:$target_folder
else
rsync result/szl $target_host:$target_folder
rsync result/top.bit $target_host:$target_folder
fi
ssh $target_host "cd $target_folder; openocd -f zc706.cfg -c 'pld load 0 top.bit; load_image szl; resume 0; exit'"

@ -0,0 +1,28 @@
let
mozillaOverlay = import (builtins.fetchTarball "https://github.com/mozilla/nixpkgs-mozilla/archive/master.tar.gz");
pkgs = import <nixpkgs> { overlays = [ mozillaOverlay ]; };
artiq-fast = <artiq-fast>;
rustPlatform = (import ./rustPlatform.nix { inherit pkgs; });
artiqpkgs = import "${artiq-fast}/default.nix" { inherit pkgs; };
vivado = import "${artiq-fast}/vivado.nix" { inherit pkgs; };
in
pkgs.stdenv.mkDerivation {
name = "artiq-zynq-env";
buildInputs = [
pkgs.gnumake
rustPlatform.rust.rustc
rustPlatform.rust.cargo
pkgs.clang_9
pkgs.cacert
pkgs.cargo-xbuild
pkgs.openssh pkgs.rsync
(pkgs.python3.withPackages(ps: (with artiqpkgs; [ migen migen-axi misoc artiq ])))
vivado
pkgs.llvm_9
pkgs.lld_9
];
XARGO_RUST_SRC = "${rustPlatform.rust.rustc.src}/src";
}

@ -0,0 +1,23 @@
all: target/armv7-none-eabihf/release/szl
clean:
rm -f runtime/src/pl.rs
rm -f szl/src/payload.bin
rm -f szl/src/payload.bin.lzma
rm -rf target
.PHONY: all clean
runtime/src/pl.rs: zc706.py
python zc706.py -r runtime/src/pl.rs
target/armv7-none-eabihf/release/runtime: .cargo/* armv7-none-eabihf.json Cargo.lock Cargo.toml libdyld/* libdyld/src/* runtime/* runtime/src/* runtime/src/pl.rs
cargo xbuild --release -p runtime
szl/src/payload.bin.lzma: target/armv7-none-eabihf/release/runtime
llvm-objcopy -O binary target/armv7-none-eabihf/release/runtime szl/src/payload.bin
lzma --keep -f szl/src/payload.bin
target/armv7-none-eabihf/release/szl: .cargo/* armv7-none-eabihf.json Cargo.lock Cargo.toml szl/* szl/src/* szl/src/payload.bin.lzma
cargo xbuild --release -p szl

@ -58,21 +58,19 @@ def write_csr_file(soc, filename):
def main():
parser = argparse.ArgumentParser(
description="ARTIQ port to the ZC706 Zynq development kit")
parser.add_argument("action", metavar="ACTION", nargs="*",
default="gateware rustif".split(),
help="actions to perform, default: %(default)s")
parser.add_argument("-r", default=None,
help="build Rust interface into the specified file")
parser.add_argument("-g", action="store_true",
help="build gateware")
args = parser.parse_args()
soc = ZC706()
soc.finalize()
for action in args.action:
if action == "gateware":
soc.build()
elif action == "rustif":
write_csr_file(soc, "pl.rs")
else:
raise ValueError("invalid action", action)
if args.g:
soc.build()
if args.r is not None:
write_csr_file(soc, args.r)
if __name__ == "__main__":
Loading…
Cancel
Save