DRTIO port - scripts #135
28
default.nix
|
@ -8,12 +8,14 @@ let
|
|||
vivado = import <artiq-fast/vivado.nix> { 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; }
|
||||
)
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -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"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -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
|
|
@ -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'"
|
||||
|
|
|
@ -3,8 +3,10 @@ members = [
|
|||
"libc",
|
||||
"libdyld",
|
||||
"libdwarf",
|
||||
"libio",
|
||||
"libunwind",
|
||||
"runtime",
|
||||
"satman"
|
||||
]
|
||||
|
||||
[profile.release]
|
||||
|
|
19
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
|
||||
mwojcik marked this conversation as resolved
Outdated
sb10q
commented
There is no rule named There is no rule named ``runtime``.
|
||||
|
||||
.PHONY: all
|
||||
|
||||
|
||||
../build/pl.rs ../build/rustc-cfg: gateware/*
|
||||
../build/pl.rs ../build/rustc-cfg ../build/mem.rs: gateware/*
|
||||
sb10q
commented
What are these What are these ``*_target`` things for?
Also (assuming they are necessary at all), if there are no ``*_target`` files produced those rules should be ``PHONY``.
mwojcik
commented
I was aiming for clearer reference of the targets in nix-scripts, or when called manually. But it's unnecessary after all, it can be called straight up with the output file rule. I was aiming for clearer reference of the targets in nix-scripts, or when called manually. But it's unnecessary after all, it can be called straight up with the output file rule.
sb10q
commented
OK, I see. Yes the manual command is a bit unwieldy, I suggest adding them back but listed as PHONY. I will merge this now, please send a new PR. OK, I see. Yes the manual command is a bit unwieldy, I suggest adding them back but listed as PHONY. I will merge this now, please send a new PR.
|
||||
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 \
|
||||
sb10q
commented
Doesn't this break dependency checks? If you modify a source file Make won't re-run the build properly anymore. Doesn't this break dependency checks? If you modify a source file Make won't re-run the build properly anymore.
mwojcik
commented
No, it doesn't from what I saw. Cargo must do the checks on its own. And with No, it doesn't from what I saw. Cargo must do the checks on its own. And with ``find .`` it would also try to build satman at the same time as runtime.
sb10q
commented
Yes. But the Makefile needs to run Cargo at all when source is modified. Yes. But the Makefile needs to run Cargo at all when source is modified.
AFAICT if you remove the ``find`` then Make will simply skip running Cargo after a corresponding source file is modified.
mwojcik
commented
Well, with it, it tries to built satman with pl/mem files obviously not prepared, failing the build. And makes a circular dependency. Calling make for master runtime throws a warning, and then fails when trying to build satman.
I haven't had issues with modifying a file and not compiling, either. Only when gateware was changed, then yes, it couldn't detect that, and required a clean build. Well, with it, it tries to built satman with pl/mem files obviously not prepared, failing the build. And makes a circular dependency.
Calling make for master runtime throws a warning, and then fails when trying to build satman.
```
make: Circular ../build/firmware/armv7-none-eabihf/release/satman <- satman dependency dropped.
make: Circular ../build/firmware/armv7-none-eabihf/release/satman <- runtime dependency dropped.
```
I haven't had issues with modifying a file and not compiling, either. Only when gateware was changed, then yes, it couldn't detect that, and required a clean build.
sb10q
commented
How did Make detect the change then? > I haven't had issues with modifying a file and not compiling, either.
How did Make detect the change then?
mwojcik
commented
Good question, actually. It's just something I wasn't really thinking about as long as it could compile. A bit of an online search only says "it resolves the dependencies" somehow, I haven't went deep into it. For circular dependencies and miscompilations, of course that's my mistake - I made targets runtime/satman so nix-build could refer to these, but of course they're listed along with Good question, actually. It's just something I wasn't really thinking about as long as it could compile. A bit of an online search only says "it resolves the dependencies" somehow, I haven't went deep into it.
For circular dependencies and miscompilations, of course that's my mistake - I made targets runtime/satman so nix-build could refer to these, but of course they're listed along with ``find``, causing these issues. I'll change their name so they don't collide, update build script and restore ``find``.
|
||||
|
@ -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 \
|
||||
mwojcik marked this conversation as resolved
Outdated
sb10q
commented
Why the deviation from the runtime Make rules? Why the deviation from the runtime Make rules?
mwojcik
commented
You mean in the name of the rule? Fair point, no particular reason for it, I'll revert it. You mean in the name of the rule? Fair point, no particular reason for it, I'll revert it.
sb10q
commented
The name of the rule needs to match the output file, otherwise Make keeps evaluating it every time it is invoked with that target. The name of the rule needs to match the output file, otherwise Make keeps evaluating it every time it is invoked with that target.
|
||||
--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
|
You can read the JSON to determine that.
Nix has
builtins.fromJSON
zc706 doesn't use JSONs, though. Now that I think about it I could make it a bit better still by having the fwtype specified in the list of targets at the bottom, passed to the build function instead.