From 0efa83e95609b9d22357f0b262babe89d03da53f Mon Sep 17 00:00:00 2001 From: mwojcik Date: Fri, 8 Oct 2021 16:25:13 +0800 Subject: [PATCH] update build scripts for DRTIO Reviewed-on: https://git.m-labs.hk/M-Labs/artiq-zynq/pulls/135 Co-authored-by: mwojcik Co-committed-by: mwojcik --- default.nix | 28 +++++++++++++++---- kasli-soc-master.json | 60 ++++++++++++++++++++++++++++++++++++++++ kasli-soc-satellite.json | 60 ++++++++++++++++++++++++++++++++++++++++ local_run.sh | 11 +++++--- remote_run.sh | 9 ++++-- src/Cargo.toml | 2 ++ src/Makefile | 19 +++++++++---- 7 files changed, 171 insertions(+), 18 deletions(-) create mode 100644 kasli-soc-master.json create mode 100644 kasli-soc-satellite.json diff --git a/default.nix b/default.nix index 267019ea..2826ce1c 100644 --- a/default.nix +++ b/default.nix @@ -8,12 +8,14 @@ let vivado = import { inherit pkgs; }; # FSBL configuration supplied by Vivado 2020.1 for these boards: fsblTargets = ["zc702" "zc706" "zed"]; + sat_variants = ["satellite" "acpki_satellite" "nist_clock_satellite" "nist_qc2_satellite"]; 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 @@ -33,15 +35,15 @@ let 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}" + make TARGET=${target} GWARGS="${if json == null then "-V ${variant}" else json}" ../build/${fwtype}.bin ''; installPhase = '' mkdir -p $out $out/nix-support - cp ../build/runtime.bin $out/runtime.bin - cp ../build/firmware/armv7-none-eabihf/release/runtime $out/runtime.elf - echo file binary-dist $out/runtime.bin >> $out/nix-support/hydra-build-products - echo file binary-dist $out/runtime.elf >> $out/nix-support/hydra-build-products + 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; @@ -66,7 +68,7 @@ let '' mkdir $out ln -s ${szl}/szl.elf $out - ln -s ${firmware}/runtime.bin $out + ln -s ${firmware}/${fwtype}.bin $out ln -s ${gateware}/top.bit $out ''; sd = pkgs.runCommand "${target}-${variant}-sd" @@ -132,11 +134,25 @@ let in ( (build { target = "zc706"; variant = "simple"; }) // + (build { target = "zc706"; variant = "master"; }) // + (build { target = "zc706"; variant = "satellite"; }) // (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_qc2"; }) // + (build { target = "zc706"; variant = "nist_qc2_master"; }) // + (build { target = "zc706"; variant = "nist_qc2_satellite"; }) // (build { target = "zc706"; variant = "acpki_simple"; }) // + (build { target = "zc706"; variant = "acpki_master"; }) // + (build { target = "zc706"; variant = "acpki_satellite"; }) // (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_qc2"; }) // + (build { target = "zc706"; variant = "acpki_nist_qc2_master"; }) // + (build { target = "zc706"; variant = "acpki_nist_qc2_satellite"; }) // (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; } ) diff --git a/kasli-soc-master.json b/kasli-soc-master.json new file mode 100644 index 00000000..1de434fa --- /dev/null +++ b/kasli-soc-master.json @@ -0,0 +1,60 @@ +{ + "target": "kasli_soc", + "variant": "master", + "hw_rev": "v1.0", + "base": "master", + "peripherals": [ + { + "type": "grabber", + "ports": [0] + }, + { + "type": "dio", + "ports": [1], + "bank_direction_low": "input", + "bank_direction_high": "output" + }, + { + "type": "dio", + "ports": [2], + "bank_direction_low": "output", + "bank_direction_high": "output" + }, + { + "type": "urukul", + "dds": "ad9910", + "ports": [3, 4], + "clk_sel": 2 + }, + { + "type": "zotino", + "ports": [5] + }, + { + "type": "sampler", + "ports": [6, 7] + }, + { + "type": "mirny", + "ports": [8], + "clk_sel": 1, + "refclk": 125e6 + }, + { + "type": "fastino", + "ports": [9] + }, + { + "type": "dio", + "ports": [10], + "bank_direction_low": "input", + "bank_direction_high": "input" + }, + { + "type": "dio", + "ports": [11], + "bank_direction_low": "output", + "bank_direction_high": "input" + } + ] +} diff --git a/kasli-soc-satellite.json b/kasli-soc-satellite.json new file mode 100644 index 00000000..7eafabfa --- /dev/null +++ b/kasli-soc-satellite.json @@ -0,0 +1,60 @@ +{ + "target": "kasli_soc", + "variant": "satellite", + "hw_rev": "v1.0", + "base": "satellite", + "peripherals": [ + { + "type": "grabber", + "ports": [0] + }, + { + "type": "dio", + "ports": [1], + "bank_direction_low": "input", + "bank_direction_high": "output" + }, + { + "type": "dio", + "ports": [2], + "bank_direction_low": "output", + "bank_direction_high": "output" + }, + { + "type": "urukul", + "dds": "ad9910", + "ports": [3, 4], + "clk_sel": 2 + }, + { + "type": "zotino", + "ports": [5] + }, + { + "type": "sampler", + "ports": [6, 7] + }, + { + "type": "mirny", + "ports": [8], + "clk_sel": 1, + "refclk": 125e6 + }, + { + "type": "fastino", + "ports": [9] + }, + { + "type": "dio", + "ports": [10], + "bank_direction_low": "input", + "bank_direction_high": "input" + }, + { + "type": "dio", + "ports": [11], + "bank_direction_low": "output", + "bank_direction_high": "input" + } + ] +} diff --git a/local_run.sh b/local_run.sh index a423d41a..1e01fe00 100755 --- a/local_run.sh +++ b/local_run.sh @@ -14,8 +14,9 @@ fi impure=0 load_bitstream=1 board_type="kasli_soc" +fw_type="runtime" -while getopts "ilb:t:" opt; do +while getopts "ilb:t:f:" opt; do case "$opt" in \?) exit 1 ;; @@ -27,6 +28,8 @@ while getopts "ilb:t:" opt; do ;; t) board_type=$OPTARG ;; + f) fw_type=$OPTARG + ;; esac done @@ -49,10 +52,10 @@ if [ $impure -eq 1 ]; then if [ $load_bitstream -eq 1 ]; then load_bitstream_cmd="-g $build_dir/gateware/top.bit" fi - artiq_netboot $load_bitstream_cmd -f $build_dir/runtime.bin -b $board_host + artiq_netboot $load_bitstream_cmd -f $build_dir/$fwtype.bin -b $board_host else if [ $load_bitstream -eq 1 ]; then load_bitstream_cmd="-g $result_dir/top.bit" fi - artiq_netboot $load_bitstream_cmd -f $result_dir/runtime.bin -b $board_host -fi + artiq_netboot $load_bitstream_cmd -f $result_dir/$fwtype.bin -b $board_host +fi \ No newline at end of file diff --git a/remote_run.sh b/remote_run.sh index fe3e4794..9a229973 100755 --- a/remote_run.sh +++ b/remote_run.sh @@ -20,8 +20,9 @@ impure_dir="build" sshopts="" load_bitstream=1 board_host="192.168.1.52" +fw_type="runtime" -while getopts "h:id:o:l" opt; do +while getopts "h:id:o:lt:" opt; do case "$opt" in \?) exit 1 ;; @@ -38,6 +39,8 @@ while getopts "h:id:o:l" opt; do ;; b) board_host=$OPTARG ;; + t) fw_type=$OPTARG + ;; esac done @@ -53,12 +56,12 @@ if [ $impure -eq 1 ]; then if [ $load_bitstream -eq 1 ]; then load_bitstream_cmd="-g build/gateware/top.bit" fi - firmware="build/runtime.bin" + firmware="build/$fw_type.bin" else if [ $load_bitstream -eq 1 ]; then load_bitstream_cmd="-g $pure_dir/top.bit" fi - firmware="$pure_dir/runtime.bin" + firmware="$pure_dir/$fw_type.bin" fi echo "Programming board..." ssh $sshopts $target_host "cd $target_folder; openocd -f zc706.cfg -c'load_image szl.elf; resume 0; exit'" diff --git a/src/Cargo.toml b/src/Cargo.toml index 89b241ee..f8473e43 100644 --- a/src/Cargo.toml +++ b/src/Cargo.toml @@ -3,8 +3,10 @@ members = [ "libc", "libdyld", "libdwarf", + "libio", "libunwind", "runtime", + "satman" ] [profile.release] diff --git a/src/Makefile b/src/Makefile index e2dc0943..a6a15e0f 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,16 +1,15 @@ TARGET := zc706 GWARGS := -V simple -all: ../build/firmware/armv7-none-eabihf/release/runtime ../build/runtime.bin +all: ../build/runtime.bin .PHONY: all - -../build/pl.rs ../build/rustc-cfg: gateware/* +../build/pl.rs ../build/rustc-cfg ../build/mem.rs: gateware/* mkdir -p ../build - python gateware/$(TARGET).py -r ../build/pl.rs -c ../build/rustc-cfg $(GWARGS) + python gateware/$(TARGET).py -r ../build/pl.rs -c ../build/rustc-cfg -m ../build/mem.rs $(GWARGS) -../build/firmware/armv7-none-eabihf/release/runtime: ../build/pl.rs ../build/rustc-cfg $(shell find . -print) +../build/firmware/armv7-none-eabihf/release/runtime: ../build/pl.rs ../build/rustc-cfg ../build/mem.rs $(shell find . -print) cd runtime && \ XBUILD_SYSROOT_PATH=`pwd`/../../build/sysroot \ cargo xbuild --release \ @@ -19,3 +18,13 @@ all: ../build/firmware/armv7-none-eabihf/release/runtime ../build/runtime.bin ../build/runtime.bin: ../build/firmware/armv7-none-eabihf/release/runtime llvm-objcopy -O binary ../build/firmware/armv7-none-eabihf/release/runtime ../build/runtime.bin + +../build/firmware/armv7-none-eabihf/release/satman: ../build/pl.rs ../build/rustc-cfg ../build/mem.rs $(shell find . -print) + cd satman && \ + XBUILD_SYSROOT_PATH=`pwd`/../../build/sysroot \ + cargo xbuild --release \ + --target-dir ../../build/firmware \ + --no-default-features --features=target_$(TARGET) + +../build/satman.bin: ../build/firmware/armv7-none-eabihf/release/satman + llvm-objcopy -O binary ../build/firmware/armv7-none-eabihf/release/satman ../build/satman.bin \ No newline at end of file