2020-04-30 21:04:28 +08:00
|
|
|
{
|
|
|
|
mozillaOverlay ? import (builtins.fetchTarball https://github.com/mozilla/nixpkgs-mozilla/archive/master.tar.gz),
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
pkgs = import <nixpkgs> { overlays = [ mozillaOverlay ]; };
|
|
|
|
rustPlatform = (import ./rustPlatform.nix { inherit pkgs; });
|
2020-05-03 08:25:19 +08:00
|
|
|
artiqpkgs = import <artiq-fast/default.nix> { inherit pkgs; };
|
|
|
|
vivado = import <artiq-fast/vivado.nix> { inherit pkgs; };
|
2020-05-14 15:30:50 +08:00
|
|
|
zc706-fsbl = import ./fsbl.nix { inherit pkgs; };
|
2020-05-01 11:23:00 +08:00
|
|
|
mkbootimage = (import ./mkbootimage.nix { inherit pkgs; });
|
2020-05-14 15:30:50 +08:00
|
|
|
build-zc706 = { variant }: let
|
|
|
|
firmware = rustPlatform.buildRustPackage rec {
|
|
|
|
name = "zc706-${variant}-firmware";
|
2020-04-30 21:04:28 +08:00
|
|
|
version = "0.1.0";
|
|
|
|
|
2020-05-01 10:07:38 +08:00
|
|
|
src = ./src;
|
2020-06-16 18:08:12 +08:00
|
|
|
cargoSha256 = "13j5pkg4hvw85r38pi2faby4cl4zmhcfqncq68bnb738yfrmf91y";
|
2020-04-30 21:04:28 +08:00
|
|
|
|
2020-05-01 10:07:38 +08:00
|
|
|
nativeBuildInputs = [
|
|
|
|
pkgs.gnumake
|
|
|
|
(pkgs.python3.withPackages(ps: (with artiqpkgs; [ migen migen-axi misoc artiq ])))
|
|
|
|
pkgs.cargo-xbuild
|
|
|
|
pkgs.llvm_9
|
|
|
|
pkgs.clang_9
|
|
|
|
];
|
2020-04-30 21:04:28 +08:00
|
|
|
buildPhase = ''
|
|
|
|
export XARGO_RUST_SRC="${rustPlatform.rust.rustc.src}/src"
|
|
|
|
export CARGO_HOME=$(mktemp -d cargo-home.XXX)
|
2020-05-14 15:30:50 +08:00
|
|
|
make VARIANT=${variant}
|
2020-04-30 21:04:28 +08:00
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out $out/nix-support
|
2020-05-07 13:52:40 +08:00
|
|
|
cp ../build/firmware/armv7-none-eabihf/release/runtime $out/runtime.elf
|
|
|
|
cp ../build/firmware/armv7-none-eabihf/release/szl $out/szl.elf
|
2020-05-06 16:53:52 +08:00
|
|
|
echo file binary-dist $out/runtime.elf >> $out/nix-support/hydra-build-products
|
2020-05-01 10:07:38 +08:00
|
|
|
echo file binary-dist $out/szl.elf >> $out/nix-support/hydra-build-products
|
2020-04-30 21:04:28 +08:00
|
|
|
'';
|
2020-05-01 10:07:38 +08:00
|
|
|
|
|
|
|
doCheck = false;
|
2020-04-30 21:04:28 +08:00
|
|
|
dontFixup = true;
|
|
|
|
};
|
2020-05-14 15:30:50 +08:00
|
|
|
gateware = pkgs.runCommand "zc706-${variant}-gateware"
|
2020-05-01 10:07:38 +08:00
|
|
|
{
|
|
|
|
nativeBuildInputs = [
|
|
|
|
(pkgs.python3.withPackages(ps: (with artiqpkgs; [ migen migen-axi misoc artiq ])))
|
|
|
|
vivado
|
|
|
|
];
|
|
|
|
}
|
2020-04-30 21:04:28 +08:00
|
|
|
''
|
2020-05-14 15:30:50 +08:00
|
|
|
python ${./src/zc706.py} -g build -V ${variant}
|
2020-04-30 21:04:28 +08:00
|
|
|
mkdir -p $out $out/nix-support
|
|
|
|
cp build/top.bit $out
|
|
|
|
echo file binary-dist $out/top.bit >> $out/nix-support/hydra-build-products
|
|
|
|
'';
|
2020-05-06 16:53:52 +08:00
|
|
|
|
|
|
|
# SZL startup
|
2020-05-14 15:30:50 +08:00
|
|
|
jtag = pkgs.runCommand "zc706-${variant}-jtag" {}
|
2020-04-30 21:04:28 +08:00
|
|
|
''
|
|
|
|
mkdir $out
|
2020-05-14 15:30:50 +08:00
|
|
|
ln -s ${firmware}/szl.elf $out
|
|
|
|
ln -s ${gateware}/top.bit $out
|
2020-04-30 21:04:28 +08:00
|
|
|
'';
|
2020-05-14 15:30:50 +08:00
|
|
|
sd = pkgs.runCommand "zc706-${variant}-sd"
|
2020-05-01 11:23:00 +08:00
|
|
|
{
|
|
|
|
buildInputs = [ mkbootimage ];
|
|
|
|
}
|
|
|
|
''
|
2020-05-06 17:46:37 +08:00
|
|
|
# Do not use "long" paths in boot.bif, because embedded developers
|
|
|
|
# can't write software (mkbootimage will segfault).
|
|
|
|
bifdir=`mktemp -d`
|
|
|
|
cd $bifdir
|
2020-05-14 15:30:50 +08:00
|
|
|
ln -s ${firmware}/szl.elf szl.elf
|
2020-06-15 17:03:27 +08:00
|
|
|
ln -s ${gateware}/top.bit top.bit
|
2020-05-06 17:46:37 +08:00
|
|
|
cat > boot.bif << EOF
|
2020-05-01 11:23:00 +08:00
|
|
|
the_ROM_image:
|
|
|
|
{
|
2020-05-06 17:46:37 +08:00
|
|
|
[bootloader]szl.elf
|
2020-06-15 17:03:27 +08:00
|
|
|
top.bit
|
2020-05-01 11:23:00 +08:00
|
|
|
}
|
|
|
|
EOF
|
2020-06-15 17:03:27 +08:00
|
|
|
mkdir $out $out/nix-support
|
2020-05-06 17:46:37 +08:00
|
|
|
mkbootimage boot.bif $out/boot.bin
|
2020-06-15 17:03:27 +08:00
|
|
|
echo file binary-dist $out/boot.bin >> $out/nix-support/hydra-build-products
|
2020-05-01 11:23:00 +08:00
|
|
|
'';
|
2020-05-06 16:02:44 +08:00
|
|
|
|
2020-05-06 16:53:52 +08:00
|
|
|
# FSBL startup
|
2020-05-14 15:30:50 +08:00
|
|
|
fsbl-sd = pkgs.runCommand "zc706-${variant}-fsbl-sd"
|
2020-05-06 16:53:52 +08:00
|
|
|
{
|
2020-06-17 15:48:55 +08:00
|
|
|
buildInputs = [ mkbootimage zc706-fsbl];
|
2020-05-06 16:53:52 +08:00
|
|
|
}
|
|
|
|
''
|
2020-05-06 17:35:15 +08:00
|
|
|
# TODO: use self-built fsbl
|
|
|
|
bifdir=`mktemp -d`
|
|
|
|
cd $bifdir
|
2020-06-17 15:48:55 +08:00
|
|
|
ln -s ${zc706-fsbl}/fsbl.elf fsbl.elf
|
2020-05-14 15:30:50 +08:00
|
|
|
ln -s ${gateware}/top.bit top.bit
|
|
|
|
ln -s ${firmware}/runtime.elf runtime.elf
|
2020-05-06 17:35:15 +08:00
|
|
|
cat > boot.bif << EOF
|
2020-05-06 16:53:52 +08:00
|
|
|
the_ROM_image:
|
|
|
|
{
|
2020-05-06 17:35:15 +08:00
|
|
|
[bootloader]fsbl.elf
|
|
|
|
top.bit
|
|
|
|
runtime.elf
|
2020-05-06 16:53:52 +08:00
|
|
|
}
|
|
|
|
EOF
|
|
|
|
mkdir $out $out/nix-support
|
2020-05-06 17:35:15 +08:00
|
|
|
mkbootimage boot.bif $out/boot.bin
|
2020-05-06 16:53:52 +08:00
|
|
|
echo file binary-dist $out/boot.bin >> $out/nix-support/hydra-build-products
|
|
|
|
'';
|
2020-05-14 15:30:50 +08:00
|
|
|
in {
|
|
|
|
"zc706-${variant}-firmware" = firmware;
|
|
|
|
"zc706-${variant}-gateware" = gateware;
|
|
|
|
"zc706-${variant}-jtag" = jtag;
|
|
|
|
"zc706-${variant}-sd" = sd;
|
|
|
|
"zc706-${variant}-fsbl-sd" = fsbl-sd;
|
|
|
|
};
|
|
|
|
in
|
|
|
|
(
|
|
|
|
(build-zc706 { variant = "simple"; }) //
|
|
|
|
(build-zc706 { variant = "nist_clock"; }) //
|
|
|
|
(build-zc706 { variant = "nist_qc2"; }) //
|
|
|
|
{ inherit zc706-fsbl; }
|
|
|
|
)
|