Merge "Optional bitstream loading for nexus test script"
diff --git a/nexus-non-interactive-test.sh b/nexus-non-interactive-test.sh
index fd0f6ce..3252393 100755
--- a/nexus-non-interactive-test.sh
+++ b/nexus-non-interactive-test.sh
@@ -27,7 +27,9 @@
 cat << EOF
     $0 <bitstream> <binary> [nexus index]
     bitstream: The path to the nexus bitstream.
-               This will be copied and loaded to the fpga
+               This will be copied and loaded to the fpga.
+               If the bitstream file doesn't exist the test will continue with
+               whatever bitstream is already loaded.
     binary: The path to the test binary.
             This will be loaded with the opentitantool utility using the
             bootstrap subcommand
@@ -52,10 +54,6 @@
 stty --file="/dev/Nexus-FTDI-${NEXUS_ID}-FPGA-UART" 115200
 stty --file="/dev/Nexus-CP210-FPGA-UART-${NEXUS_ID}" 115200
 
-scp \
-    "${BITSTREAM_PATH}" \
-    "root@nexus${NEXUS_ID}:/mnt/mmcp1/"
-
 # Starting logging the UARTs
 cat "/dev/Nexus-FTDI-${NEXUS_ID}-FPGA-UART" > uart.sc.log &
 SC_UART_PID=$!
@@ -67,11 +65,16 @@
       sleep 10 ; \
       kill -KILL ${SC_UART_PID} ; kill -KILL ${SMC_UART_PID}' 0
 
-# zturn exits with 1 even when working correctly. Mask with exit 0
-BITSTREAM_NAME=$(basename "${BITSTREAM_PATH}")
-ssh \
-    "root@nexus${NEXUS_ID}" \
-    "/mnt/mmcp1/zturn -d a /mnt/mmcp1/${BITSTREAM_NAME} ; exit 0"
+if [[ -f "${BITSTREAM_PATH}" ]]; then
+    scp \
+        "${BITSTREAM_PATH}" \
+        "root@nexus${NEXUS_ID}:/mnt/mmcp1/"
+    # zturn exits with 1 even when working correctly. Mask with exit 0
+    BITSTREAM_NAME=$(basename "${BITSTREAM_PATH}")
+    ssh \
+        "root@nexus${NEXUS_ID}" \
+        "/mnt/mmcp1/zturn -d a /mnt/mmcp1/${BITSTREAM_NAME} ; exit 0"
+fi
 
 OT_TOOL_PATH=`command -v opentitantool`
 NEXUS_JSON_DIR=`dirname "${OT_TOOL_PATH}"`