2020-10-14 15:56:10 +08:00
|
|
|
let
|
|
|
|
zynq-rs = (import ./zynq-rs.nix);
|
|
|
|
pkgs = import <nixpkgs> { overlays = [ (import "${zynq-rs}/nix/mozilla-overlay.nix") ]; };
|
|
|
|
rustPlatform = (import "${zynq-rs}/nix/rust-platform.nix" { inherit pkgs; });
|
|
|
|
cargo-xbuild = (import zynq-rs).cargo-xbuild;
|
2020-10-14 21:34:49 +08:00
|
|
|
redpitaya-szl = (import zynq-rs).redpitaya-szl;
|
2020-10-14 15:56:10 +08:00
|
|
|
mkbootimage = import "${zynq-rs}/nix/mkbootimage.nix" { inherit pkgs; };
|
|
|
|
artiqpkgs = import <artiq-fast/default.nix> { inherit pkgs; };
|
|
|
|
vivado = import <artiq-fast/vivado.nix> { inherit pkgs; };
|
|
|
|
in rec {
|
|
|
|
rust-pitaya-firmware = rustPlatform.buildRustPackage {
|
|
|
|
name = "rust-pitaya-firmware";
|
|
|
|
|
|
|
|
src = ./src;
|
2020-10-14 21:34:49 +08:00
|
|
|
cargoSha256 = "173013gdlk8mljps6lar892zqgxrmxa7fkv8is3wgvgf7dnifjzs";
|
2020-10-14 15:56:10 +08:00
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
pkgs.gnumake
|
|
|
|
(pkgs.python3.withPackages(ps: (with artiqpkgs; [ migen migen-axi misoc artiq ])))
|
|
|
|
cargo-xbuild
|
|
|
|
pkgs.llvmPackages_9.llvm
|
|
|
|
pkgs.llvmPackages_9.clang-unwrapped
|
|
|
|
];
|
|
|
|
buildPhase = ''
|
|
|
|
export XARGO_RUST_SRC="${rustPlatform.rust.rustc.src}/library"
|
|
|
|
export CARGO_HOME=$(mktemp -d cargo-home.XXX)
|
|
|
|
make
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out $out/nix-support
|
2020-10-14 21:34:49 +08:00
|
|
|
cp ../build/firmware.bin $out/firmware.bin
|
2020-10-14 15:56:10 +08:00
|
|
|
cp ../build/firmware/armv7-none-eabihf/release/firmware $out/firmware.elf
|
|
|
|
echo file binary-dist $out/firmware.bin >> $out/nix-support/hydra-build-products
|
|
|
|
echo file binary-dist $out/firmware.elf >> $out/nix-support/hydra-build-products
|
|
|
|
'';
|
|
|
|
|
|
|
|
doCheck = false;
|
|
|
|
dontFixup = true;
|
|
|
|
};
|
|
|
|
rust-pitaya-gateware = pkgs.runCommand "rust-pitaya-gateware"
|
|
|
|
{
|
|
|
|
nativeBuildInputs = [
|
|
|
|
(pkgs.python3.withPackages(ps: (with artiqpkgs; [ migen migen-axi misoc ])))
|
|
|
|
vivado
|
|
|
|
];
|
|
|
|
}
|
|
|
|
''
|
2020-10-14 21:34:49 +08:00
|
|
|
python ${./src/gateware}/rust-pitaya.py -g build
|
2020-10-14 15:56:10 +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
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
|
|
rust-pitaya-jtag = pkgs.runCommand "rust-pitaya-jtag" {}
|
|
|
|
''
|
|
|
|
mkdir $out
|
2020-10-14 21:34:49 +08:00
|
|
|
ln -s ${redpitaya-szl}/szl.elf $out
|
2020-10-14 15:56:10 +08:00
|
|
|
ln -s ${rust-pitaya-firmware}/firmware.bin $out
|
|
|
|
ln -s ${rust-pitaya-gateware}/top.bit $out
|
|
|
|
'';
|
|
|
|
sd = pkgs.runCommand "rust-pitaya-sd"
|
|
|
|
{
|
|
|
|
buildInputs = [ mkbootimage ];
|
|
|
|
}
|
|
|
|
''
|
|
|
|
# Do not use "long" paths in boot.bif, because embedded developers
|
|
|
|
# can't write software (mkbootimage will segfault).
|
|
|
|
bifdir=`mktemp -d`
|
|
|
|
cd $bifdir
|
2020-10-14 21:34:49 +08:00
|
|
|
ln -s ${redpitaya-szl}/szl.elf szl.elf
|
|
|
|
ln -s ${rust-pitaya-firmware}/firmware.elf firmware.elf
|
2020-10-14 15:56:10 +08:00
|
|
|
ln -s ${rust-pitaya-gateware}/top.bit top.bit
|
|
|
|
cat > boot.bif << EOF
|
|
|
|
the_ROM_image:
|
|
|
|
{
|
|
|
|
[bootloader]szl.elf
|
|
|
|
top.bit
|
2020-10-14 21:34:49 +08:00
|
|
|
firmware.elf
|
2020-10-14 15:56:10 +08:00
|
|
|
}
|
|
|
|
EOF
|
|
|
|
mkdir $out $out/nix-support
|
|
|
|
mkbootimage boot.bif $out/boot.bin
|
|
|
|
echo file binary-dist $out/boot.bin >> $out/nix-support/hydra-build-products
|
|
|
|
'';
|
|
|
|
}
|