forked from M-Labs/artiq-zynq
add impure incremental build process, document
This commit is contained in:
parent
92ae487143
commit
2439ba1f88
5
.gitignore
vendored
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
|
||||
|
23
README.md
Normal file
23
README.md
Normal file
@ -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.
|
74
default.nix
74
default.nix
@ -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;
|
||||
version = "0.1.0";
|
||||
|
||||
inherit src;
|
||||
cargoSha256 = (import "${src}/cargosha256.nix");
|
||||
|
||||
nativeBuildInputs = [ 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}
|
||||
'';
|
||||
|
||||
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
|
||||
'';
|
||||
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 = [
|
||||
zc706-szl = rustPlatform.buildRustPackage rec {
|
||||
name = "szl";
|
||||
version = "0.1.0";
|
||||
|
||||
src = ./src;
|
||||
cargoSha256 = "199qfs7fbbj8kxkyb0dcns6hdq9hvlppk7l3pnz204j9zkd7dkcp";
|
||||
|
||||
nativeBuildInputs = [
|
||||
pkgs.gnumake
|
||||
(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
|
||||
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)
|
||||
make clean
|
||||
make
|
||||
'';
|
||||
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
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out $out/nix-support
|
||||
cp target/armv7-none-eabihf/release/szl $out/$szl.elf
|
||||
echo file binary-dist $out/szl.elf >> $out/nix-support/hydra-build-products
|
||||
'';
|
||||
zc706-szl = buildFirmware { name = "szl"; src = zc706-szl-src; };
|
||||
|
||||
doCheck = false;
|
||||
dontFixup = true;
|
||||
};
|
||||
zc706-gateware = pkgs.runCommand "zc706-gateware"
|
||||
{ buildInputs = [
|
||||
{
|
||||
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'"
|
||||
|
28
shell.nix
Normal file
28
shell.nix
Normal file
@ -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
firmware/Cargo.lock → src/Cargo.lock
generated
0
firmware/Cargo.lock → src/Cargo.lock
generated
23
src/Makefile
Normal file
23
src/Makefile
Normal file
@ -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":
|
||||
if args.g:
|
||||
soc.build()
|
||||
elif action == "rustif":
|
||||
write_csr_file(soc, "pl.rs")
|
||||
else:
|
||||
raise ValueError("invalid action", action)
|
||||
if args.r is not None:
|
||||
write_csr_file(soc, args.r)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
Loading…
Reference in New Issue
Block a user