refactor nexus_mcu_write to use nexus_mcu.py

Add some verbosity to nexus commands to aid in understanding what is
going on in the louhi logs

Change-Id: Ic54620a5747bbd3725b67d2cdebe274d34f57b59
diff --git a/platforms/nexus/setup.sh b/platforms/nexus/setup.sh
index b099047..9b27f13 100644
--- a/platforms/nexus/setup.sh
+++ b/platforms/nexus/setup.sh
@@ -149,6 +149,7 @@
         return 1
     fi
 
+    echo "Resetting nexus-${NEXUS_ID}"
     opentitantool gpio write RESET true
     opentitantool gpio write RESET false
     opentitantool gpio write RESET true
@@ -190,7 +191,7 @@
     local erase_size="$(du -b ${flash_tar} \
         | awk '{ print $1 + (n - $1 % n) % n }' n=262144)"
 
-    echo "Program SPI using ${NEXUS_SPI_PASSTHRU} on board ${NEXUS_ID}"
+    echo "Program SPI using ${NEXUS_SPI_PASSTHRU} on nexus-${NEXUS_ID}"
     opentitantool bootstrap "${NEXUS_SPI_PASSTHRU}"
     opentitantool spi block-erase --start 0 --length "${erase_size}"
     opentitantool spi program --start 0 "${flash_tar}"
@@ -216,27 +217,21 @@
         return 1
     fi
 
-    echo "Clearing nexus SPI flash"
+    echo "Clearing nexus-${NEXUS_ID} SPI flash"
     nexus_reset
     opentitantool bootstrap "${NEXUS_SPI_PASSTHRU}"
     opentitantool spi block-erase --start 0 --length 262144
 }
 
 function nexus_mcu_write() {
-    # Slowly send characters to the Nexus MCU
+    # Send command to the Nexus MCU REPL
     if [[ -z "${NEXUS_ID}" ]]; then
         echo "Run set-nexus-id first"
         return 1
     fi
 
-    local string="$1"
-    local length="${#string}"
-    for ((i = 0; i < length; i++)); do
-        local char="${string:i:1}"
-        echo -n "$char" > "/dev/Nexus-FTDI-${NEXUS_ID}-MCU-UART"
-        sleep 0.5
-    done
-    echo -e "\r" > "/dev/Nexus-FTDI-${NEXUS_ID}-MCU-UART"
+    echo "Sending nexus-${NEXUS_ID} MCU the command: $@"
+    nexus_mcu.py --nexus_id=${NEXUS_ID} "$@"
 }
 
 function nexus_load_bitstream
@@ -264,6 +259,7 @@
         return 1
     fi
 
+    echo "Pushing ${bitstream_path} to nexus-${NEXUS_ID}"
     # Issue a no-op command to flush the character buffer in case it isn't empty
     nexus_mcu_write "help"
     scp "${bitstream_path}" "root@nexus${NEXUS_ID}:/mnt/mmcp1/"
@@ -278,6 +274,7 @@
 {
     # Boot the Nexus board.  If flashed, will boot from flash
     # This command is a synomym for `opentitantool boot`
+    echo "Booting Nexus-${NEXUS_ID}"
     opentitantool boot
 }
 
@@ -295,5 +292,6 @@
         ) | fmt
         return 1
     fi
+    echo "Bootstrapping ${binary} onto Nexus-${NEXUS_ID}"
     opentitantool bootstrap "${binary}"
 }