Support extflash in nexus-non-interactive-test.sh

Change-Id: Ifb1b8258c5d9157a55f1bcb27a862e2f197950a8
diff --git a/nexus-non-interactive-test.sh b/nexus-non-interactive-test.sh
index ff7ef13..fd0f6ce 100755
--- a/nexus-non-interactive-test.sh
+++ b/nexus-non-interactive-test.sh
@@ -20,6 +20,8 @@
 BITSTREAM_PATH="$1"
 BINARY_PATH="$2"
 NEXUS_ID="${NEXUS_ID:-$3}"
+DEFAULT_NEXUS_FLASH_PATH="${ROOTDIR}/internal/nexus_usage/nexus_flash.sh"
+NEXUS_FLASH_PATH="${NEXUS_FLASH_PATH:-$DEFAULT_NEXUS_FLASH_PATH}"
 
 if [ $# -lt 2 ] || [ $# -gt 3 ] ; then
 cat << EOF
@@ -75,11 +77,18 @@
 NEXUS_JSON_DIR=`dirname "${OT_TOOL_PATH}"`
 NEXUS_JSON_PATH="${NEXUS_JSON_DIR}/nexus.json"
 
-opentitantool \
-    --conf "${NEXUS_JSON_PATH}" \
-    --interface nexus \
-    --usb-serial "Nexus-FTDI-${NEXUS_ID}" \
-    bootstrap "${BINARY_PATH}"
+if [[ "${BINARY_PATH}" == *".bin" ]]; then
+    opentitantool \
+        --conf "${NEXUS_JSON_PATH}" \
+        --interface nexus \
+        --usb-serial "Nexus-FTDI-${NEXUS_ID}" \
+        bootstrap "${BINARY_PATH}"
+elif [[ "${BINARY_PATH}" == *"extflash.tar" ]]; then
+    export NEXUS_BOARD="${NEXUS_ID}"
+    export OT_TOOL="${OT_TOOL_PATH}"
+    export NEXUS_JSON="${NEXUS_JSON_PATH}"
+    "${NEXUS_FLASH_PATH}" "${BINARY_PATH}"
+fi
 
 timeout 300 bash -c 'until grep -q PASS! uart.sc.log ; do
                         echo "Expected log is missing. Wait up to 300s."