2 # Convenience script for loading firmware onto a teensy type device
3 # By default, initiates teensy-load-cli
7 PROG_NAME=$(basename $0)
9 # Parse all the command line arguments
10 while (( "$#" >= "1" )); do
15 AUTO_SCREEN_SESSION="$2"
23 echo "Usage: $PROG_NAME [options...]"
25 echo "Loads the most recent built firmware (@TARGET_BIN@) to the device."
26 echo "Requires Cygwin."
27 echo " (winload.teensy)"
30 echo " -f, --fastload SERIAL_PORT Send the reload command to the debug terminal."
31 echo " e.g. /dev/ttyACM0"
32 echo " NOTE: May not work due to non-functional terminal, or disable remote flashing"
33 echo " -h, --help This message."
37 echo "INVALID ARG: '$1'"
42 # Shift to the next argument
46 # First check to see teensy-loader-cli has been compiled
47 if [ ! -e teensy-loader-cli/teensy-loader-cli ]; then
48 # Compile teensy-loader-cli
49 mkdir -p teensy-loader-cli
51 cmake -G "Unix Makefiles" $(cygpath -u @CMAKE_SOURCE_DIR@/LoadFile)
56 # If a SERIAL_PORT was specified set the uC into reflash mode
57 # XXX May not be successful if uC is not in a good state (or does not allow remote flashing)
58 if [[ "$SERIAL_PORT" != "" ]] && [[ -e "$SERIAL_PORT" ]]; then
59 echo "NOTE: This may fail if the uC is in a bad state or does not support remote flashing"
60 printf "reload\r" > $SERIAL_PORT
64 # Loads the hex file onto the teensy
65 teensy-loader-cli/teensy-loader-cli -mmcu=@MCU@ -w @TARGET_HEX@