Update manual test script
Minor fix to fpga pytest.
Minor fix to meson build flow in splice script and also update
main script to use meson.
diff --git a/test/fpga_manual_test.sh b/test/fpga_manual_test.sh
index 64581b1..48acb5d 100755
--- a/test/fpga_manual_test.sh
+++ b/test/fpga_manual_test.sh
@@ -3,51 +3,109 @@
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
set -e
-USAGE="Usage: ./test/fpga_manual_test.sh <UART PORT ATTACHED>.
-Example : ./test/fpga_manual_test.sh /dev/ttyUSB0"
-if [ $# == 0 ] ; then
+function usage() {
+ cat << USAGE
+Usage: ./test/fpga_manual_test.sh -u <UART PORT ATTACHED> -n -p.
+-n Controls whether a new fpga bitfile is built
+-p Controls whether the existing bitfile at build/lowrisc_systems_top_earlgrey_nexysvideo_0.1
+is programmed.
+
+The following command builds the fpga, programs it onto the device and begins testing
+./test/fpga_manual_test.sh -u /dev/ttyUSB0 -n -p
+
+The following command assumes there exists a bitfile already, programs it and begins testing
+./test/fpga_manual_test.sh -u /dev/ttyUSB0 -p
+
+The following command assumes the bitfile is already programmed and begins testing
+./test/fpga_manual_test.sh -u /dev/ttyUSB0
+
+USAGE
+}
+
+FPGA_UART=
+BUILD_FPGA=0
+PROGRAM_FPGA=0
+while getopts ':pnu:' opt; do
+ case "${opt}" in
+ u) FPGA_UART=$OPTARG;;
+ n) BUILD_FPGA=1;;
+ p) PROGRAM_FPGA=1;;
+ ?) usage && exit 1;;
+ *) usage
+ error "Unexpected option ${opt}"
+ ;;
+ esac
+done
+
+# Double check a device has been specified
+if [ -z "$FPGA_UART" ] ; then
echo "Please make sure to pass FPGA's UART port as an argument to the script."
- echo -e "$USAGE"
echo "To find out which ttyUSB to use exactly, unplug/plug UART cable and find the last entry in dmesg"
+ echo "Use -h for more usage details"
exit 1;
fi
-FPGA_UART="$1"
-readonly TEST_TARGETS=("flash_ctrl"
- "hmac"
- "rv_timer"
+readonly TEST_TARGETS=("flash_ctrl/flash_test.bin"
+ "hmac/sha256_test.bin"
+ "rv_timer/rv_timer_test.bin"
)
-echo "Compiling ROM."
-make -C sw SW_DIR=boot_rom clean all
+BUILD_TARGET=${PWD}/build-fpga
+./meson_init.sh -f
-echo "Building FPGA."
-fusesoc --cores-root . build lowrisc:systems:top_earlgrey_nexysvideo
+if [ ${BUILD_FPGA} -eq 1 ] ; then
+ echo "Compiling ROM - this is needed in order for the build step below to correctly infer ROM"
+ ninja -C ${BUILD_TARGET} sw/device/boot_rom/boot_rom.vmem
-echo "Splice FPGA."
-util/fpga/splice_nexysvideo.sh
+ echo "Building FPGA."
+ fusesoc --cores-root . build lowrisc:systems:top_earlgrey_nexysvideo \
+ --ROM_INIT_FILE=${BUILD_TARGET}/sw/device/boot_rom/boot_rom.vmem
+fi
-echo "Program FPGA."
-fusesoc --cores-root . pgm lowrisc:systems:top_earlgrey_nexysvideo:0.1
+if [ ${PROGRAM_FPGA} -eq 1 ] ; then
+ echo "Splice latest boot ROM and program FPGA."
+ util/fpga/splice_nexysvideo.sh
+ fusesoc --cores-root . pgm lowrisc:systems:top_earlgrey_nexysvideo
+fi
echo "Build spiflash tool."
-make -C sw/host/spiflash clean all
+ninja -C ${BUILD_TARGET} sw/host/spiflash/spiflash
for target in "${TEST_TARGETS[@]}"; do
echo "Building ${target} binaries."
- make -C sw SW_DIR=tests/${target} SW_BUILD_DIR=${target}_out clean all
+
+ ninja -C ${BUILD_TARGET} sw/device/tests/${target}/
done
-# Eventually this step should be replaced by PyTest
-# How the test results will be looked at manually
-# To observe results: use
-# miniterm.py /dev/ttyUSBx 230400
-# To find out which ttyUSB to use exactly, unplug/plug UART cable and find
-# the last entry in dmesg
+FAIL_TARGETS=()
+
+# Invoke self contained tests
+
+set +e
for target in "${TEST_TARGETS[@]}"; do
- echo "Flashing ${target}_out/sw.bin onto FPGA for tests."
- ./sw/host/spiflash/spiflash --input=sw/${target}_out/sw.bin
- sleep 5
+ echo "Flashing binaries onto FPGA for tests."
+ pytest -s -v test/systemtest/functional_fpga_test.py \
+ --test_bin ${BUILD_TARGET}/sw/device/tests/"${target}" \
+ --fpga_uart ${FPGA_UART} \
+ --spiflash sw/host/spiflash/spiflash
+
+ if [[ $? == 1 ]]; then
+ FAIL_TARGETS=("${FAIL_TARGETS[@]}" "${target}")
+ fi
+
done
+
+if [ ${#FAIL_TARGETS[@]} -eq 0 ]; then
+ echo "TESTS PASS!"
+else
+ echo
+ echo "Failing targets:"
+ for target in "${FAIL_TARGETS[@]}"; do
+ echo "* ${target}"
+ done
+ echo
+ echo "TESTS FAILED!"
+ exit 1
+fi
diff --git a/test/systemtest/conftest.py b/test/systemtest/conftest.py
index 7c8142b..6111534 100644
--- a/test/systemtest/conftest.py
+++ b/test/systemtest/conftest.py
@@ -116,7 +116,7 @@
def fpga_uart(pytestconfig):
"""Return the path to the UART attached to the FPGA."""
path = Path(pytestconfig.getoption('fpga_uart')).resolve()
- assert path.is_file()
+ assert path.exists() and not path.is_dir()
return path
@pytest.fixture(scope="session")
diff --git a/util/fpga/splice_nexysvideo.sh b/util/fpga/splice_nexysvideo.sh
index 4c03700..9546055 100755
--- a/util/fpga/splice_nexysvideo.sh
+++ b/util/fpga/splice_nexysvideo.sh
@@ -15,12 +15,13 @@
set -e
BUILD_DIR=build-fpga
-TARGET_PREFIX="$BUILD_DIR/sw/build_rom/build_rom"
+TARGET_PREFIX="$BUILD_DIR/sw/device/boot_rom/boot_rom"
+#TARGET_PREFIX="sw/${BUILD_DIR}/rom"
FPGA_BUILD_DIR=build/lowrisc_systems_top_earlgrey_nexysvideo_0.1/synth-vivado/
FPGA_BIT_NAME=lowrisc_systems_top_earlgrey_nexysvideo_0.1
-./meson-init.sh -f
-ninja -C "$BUILD_DIR" sw/boot_rom/boot_rom.bin
+./meson_init.sh -f
+ninja -C "$BUILD_DIR" sw/device/boot_rom/boot_rom.bin
srec_cat ${TARGET_PREFIX}.bin -binary -offset 0x0 -o ${TARGET_PREFIX}.brammem \
-vmem -Output_Block_Size 4;