forked from M-Labs/artiq-zynq
flakes support
This commit is contained in:
parent
663fdcbabf
commit
cc5fdb64c7
18
README.md
18
README.md
@ -33,26 +33,19 @@ not implemented as it seems not very useful.
|
|||||||
Development instructions
|
Development instructions
|
||||||
------------------------
|
------------------------
|
||||||
|
|
||||||
Configure Nix channels:
|
ARTIQ on Zynq is packaged using the [Nix](https://nixos.org) Flakes system. Install Nix 2.4+ and enable flakes by adding ``experimental-features = nix-command flakes`` to ``nix.conf`` (e.g. ``~/.config/nix/nix.conf``).
|
||||||
|
|
||||||
```shell
|
|
||||||
nix-channel --add https://nixbld.m-labs.hk/channel/custom/artiq/fast-beta/artiq-fast
|
|
||||||
nix-channel --update
|
|
||||||
```
|
|
||||||
|
|
||||||
Note: if you are using Nix channels the first time, you need to be aware of this bug: https://github.com/NixOS/nix/issues/3831
|
|
||||||
|
|
||||||
Pure build with Nix and execution on a remote JTAG server:
|
Pure build with Nix and execution on a remote JTAG server:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
nix-build -A zc706-nist_clock-jtag # or zc706-nist_qc2-jtag or zc706-nist_clock_satellite-jtag etc.
|
nix build .#zc706-nist_clock-jtag # or zc706-nist_qc2-jtag or zc706-nist_clock_satellite-jtag etc.
|
||||||
./remote_run.sh
|
./remote_run.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
Impure incremental build and execution on a remote JTAG server:
|
Impure incremental build and execution on a remote JTAG server:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
nix-shell
|
nix develop
|
||||||
cd src
|
cd src
|
||||||
gateware/zc706.py -g ../build/gateware -v <variant> # build gateware
|
gateware/zc706.py -g ../build/gateware -v <variant> # build gateware
|
||||||
make GWARGS="-V <variant>" <runtime/satman> # build firmware
|
make GWARGS="-V <variant>" <runtime/satman> # build firmware
|
||||||
@ -62,14 +55,11 @@ cd ..
|
|||||||
|
|
||||||
Notes:
|
Notes:
|
||||||
|
|
||||||
- This is developed with Nixpkgs 21.05[^1], and the ``nixbld.m-labs.hk`` binary substituter can also be used here (see the ARTIQ manual for the public key and instructions).
|
|
||||||
- The impure build process is also compatible with non-Nix systems.
|
- The impure build process is also compatible with non-Nix systems.
|
||||||
- When calling make, you need to specify both the variant and firmware type.
|
- When calling make, you need to specify both the variant and firmware type.
|
||||||
- Firmware type must be either ``runtime`` for DRTIO-less or DRTIO master variants, or ``satman`` for DRTIO satellite.
|
- Firmware type must be either ``runtime`` for DRTIO-less or DRTIO master variants, or ``satman`` for DRTIO satellite.
|
||||||
- If the board is connected to the local machine, use the ``local_run.sh`` script.
|
- If the board is connected to the local machine, use the ``local_run.sh`` script.
|
||||||
- To update ``zynq-rs``, update the cargo files as per usual for Rust projects, but also keep ``zynq-rs.nix`` in sync.
|
- To update ``zynq-rs``, update the cargo files as per usual for Rust projects, but also keep ``flake.lock`` in sync.
|
||||||
|
|
||||||
[^1]: Thus, on newer version of NixOS, you should run `nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/21.05.tar.gz` instead
|
|
||||||
|
|
||||||
License
|
License
|
||||||
-------
|
-------
|
||||||
|
162
default.nix
162
default.nix
@ -1,162 +0,0 @@
|
|||||||
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;
|
|
||||||
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; };
|
|
||||||
# FSBL configuration supplied by Vivado 2020.1 for these boards:
|
|
||||||
fsblTargets = ["zc702" "zc706" "zed"];
|
|
||||||
sat_variants = [
|
|
||||||
# kasli-soc satellite variants
|
|
||||||
"satellite"
|
|
||||||
# zc706 satellite variants
|
|
||||||
"nist_clock_satellite" "nist_qc2_satellite" "acpki_nist_clock_satellite" "acpki_nist_qc2_satellite"
|
|
||||||
"nist_clock_satellite_100mhz" "nist_qc2_satellite_100mhz" "acpki_nist_clock_satellite_100mhz" "acpki_nist_qc2_satellite_100mhz"
|
|
||||||
];
|
|
||||||
build = { target, variant, json ? null }: let
|
|
||||||
szl = (import zynq-rs)."${target}-szl";
|
|
||||||
fsbl = import "${zynq-rs}/nix/fsbl.nix" {
|
|
||||||
inherit pkgs;
|
|
||||||
board = target;
|
|
||||||
};
|
|
||||||
fwtype = if builtins.elem variant sat_variants then "satman" else "runtime";
|
|
||||||
|
|
||||||
firmware = rustPlatform.buildRustPackage rec {
|
|
||||||
# note: due to fetchCargoTarball, cargoSha256 depends on package name
|
|
||||||
name = "firmware";
|
|
||||||
|
|
||||||
src = ./src;
|
|
||||||
cargoSha256 = "sha256-uCqCeqXbTjTDEoZERPDb3kX+CTfzSJ/jGlrFxuKO8HQ=";
|
|
||||||
|
|
||||||
nativeBuildInputs = [
|
|
||||||
pkgs.gnumake
|
|
||||||
(pkgs.python3.withPackages(ps: (with artiqpkgs; [ ps.jsonschema migen migen-axi misoc artiq ])))
|
|
||||||
cargo-xbuild
|
|
||||||
pkgs.llvmPackages_9.llvm
|
|
||||||
pkgs.llvmPackages_9.clang-unwrapped
|
|
||||||
];
|
|
||||||
buildPhase = ''
|
|
||||||
export XARGO_RUST_SRC="${rustPlatform.rust.rustc}/lib/rustlib/src/rust/library"
|
|
||||||
export CLANG_EXTRA_INCLUDE_DIR="${pkgs.llvmPackages_9.clang-unwrapped.lib}/lib/clang/9.0.1/include"
|
|
||||||
export CARGO_HOME=$(mktemp -d cargo-home.XXX)
|
|
||||||
make TARGET=${target} GWARGS="${if json == null then "-V ${variant}" else json}" ${fwtype}
|
|
||||||
'';
|
|
||||||
|
|
||||||
installPhase = ''
|
|
||||||
mkdir -p $out $out/nix-support
|
|
||||||
cp ../build/${fwtype}.bin $out/${fwtype}.bin
|
|
||||||
cp ../build/firmware/armv7-none-eabihf/release/${fwtype} $out/${fwtype}.elf
|
|
||||||
echo file binary-dist $out/${fwtype}.bin >> $out/nix-support/hydra-build-products
|
|
||||||
echo file binary-dist $out/${fwtype}.elf >> $out/nix-support/hydra-build-products
|
|
||||||
'';
|
|
||||||
|
|
||||||
doCheck = false;
|
|
||||||
dontFixup = true;
|
|
||||||
};
|
|
||||||
gateware = pkgs.runCommand "${target}-${variant}-gateware"
|
|
||||||
{
|
|
||||||
nativeBuildInputs = [
|
|
||||||
(pkgs.python3.withPackages(ps: (with artiqpkgs; [ ps.jsonschema migen migen-axi misoc artiq ])))
|
|
||||||
vivado
|
|
||||||
];
|
|
||||||
}
|
|
||||||
''
|
|
||||||
python ${./src/gateware}/${target}.py -g build ${if json == null then "-V ${variant}" else json}
|
|
||||||
mkdir -p $out $out/nix-support
|
|
||||||
cp build/top.bit $out
|
|
||||||
echo file binary-dist $out/top.bit >> $out/nix-support/hydra-build-products
|
|
||||||
'';
|
|
||||||
|
|
||||||
# SZL startup
|
|
||||||
jtag = pkgs.runCommand "${target}-${variant}-jtag" {}
|
|
||||||
''
|
|
||||||
mkdir $out
|
|
||||||
ln -s ${szl}/szl.elf $out
|
|
||||||
ln -s ${firmware}/${fwtype}.bin $out
|
|
||||||
ln -s ${gateware}/top.bit $out
|
|
||||||
'';
|
|
||||||
sd = pkgs.runCommand "${target}-${variant}-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
|
|
||||||
ln -s ${szl}/szl.elf szl.elf
|
|
||||||
ln -s ${firmware}/${fwtype}.elf ${fwtype}.elf
|
|
||||||
ln -s ${gateware}/top.bit top.bit
|
|
||||||
cat > boot.bif << EOF
|
|
||||||
the_ROM_image:
|
|
||||||
{
|
|
||||||
[bootloader]szl.elf
|
|
||||||
top.bit
|
|
||||||
${fwtype}.elf
|
|
||||||
}
|
|
||||||
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
|
|
||||||
'';
|
|
||||||
|
|
||||||
# FSBL startup
|
|
||||||
fsbl-sd = pkgs.runCommand "${target}-${variant}-fsbl-sd"
|
|
||||||
{
|
|
||||||
buildInputs = [ mkbootimage ];
|
|
||||||
}
|
|
||||||
''
|
|
||||||
bifdir=`mktemp -d`
|
|
||||||
cd $bifdir
|
|
||||||
ln -s ${fsbl}/fsbl.elf fsbl.elf
|
|
||||||
ln -s ${gateware}/top.bit top.bit
|
|
||||||
ln -s ${firmware}/${fwtype}.elf ${fwtype}.elf
|
|
||||||
cat > boot.bif << EOF
|
|
||||||
the_ROM_image:
|
|
||||||
{
|
|
||||||
[bootloader]fsbl.elf
|
|
||||||
top.bit
|
|
||||||
${fwtype}.elf
|
|
||||||
}
|
|
||||||
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
|
|
||||||
'';
|
|
||||||
in {
|
|
||||||
"${target}-${variant}-firmware" = firmware;
|
|
||||||
"${target}-${variant}-gateware" = gateware;
|
|
||||||
"${target}-${variant}-jtag" = jtag;
|
|
||||||
"${target}-${variant}-sd" = sd;
|
|
||||||
} // (
|
|
||||||
if builtins.elem target fsblTargets
|
|
||||||
then {
|
|
||||||
"${target}-${variant}-fsbl-sd" = fsbl-sd;
|
|
||||||
}
|
|
||||||
else {}
|
|
||||||
);
|
|
||||||
in
|
|
||||||
(
|
|
||||||
(build { target = "zc706"; variant = "nist_clock"; }) //
|
|
||||||
(build { target = "zc706"; variant = "nist_clock_master"; }) //
|
|
||||||
(build { target = "zc706"; variant = "nist_clock_satellite"; }) //
|
|
||||||
(build { target = "zc706"; variant = "nist_clock_satellite_100mhz"; }) //
|
|
||||||
(build { target = "zc706"; variant = "nist_qc2"; }) //
|
|
||||||
(build { target = "zc706"; variant = "nist_qc2_master"; }) //
|
|
||||||
(build { target = "zc706"; variant = "nist_qc2_satellite"; }) //
|
|
||||||
(build { target = "zc706"; variant = "nist_qc2_satellite_100mhz"; }) //
|
|
||||||
(build { target = "zc706"; variant = "acpki_nist_clock"; }) //
|
|
||||||
(build { target = "zc706"; variant = "acpki_nist_clock_master"; }) //
|
|
||||||
(build { target = "zc706"; variant = "acpki_nist_clock_satellite"; }) //
|
|
||||||
(build { target = "zc706"; variant = "acpki_nist_clock_satellite_100mhz"; }) //
|
|
||||||
(build { target = "zc706"; variant = "acpki_nist_qc2"; }) //
|
|
||||||
(build { target = "zc706"; variant = "acpki_nist_qc2_master"; }) //
|
|
||||||
(build { target = "zc706"; variant = "acpki_nist_qc2_satellite"; }) //
|
|
||||||
(build { target = "zc706"; variant = "acpki_nist_qc2_satellite_100mhz"; }) //
|
|
||||||
(build { target = "kasli_soc"; variant = "demo"; json = ./demo.json; }) //
|
|
||||||
(build { target = "kasli_soc"; variant = "master"; json = ./kasli-soc-master.json; }) //
|
|
||||||
(build { target = "kasli_soc"; variant = "satellite"; json = ./kasli-soc-satellite.json; }) //
|
|
||||||
{ inherit zynq-rs; }
|
|
||||||
)
|
|
218
flake.lock
generated
Normal file
218
flake.lock
generated
Normal file
@ -0,0 +1,218 @@
|
|||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"artiq": {
|
||||||
|
"inputs": {
|
||||||
|
"mozilla-overlay": "mozilla-overlay",
|
||||||
|
"nixpkgs": "nixpkgs",
|
||||||
|
"src-migen": "src-migen",
|
||||||
|
"src-misoc": "src-misoc",
|
||||||
|
"src-pythonparser": "src-pythonparser",
|
||||||
|
"src-sipyco": "src-sipyco"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1643542736,
|
||||||
|
"narHash": "sha256-SXOAQ2hxwoT+zTrMZCtjlcf/i8phN4AwwCAwUlhufzc=",
|
||||||
|
"ref": "master",
|
||||||
|
"rev": "dd3279e50622b5ceb1c24b4d1891f442cc0acce3",
|
||||||
|
"revCount": 7947,
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/m-labs/artiq.git"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/m-labs/artiq.git"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"mozilla-overlay": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1638887313,
|
||||||
|
"narHash": "sha256-FMYV6rVtvSIfthgC1sK1xugh3y7muoQcvduMdriz4ag=",
|
||||||
|
"owner": "mozilla",
|
||||||
|
"repo": "nixpkgs-mozilla",
|
||||||
|
"rev": "7c1e8b1dd6ed0043fb4ee0b12b815256b0b9de6f",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "mozilla",
|
||||||
|
"repo": "nixpkgs-mozilla",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"mozilla-overlay_2": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1638887313,
|
||||||
|
"narHash": "sha256-FMYV6rVtvSIfthgC1sK1xugh3y7muoQcvduMdriz4ag=",
|
||||||
|
"owner": "mozilla",
|
||||||
|
"repo": "nixpkgs-mozilla",
|
||||||
|
"rev": "7c1e8b1dd6ed0043fb4ee0b12b815256b0b9de6f",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "mozilla",
|
||||||
|
"repo": "nixpkgs-mozilla",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"mozilla-overlay_3": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1638887313,
|
||||||
|
"narHash": "sha256-FMYV6rVtvSIfthgC1sK1xugh3y7muoQcvduMdriz4ag=",
|
||||||
|
"owner": "mozilla",
|
||||||
|
"repo": "nixpkgs-mozilla",
|
||||||
|
"rev": "7c1e8b1dd6ed0043fb4ee0b12b815256b0b9de6f",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "mozilla",
|
||||||
|
"repo": "nixpkgs-mozilla",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1642522226,
|
||||||
|
"narHash": "sha256-m/j9U8KYuwwxjwgRCjmEj8ejftvdMLJ+NGXh/L2I4FU=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "610d4ea2750e064bf34b33fa38cb671edd893d3d",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixos-21.11",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs_2": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1643247693,
|
||||||
|
"narHash": "sha256-rmShxIuNjYBz4l83J0J++sug+MURUY1koPCzX4F8hfo=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "6c4b9f1a2fd761e2d384ef86cff0d208ca27fdca",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixos-21.11",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs_3": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1642961095,
|
||||||
|
"narHash": "sha256-RLatktZmvwFBOyqdoIk4qdS4OGKB7aKIvvs4ZP2L8D8=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "604c44137d97b5111be1ca5c0d97f6e24fbc5c2c",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixos-21.11",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"artiq": "artiq",
|
||||||
|
"mozilla-overlay": "mozilla-overlay_2",
|
||||||
|
"nixpkgs": "nixpkgs_2",
|
||||||
|
"zynq-rs": "zynq-rs"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"src-migen": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1639659493,
|
||||||
|
"narHash": "sha256-qpVj/yJf4hDDc99XXpVPH4EbLC8aCmEtACn5qNc3DGI=",
|
||||||
|
"owner": "m-labs",
|
||||||
|
"repo": "migen",
|
||||||
|
"rev": "ac703010eaa06ac9b6e32f97c6fa98b15de22b31",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "m-labs",
|
||||||
|
"repo": "migen",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"src-misoc": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1641889368,
|
||||||
|
"narHash": "sha256-0Ai25lry9ju1HxFmfMRNKG8mamBqvw+kvDfpuK8Dtjo=",
|
||||||
|
"ref": "master",
|
||||||
|
"rev": "7242dc5a41732135425acc4871487461dfae6c66",
|
||||||
|
"revCount": 2419,
|
||||||
|
"submodules": true,
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/m-labs/misoc.git"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"submodules": true,
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/m-labs/misoc.git"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"src-pythonparser": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1628745371,
|
||||||
|
"narHash": "sha256-p6TgeeaK4NEmbhimEXp31W8hVRo4DgWmcCoqZ+UdN60=",
|
||||||
|
"owner": "m-labs",
|
||||||
|
"repo": "pythonparser",
|
||||||
|
"rev": "5413ee5c9f8760e95c6acd5d6e88dabb831ad201",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "m-labs",
|
||||||
|
"repo": "pythonparser",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"src-sipyco": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1641866796,
|
||||||
|
"narHash": "sha256-TSH0IgNbi9IcMcBDb2nWRphKlxstbWeATjrGbi6K2m0=",
|
||||||
|
"owner": "m-labs",
|
||||||
|
"repo": "sipyco",
|
||||||
|
"rev": "b04234c49379cd446d4cb3346d4741868d86841a",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "m-labs",
|
||||||
|
"repo": "sipyco",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"zynq-rs": {
|
||||||
|
"inputs": {
|
||||||
|
"mozilla-overlay": "mozilla-overlay_3",
|
||||||
|
"nixpkgs": "nixpkgs_3"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1643971355,
|
||||||
|
"narHash": "sha256-kaVxTtgdoEwB+PEorp72MXcaaaAh5U/LDnF3QKjsCco=",
|
||||||
|
"ref": "master",
|
||||||
|
"rev": "e5e646f40eae3c04898266310a64c09b8c03dfbc",
|
||||||
|
"revCount": 597,
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://git.m-labs.hk/m-labs/zynq-rs"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://git.m-labs.hk/m-labs/zynq-rs"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
296
flake.nix
Normal file
296
flake.nix
Normal file
@ -0,0 +1,296 @@
|
|||||||
|
{
|
||||||
|
description = "ARTIQ port for Zynq platform";
|
||||||
|
|
||||||
|
inputs.nixpkgs.url = github:NixOS/nixpkgs/nixos-21.11;
|
||||||
|
inputs.mozilla-overlay = { url = github:mozilla/nixpkgs-mozilla; flake = false; };
|
||||||
|
inputs.zynq-rs.url = git+https://git.m-labs.hk/m-labs/zynq-rs;
|
||||||
|
inputs.artiq.url = git+https://github.com/m-labs/artiq.git;
|
||||||
|
|
||||||
|
outputs = { self, nixpkgs, mozilla-overlay, zynq-rs, artiq }:
|
||||||
|
let
|
||||||
|
pkgs = import nixpkgs { system = "x86_64-linux"; overlays = [ (import mozilla-overlay) ]; };
|
||||||
|
zynqpkgs = zynq-rs.packages.x86_64-linux;
|
||||||
|
artiqpkgs = artiq.packages.x86_64-linux;
|
||||||
|
|
||||||
|
rustPlatform = zynq-rs.rustPlatform;
|
||||||
|
|
||||||
|
fastnumbers = pkgs.python3Packages.buildPythonPackage rec {
|
||||||
|
pname = "fastnumbers";
|
||||||
|
version = "2.2.1";
|
||||||
|
|
||||||
|
src = pkgs.python3Packages.fetchPypi {
|
||||||
|
inherit pname version;
|
||||||
|
sha256 = "0j15i54p7nri6hkzn1wal9pxri4pgql01wgjccig6ar0v5jjbvsy";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
artiq-netboot = pkgs.python3Packages.buildPythonPackage rec {
|
||||||
|
pname = "artiq-netboot";
|
||||||
|
version = "unstable-2020-10-15";
|
||||||
|
|
||||||
|
src = pkgs.fetchgit {
|
||||||
|
url = "https://git.m-labs.hk/m-labs/artiq-netboot.git";
|
||||||
|
rev = "04f69eb07df73abe4b89fde2c24084f7664f2104";
|
||||||
|
sha256 = "0ql4fr8m8gpb2yql8aqsdqsssxb8zqd6l65kl1f6s9845zy7shs9";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
ramda = pkgs.python3Packages.buildPythonPackage {
|
||||||
|
pname = "ramda";
|
||||||
|
version = "unstable-2019-02-01";
|
||||||
|
|
||||||
|
src = pkgs.fetchFromGitHub {
|
||||||
|
owner = "peteut";
|
||||||
|
repo = "ramda.py";
|
||||||
|
rev = "bd58f8e69d0e9a713d9c1f286a1ac5e5603956b1";
|
||||||
|
sha256 = "0qzd5yp9lbaham8p1wiymdjapzbqsli7lvngv24c3z4ybd9jlq9g";
|
||||||
|
};
|
||||||
|
|
||||||
|
nativeBuildInputs = with pkgs.python3Packages; [ pbr ];
|
||||||
|
propagatedBuildInputs = with pkgs.python3Packages; [ future fastnumbers ];
|
||||||
|
|
||||||
|
checkInputs = with pkgs.python3Packages; [ pytest pytest-flake8 ];
|
||||||
|
checkPhase = "pytest";
|
||||||
|
doCheck = false;
|
||||||
|
|
||||||
|
preBuild = ''
|
||||||
|
export PBR_VERSION=0.0.1
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
migen-axi = pkgs.python3Packages.buildPythonPackage {
|
||||||
|
pname = "migen-axi";
|
||||||
|
version = "unstable-2021-09-15";
|
||||||
|
|
||||||
|
src = pkgs.fetchFromGitHub {
|
||||||
|
owner = "peteut";
|
||||||
|
repo = "migen-axi";
|
||||||
|
rev = "9763505ee96acd7572280a2d1233721342dc7c3f";
|
||||||
|
sha256 = "15c7g05n183rka66fl1glzp6h7xjlpy1p6k8biry24dangsmxmvg";
|
||||||
|
};
|
||||||
|
|
||||||
|
nativeBuildInputs = with pkgs.python3Packages; [ pbr ];
|
||||||
|
propagatedBuildInputs = with pkgs.python3Packages; [ setuptools click numpy toolz jinja2 ramda artiqpkgs.migen artiqpkgs.misoc ];
|
||||||
|
|
||||||
|
postPatch = ''
|
||||||
|
substituteInPlace requirements.txt \
|
||||||
|
--replace "jinja2==2.11.3" "jinja2"
|
||||||
|
substituteInPlace requirements.txt \
|
||||||
|
--replace "future==0.18.2" "future"
|
||||||
|
substituteInPlace requirements.txt \
|
||||||
|
--replace "ramda==0.5.5" "ramda"
|
||||||
|
substituteInPlace requirements.txt \
|
||||||
|
--replace "colorama==0.4.3" "colorama"
|
||||||
|
substituteInPlace requirements.txt \
|
||||||
|
--replace "toolz==0.10.0" "toolz"
|
||||||
|
substituteInPlace requirements.txt \
|
||||||
|
--replace "pyserial==3.4" "pyserial"
|
||||||
|
substituteInPlace requirements.txt \
|
||||||
|
--replace "markupsafe==1.1.1" "markupsafe"
|
||||||
|
'';
|
||||||
|
|
||||||
|
checkInputs = with pkgs.python3Packages; [ pytest pytest-timeout pytest-flake8 ];
|
||||||
|
checkPhase = "pytest";
|
||||||
|
|
||||||
|
preBuild = ''
|
||||||
|
export PBR_VERSION=0.0.1
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
binutils = { platform, target, zlib }: pkgs.stdenv.mkDerivation rec {
|
||||||
|
basename = "binutils";
|
||||||
|
version = "2.30";
|
||||||
|
name = "${basename}-${platform}-${version}";
|
||||||
|
src = pkgs.fetchurl {
|
||||||
|
url = "https://ftp.gnu.org/gnu/binutils/binutils-${version}.tar.bz2";
|
||||||
|
sha256 = "028cklfqaab24glva1ks2aqa1zxa6w6xmc8q34zs1sb7h22dxspg";
|
||||||
|
};
|
||||||
|
configureFlags =
|
||||||
|
[ "--enable-shared" "--enable-deterministic-archives" "--target=${target}"];
|
||||||
|
outputs = [ "out" "info" "man" ];
|
||||||
|
depsBuildBuild = [ pkgs.buildPackages.stdenv.cc ];
|
||||||
|
buildInputs = [ zlib ];
|
||||||
|
enableParallelBuilding = true;
|
||||||
|
};
|
||||||
|
binutils-arm = pkgs.callPackage binutils { platform = "arm"; target = "armv7-unknown-linux-gnueabihf"; };
|
||||||
|
|
||||||
|
# FSBL configuration supplied by Vivado 2020.1 for these boards:
|
||||||
|
fsblTargets = ["zc702" "zc706" "zed"];
|
||||||
|
sat_variants = [
|
||||||
|
# kasli-soc satellite variants
|
||||||
|
"satellite"
|
||||||
|
# zc706 satellite variants
|
||||||
|
"nist_clock_satellite" "nist_qc2_satellite" "acpki_nist_clock_satellite" "acpki_nist_qc2_satellite"
|
||||||
|
"nist_clock_satellite_100mhz" "nist_qc2_satellite_100mhz" "acpki_nist_clock_satellite_100mhz" "acpki_nist_qc2_satellite_100mhz"
|
||||||
|
];
|
||||||
|
build = { target, variant, json ? null }: let
|
||||||
|
szl = zynqpkgs."${target}-szl";
|
||||||
|
fsbl = zynqpkgs."${target}-fsbl";
|
||||||
|
fwtype = if builtins.elem variant sat_variants then "satman" else "runtime";
|
||||||
|
|
||||||
|
firmware = rustPlatform.buildRustPackage rec {
|
||||||
|
|
||||||
|
name = "firmware";
|
||||||
|
src = ./src;
|
||||||
|
cargoLock = {
|
||||||
|
lockFile = src/Cargo.lock;
|
||||||
|
outputHashes = {
|
||||||
|
"libasync-0.0.0" = "sha256-Ug6y1sDnftSlQpn8PBlpFAwTskilSS1izz0/G19Xyz4=";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
nativeBuildInputs = [
|
||||||
|
pkgs.gnumake
|
||||||
|
(pkgs.python3.withPackages(ps: (with artiqpkgs; [ ps.jsonschema migen migen-axi misoc artiq ])))
|
||||||
|
artiqpkgs.artiq
|
||||||
|
zynqpkgs.cargo-xbuild
|
||||||
|
pkgs.llvmPackages_9.llvm
|
||||||
|
pkgs.llvmPackages_9.clang-unwrapped
|
||||||
|
];
|
||||||
|
buildPhase = ''
|
||||||
|
export XARGO_RUST_SRC="${rustPlatform.rust.rustc}/lib/rustlib/src/rust/library"
|
||||||
|
export CLANG_EXTRA_INCLUDE_DIR="${pkgs.llvmPackages_9.clang-unwrapped.lib}/lib/clang/9.0.1/include"
|
||||||
|
export CARGO_HOME=$(mktemp -d cargo-home.XXX)
|
||||||
|
make TARGET=${target} GWARGS="${if json == null then "-V ${variant}" else json}" ${fwtype}
|
||||||
|
'';
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
mkdir -p $out $out/nix-support
|
||||||
|
cp ../build/${fwtype}.bin $out/${fwtype}.bin
|
||||||
|
cp ../build/firmware/armv7-none-eabihf/release/${fwtype} $out/${fwtype}.elf
|
||||||
|
echo file binary-dist $out/${fwtype}.bin >> $out/nix-support/hydra-build-products
|
||||||
|
echo file binary-dist $out/${fwtype}.elf >> $out/nix-support/hydra-build-products
|
||||||
|
'';
|
||||||
|
|
||||||
|
doCheck = false;
|
||||||
|
dontFixup = true;
|
||||||
|
};
|
||||||
|
gateware = pkgs.runCommand "${target}-${variant}-gateware"
|
||||||
|
{
|
||||||
|
nativeBuildInputs = [
|
||||||
|
(pkgs.python3.withPackages(ps: (with artiqpkgs; [ ps.jsonschema migen migen-axi misoc artiq ])))
|
||||||
|
artiqpkgs.artiq
|
||||||
|
artiqpkgs.vivado
|
||||||
|
];
|
||||||
|
}
|
||||||
|
''
|
||||||
|
python ${./src/gateware}/${target}.py -g build ${if json == null then "-V ${variant}" else json}
|
||||||
|
mkdir -p $out $out/nix-support
|
||||||
|
cp build/top.bit $out
|
||||||
|
echo file binary-dist $out/top.bit >> $out/nix-support/hydra-build-products
|
||||||
|
'';
|
||||||
|
|
||||||
|
# SZL startup
|
||||||
|
jtag = pkgs.runCommand "${target}-${variant}-jtag" {}
|
||||||
|
''
|
||||||
|
mkdir $out
|
||||||
|
ln -s ${szl}/szl.elf $out
|
||||||
|
ln -s ${firmware}/${fwtype}.bin $out
|
||||||
|
ln -s ${gateware}/top.bit $out
|
||||||
|
'';
|
||||||
|
sd = pkgs.runCommand "${target}-${variant}-sd"
|
||||||
|
{
|
||||||
|
buildInputs = [ zynqpkgs.mkbootimage ];
|
||||||
|
}
|
||||||
|
''
|
||||||
|
# Do not use "long" paths in boot.bif, because embedded developers
|
||||||
|
# can't write software (mkbootimage will segfault).
|
||||||
|
bifdir=`mktemp -d`
|
||||||
|
cd $bifdir
|
||||||
|
ln -s ${szl}/szl.elf szl.elf
|
||||||
|
ln -s ${firmware}/${fwtype}.elf ${fwtype}.elf
|
||||||
|
ln -s ${gateware}/top.bit top.bit
|
||||||
|
cat > boot.bif << EOF
|
||||||
|
the_ROM_image:
|
||||||
|
{
|
||||||
|
[bootloader]szl.elf
|
||||||
|
top.bit
|
||||||
|
${fwtype}.elf
|
||||||
|
}
|
||||||
|
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
|
||||||
|
'';
|
||||||
|
|
||||||
|
# FSBL startup
|
||||||
|
fsbl-sd = pkgs.runCommand "${target}-${variant}-fsbl-sd"
|
||||||
|
{
|
||||||
|
buildInputs = [ zynqpkgs.mkbootimage ];
|
||||||
|
}
|
||||||
|
''
|
||||||
|
bifdir=`mktemp -d`
|
||||||
|
cd $bifdir
|
||||||
|
ln -s ${fsbl}/fsbl.elf fsbl.elf
|
||||||
|
ln -s ${gateware}/top.bit top.bit
|
||||||
|
ln -s ${firmware}/${fwtype}.elf ${fwtype}.elf
|
||||||
|
cat > boot.bif << EOF
|
||||||
|
the_ROM_image:
|
||||||
|
{
|
||||||
|
[bootloader]fsbl.elf
|
||||||
|
top.bit
|
||||||
|
${fwtype}.elf
|
||||||
|
}
|
||||||
|
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
|
||||||
|
'';
|
||||||
|
in {
|
||||||
|
"${target}-${variant}-firmware" = firmware;
|
||||||
|
"${target}-${variant}-gateware" = gateware;
|
||||||
|
"${target}-${variant}-jtag" = jtag;
|
||||||
|
"${target}-${variant}-sd" = sd;
|
||||||
|
} // (
|
||||||
|
if builtins.elem target fsblTargets
|
||||||
|
then {
|
||||||
|
"${target}-${variant}-fsbl-sd" = fsbl-sd;
|
||||||
|
}
|
||||||
|
else {}
|
||||||
|
);
|
||||||
|
in {
|
||||||
|
packages.x86_64-linux = (build { target = "zc706"; variant = "nist_clock"; }) //
|
||||||
|
(build { target = "zc706"; variant = "nist_clock_master"; }) //
|
||||||
|
(build { target = "zc706"; variant = "nist_clock_satellite"; }) //
|
||||||
|
(build { target = "zc706"; variant = "nist_clock_satellite_100mhz"; }) //
|
||||||
|
(build { target = "zc706"; variant = "nist_qc2"; }) //
|
||||||
|
(build { target = "zc706"; variant = "nist_qc2_master"; }) //
|
||||||
|
(build { target = "zc706"; variant = "nist_qc2_satellite"; }) //
|
||||||
|
(build { target = "zc706"; variant = "nist_qc2_satellite_100mhz"; }) //
|
||||||
|
(build { target = "zc706"; variant = "acpki_nist_clock"; }) //
|
||||||
|
(build { target = "zc706"; variant = "acpki_nist_clock_master"; }) //
|
||||||
|
(build { target = "zc706"; variant = "acpki_nist_clock_satellite"; }) //
|
||||||
|
(build { target = "zc706"; variant = "acpki_nist_clock_satellite_100mhz"; }) //
|
||||||
|
(build { target = "zc706"; variant = "acpki_nist_qc2"; }) //
|
||||||
|
(build { target = "zc706"; variant = "acpki_nist_qc2_master"; }) //
|
||||||
|
(build { target = "zc706"; variant = "acpki_nist_qc2_satellite"; }) //
|
||||||
|
(build { target = "zc706"; variant = "acpki_nist_qc2_satellite_100mhz"; }) //
|
||||||
|
(build { target = "kasli_soc"; variant = "demo"; json = ./demo.json; }) //
|
||||||
|
(build { target = "kasli_soc"; variant = "master"; json = ./kasli-soc-master.json; }) //
|
||||||
|
(build { target = "kasli_soc"; variant = "satellite"; json = ./kasli-soc-satellite.json; });
|
||||||
|
|
||||||
|
devShell.x86_64-linux = pkgs.mkShell {
|
||||||
|
name = "artiq-zynq-dev-shell";
|
||||||
|
buildInputs = with pkgs; [
|
||||||
|
rustPlatform.rust.rustc
|
||||||
|
rustPlatform.rust.cargo
|
||||||
|
llvmPackages_9.llvm
|
||||||
|
llvmPackages_9.clang-unwrapped
|
||||||
|
gnumake
|
||||||
|
cacert
|
||||||
|
zynqpkgs.cargo-xbuild
|
||||||
|
zynqpkgs.mkbootimage
|
||||||
|
openocd
|
||||||
|
openssh rsync
|
||||||
|
(python3.withPackages(ps: (with artiqpkgs; [ migen migen-axi misoc artiq artiq-netboot ps.jsonschema ps.pyftdi ])))
|
||||||
|
artiqpkgs.artiq
|
||||||
|
artiqpkgs.vivado
|
||||||
|
binutils-arm
|
||||||
|
];
|
||||||
|
XARGO_RUST_SRC = "${rustPlatform.rust.rustc}/lib/rustlib/src/rust/library";
|
||||||
|
CLANG_EXTRA_INCLUDE_DIR = "${pkgs.llvmPackages_9.clang-unwrapped.lib}/lib/clang/9.0.1/include";
|
||||||
|
OPENOCD_ZYNQ = "${zynq-rs}/openocd";
|
||||||
|
SZL = "${zynqpkgs.szl}";
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
35
shell.nix
35
shell.nix
@ -1,35 +0,0 @@
|
|||||||
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;
|
|
||||||
artiq-fast = <artiq-fast>;
|
|
||||||
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.llvmPackages_9.llvm
|
|
||||||
pkgs.llvmPackages_9.clang-unwrapped
|
|
||||||
pkgs.cacert
|
|
||||||
cargo-xbuild
|
|
||||||
|
|
||||||
pkgs.openocd
|
|
||||||
pkgs.openssh pkgs.rsync
|
|
||||||
|
|
||||||
(pkgs.python3.withPackages(ps: (with artiqpkgs; [ migen migen-axi misoc artiq artiq-netboot ps.jsonschema ps.pyftdi ])))
|
|
||||||
vivado
|
|
||||||
artiqpkgs.binutils-arm
|
|
||||||
|
|
||||||
(import "${zynq-rs}/nix/mkbootimage.nix" { inherit pkgs; })
|
|
||||||
];
|
|
||||||
|
|
||||||
XARGO_RUST_SRC = "${rustPlatform.rust.rustc}/lib/rustlib/src/rust/library";
|
|
||||||
CLANG_EXTRA_INCLUDE_DIR = "${pkgs.llvmPackages_9.clang-unwrapped.lib}/lib/clang/9.0.1/include";
|
|
||||||
OPENOCD_ZYNQ = "${zynq-rs}/openocd";
|
|
||||||
SZL = "${(import zynq-rs).szl}";
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
let
|
|
||||||
pkgs = import <nixpkgs> {};
|
|
||||||
in
|
|
||||||
pkgs.fetchgit {
|
|
||||||
url = "https://git.m-labs.hk/M-Labs/zynq-rs.git";
|
|
||||||
rev = "57d8d8fbc7087863305721bcb8fdbdd13d65bd65";
|
|
||||||
sha256 = "0gnbaxgingrxrxi2sjd592r1630ld4ckrz4r8ajx8zp7q3bb43jj";
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user