pure Nix build system

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

5
.gitignore vendored

@ -1,4 +1,3 @@
build/
runtime/src/pl.rs
target/
result
examples/*.elf
__pycache__

@ -1,6 +0,0 @@
Build with:
```shell
cargo xbuild -p runtime --release
cargo xbuild -p szl --release
```

@ -0,0 +1,72 @@
{
mozillaOverlay ? import (builtins.fetchTarball https://github.com/mozilla/nixpkgs-mozilla/archive/master.tar.gz),
}:
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 = [
(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
]; }
''
python ${./zc706.py} gateware
mkdir -p $out $out/nix-support
cp build/top.bit $out
echo file binary-dist $out/top.bit >> $out/nix-support/hydra-build-products
'';
zc706-jtag = pkgs.runCommand "zc706-jtag" {}
''
mkdir $out
ln -s ${zc706-szl}/szl $out
ln -s ${zc706-gateware}/top.bit $out
'';
}

@ -0,0 +1 @@
"1mfprkcq4cr4jiihy1qn8q8qymxwhafh90vyr3i4brj4aq5kksn1"

@ -5,20 +5,8 @@ use std::io::Write;
use std::path::{Path, PathBuf};
fn main() {
// FIXME: this is dirty and unreliable. How to depend on the output of the runtime build?
let payload = "../target/armv7-none-eabihf/release/runtime";
let out = env::var("OUT_DIR").unwrap();
let out_dir = &PathBuf::from(&out);
let status = Command::new("llvm-objcopy")
.args(&["-O", "binary", payload, &format!("{}/payload.bin", out)])
.status().unwrap();
assert!(status.success());
let status = Command::new("lzma")
.args(&["--keep", "-f", &format!("{}/payload.bin", out)])
.status().unwrap();
assert!(status.success());
println!("cargo:rerun-if-changed={}", payload);
let status = Command::new("clang")
.args(&["-target", "armv7-unknown-linux", "-fno-stack-protector",

@ -39,7 +39,7 @@ pub fn main_core0() {
libboard_zynq::stdio::drop_uart(); // reinitialize UART after clocking change
let mut ddr = zynq::ddr::DdrRam::new();
let payload = include_bytes!(concat!(env!("OUT_DIR"), "/payload.bin.lzma"));
let payload = include_bytes!("payload.bin.lzma");
info!("decompressing payload");
let result = unsafe {
unlzma_simple(payload.as_ptr(), payload.len() as i32, ddr.ptr(), lzma_error)

@ -8,6 +8,6 @@ TARGET_FOLDER=/tmp/zynq-\$USER
ssh $TARGET_HOST "mkdir -p $TARGET_FOLDER"
rsync openocd/* $TARGET_HOST:$TARGET_FOLDER
rsync target/armv7-none-eabihf/release/szl $TARGET_HOST:$TARGET_FOLDER
rsync build/top.bit $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'"

Binary file not shown.

@ -0,0 +1,24 @@
{ pkgs }:
let
rustcSrc = pkgs.fetchgit {
url = "https://github.com/rust-lang/rust.git";
# master of 2020-04-10
rev = "94d346360da50f159e0dc777dc9bc3c5b6b51a00";
sha256 = "1hcqdz4w2vqb12rrqqcjbfs5s0w4qwjn7z45d1zh0fzncdcf6f7d";
fetchSubmodules = true;
};
rustManifest = ./channel-rust-nightly.toml;
targets = [];
rustChannelOfTargets = _channel: _date: targets:
(pkgs.lib.rustLib.fromManifestFile rustManifest {
inherit (pkgs) stdenv fetchurl patchelf;
}).rust.override { inherit targets; };
rust =
rustChannelOfTargets "nightly" null targets;
in
pkgs.recurseIntoAttrs (pkgs.makeRustPlatform {
rustc = rust // { src = rustcSrc; };
cargo = rust;
})

@ -1,50 +0,0 @@
let
mozillaOverlay = import (builtins.fetchTarball "https://github.com/mozilla/nixpkgs-mozilla/archive/master.tar.gz");
artiq-fast = builtins.fetchTarball "https://nixbld.m-labs.hk/channel/custom/artiq/fast-beta/artiq-fast/nixexprs.tar.xz";
pkgs = import <nixpkgs> { overlays = [ mozillaOverlay ]; };
rustcSrc = pkgs.fetchgit {
url = "https://github.com/rust-lang/rust.git";
# master of 2020-04-10
rev = "94d346360da50f159e0dc777dc9bc3c5b6b51a00";
sha256 = "1hcqdz4w2vqb12rrqqcjbfs5s0w4qwjn7z45d1zh0fzncdcf6f7d";
fetchSubmodules = true;
};
rustManifest = ./channel-rust-nightly.toml;
targets = [];
rustChannelOfTargets = _channel: _date: targets:
(pkgs.lib.rustLib.fromManifestFile rustManifest {
inherit (pkgs) stdenv fetchurl patchelf;
}).rust.override { inherit targets; };
rust =
rustChannelOfTargets "nightly" null targets;
rustPlatform = pkgs.recurseIntoAttrs (pkgs.makeRustPlatform {
rustc = rust // { src = rustcSrc; };
cargo = rust;
});
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 = [
rustPlatform.rust.rustc
rustPlatform.rust.cargo
rustcSrc
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 = "${rustcSrc}/src";
}

@ -1,7 +1,6 @@
#!/usr/bin/env python
import argparse
import os
from migen import *
@ -71,7 +70,7 @@ def main():
if action == "gateware":
soc.build()
elif action == "rustif":
write_csr_file(soc, os.path.join("runtime", "src", "pl.rs"))
write_csr_file(soc, "pl.rs")
else:
raise ValueError("invalid action", action)

Loading…
Cancel
Save