diff --git a/default.nix b/default.nix index a9b7f19..cb28ac1 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}" ${fwtype} ''; 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 0000000..1de434f --- /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 0000000..7eafabf --- /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 a423d41..f72d223 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 + artiq_netboot $load_bitstream_cmd -f $result_dir/$fwtype.bin -b $board_host fi diff --git a/remote_run.sh b/remote_run.sh index fe3e479..9a22997 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 89b241e..f8473e4 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 e2dc094..5eca52f 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,16 +1,18 @@ TARGET := zc706 GWARGS := -V simple -all: ../build/firmware/armv7-none-eabihf/release/runtime ../build/runtime.bin +all: runtime + +runtime: ../build/runtime.bin .PHONY: all ../build/pl.rs ../build/rustc-cfg: 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 cd runtime && \ XBUILD_SYSROOT_PATH=`pwd`/../../build/sysroot \ cargo xbuild --release \ @@ -19,3 +21,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 + +satmanout: ../build/pl.rs ../build/rustc-cfg + cd satman && \ + XBUILD_SYSROOT_PATH=`pwd`/../../build/sysroot \ + cargo xbuild --release \ + --target-dir ../../build/firmware \ + --no-default-features --features=target_$(TARGET) + +satman: satmanout + llvm-objcopy -O binary ../build/firmware/armv7-none-eabihf/release/satman ../build/satman.bin \ No newline at end of file