Add camera power down/up workaround
Change-Id: Ia666caa8dad83bf803b47bc1526316e2b3019043
diff --git a/nexus-non-interactive-test.sh b/nexus-non-interactive-test.sh
index 411d605..c67d94c 100755
--- a/nexus-non-interactive-test.sh
+++ b/nexus-non-interactive-test.sh
@@ -25,6 +25,19 @@
export LOG_TIMEOUT="${LOG_TIMEOUT:-900}"
export LOG_CHECK_INTERVAL="${LOG_CHECK_INTERVAL:-30}"
+
+function mcu_write() {
+ string=$1
+ length=${#string}
+ for ((i = 0; i < length; i++)); do
+ char="${string:i:1}"
+ echo -n "$char"
+ sleep 0.5
+ done > "/dev/Nexus-FTDI-${NEXUS_ID}-MCU-UART"
+ echo -e "\r" > "/dev/Nexus-FTDI-${NEXUS_ID}-MCU-UART"
+}
+
+
if [ $# -lt 2 ] || [ $# -gt 3 ] ; then
cat << EOF
$0 <bitstream> <binary> [nexus index]
@@ -52,9 +65,14 @@
then
echo "/dev/Nexus-CP210-FPGA-UART-${NEXUS_ID} appears to be busy"
fi
+if fuser "/dev/Nexus-FTDI-${NEXUS_ID}-MCU-UART"
+then
+ echo "/dev/Nexus-FTDI-${NEXUS_ID}-MCU-UART appears to be busy"
+fi
stty --file="/dev/Nexus-FTDI-${NEXUS_ID}-FPGA-UART" 115200
stty --file="/dev/Nexus-CP210-FPGA-UART-${NEXUS_ID}" 115200
+stty --file="/dev/Nexus-FTDI-${NEXUS_ID}-MCU-UART" 115200
# Starting logging the UARTs
cat "/dev/Nexus-FTDI-${NEXUS_ID}-FPGA-UART" > uart.sc.log &
@@ -68,14 +86,19 @@
kill -KILL ${SC_UART_PID} ; kill -KILL ${SMC_UART_PID}' 0
if [[ -f "${BITSTREAM_PATH}" ]]; then
+ # Issue a no-op command to flush the character buffer in case it isn't empty
+ mcu_write "help"
scp \
"${BITSTREAM_PATH}" \
"root@nexus${NEXUS_ID}:/mnt/mmcp1/"
+ mcu_write "camera_powerdown"
+ sleep 5
# 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"
+ mcu_write "camera_powerup"
fi
OT_TOOL_PATH=`command -v opentitantool`