forked from M-Labs/artiq-zynq
flake: check firmware for potentially overlapping code
This commit is contained in:
36
flake.nix
36
flake.nix
@@ -175,6 +175,40 @@
|
||||
}" ${fwtype}
|
||||
'';
|
||||
|
||||
checkPhase = ''
|
||||
# check if the overlapping RTIO/DMA/batch sections
|
||||
# don't overwrite other parts
|
||||
max_size=2048 # half the page size (see link.x)
|
||||
|
||||
sections_to_check=(
|
||||
".rtio_page"
|
||||
".rtio_wide_page"
|
||||
".dma_page"
|
||||
".dma_wide_page"
|
||||
".batch_page"
|
||||
".batch_wide_page"
|
||||
)
|
||||
|
||||
objdump_output=$(objdump -h "../build/firmware/armv7-none-eabihf/release/${fwtype}")
|
||||
|
||||
for section in "''${sections_to_check[@]}"; do
|
||||
line=$(echo "$objdump_output" | grep -w "$section" || true)
|
||||
|
||||
if [ -z "$line" ]; then
|
||||
echo "ERROR: section $section not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
size_hex=$(echo "$line" | awk '{print $3}')
|
||||
size_dec=$((16#$size_hex))
|
||||
|
||||
if [ "$size_dec" -ge "$max_size" ]; then
|
||||
echo "ERROR: section $section ($size_dec bytes) exceeds $max_size bytes."
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out $out/nix-support
|
||||
cp ../build/${fwtype}.bin $out/${fwtype}.bin
|
||||
@@ -183,7 +217,7 @@
|
||||
echo file binary-dist $out/${fwtype}.elf >> $out/nix-support/hydra-build-products
|
||||
'';
|
||||
|
||||
doCheck = false;
|
||||
doCheck = true;
|
||||
dontFixup = true;
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user