]> git.donarmstrong.com Git - kiibohd-controller.git/commitdiff
Updating load scripts with command line arguments
authorJacob Alexander <haata@kiibohd.com>
Mon, 9 Feb 2015 23:58:07 +0000 (15:58 -0800)
committerJacob Alexander <haata@kiibohd.com>
Tue, 10 Feb 2015 00:01:27 +0000 (16:01 -0800)
- Fastload option (allows for remote flashing)
- Autoscreen option initiates screen after successfully loading the firmware

LoadFile/load.dfu
LoadFile/load.teensy
LoadFile/winload.teensy

index 8eead300a2e42c7a626658598bc41952967daa27..a3769e378685e2d8f705613478e78225d5ef6dce 100755 (executable)
@@ -1,8 +1,67 @@
 #!/bin/bash
+# Convenience script for loading firmware onto a dfu type device
+# By default, initiates dfu-util
+
+SERIAL_PORT=""
+AUTO_SCREEN_SESSION=""
+PROG_NAME=$(basename $0)
+
+# Parse all the command line arguments
+while (( "$#" >= "1" )); do
+       # Scan each argument
+       key="$1"
+       case $key in
+       -a|--autoscreen)
+               AUTO_SCREEN_SESSION="$2"
+               shift
+               ;;
+       -f|--fastload)
+               SERIAL_PORT="$2"
+               shift
+               ;;
+       -h|--help)
+               echo "Usage: $PROG_NAME [options...]"
+               echo ""
+               echo "Loads the most recent built firmware (@TARGET_BIN@) to the device."
+               echo "  (load.dfu)"
+               echo ""
+               echo "Arguments:"
+               echo " -a, --autoscreen SERIAL_PORT  Use screen on the specified serial port after loading."
+               echo "                               e.g. /dev/ttyACM0"
+               echo " -f, --fastload SERIAL_PORT    Send the reload command to the debug terminal."
+               echo "                               e.g. /dev/ttyACM0"
+               echo "                               NOTE: May not work due to non-functional terminal, or disable remote flashing"
+               echo " -h, --help                    This message."
+               exit 1
+               ;;
+       *)
+               echo "INVALID ARG: '$1'"
+               exit 2
+               ;;
+       esac
+
+       # Shift to the next argument
+       shift
+done
+
+# If a SERIAL_PORT was specified set the uC into reflash mode
+# XXX May not be successful if uC is not in a good state (or does not allow remote flashing)
+if [[ "$SERIAL_PORT" != "" ]] && [[ -e "$SERIAL_PORT" ]]; then
+       echo "NOTE: This may fail if the uC is in a bad state or does not support remote flashing"
+       printf "reload\r" > $SERIAL_PORT
+       sleep 1
+fi
 
 # Load via dfu-util
 # Used for McHCK based uCs
 dfu-util -D @TARGET_BIN@
+EXIT_STATUS=$?
+
+# Load Screen Session if specified
+if (( "$EXIT_STATUS" == "0" )) && [[ "$AUTO_SCREEN_SESSION" != "" ]]; then
+       sleep 0.1
+       screen $AUTO_SCREEN_SESSION
+fi
 
-exit $?
+exit $EXIT_STATUS
 
index f2e5592ea9a20b79742e835602baff586a8bbb8a..83b48d6e785083f5821cdf837a0addde3d3d40c5 100755 (executable)
@@ -1,6 +1,50 @@
 #!/bin/bash
+# Convenience script for loading firmware onto a teensy type device
+# By default, initiates teensy-load-cli
 
-#| First check to see teensy-loader-cli has been compiled
+SERIAL_PORT=""
+AUTO_SCREEN_SESSION=""
+PROG_NAME=$(basename $0)
+
+# Parse all the command line arguments
+while (( "$#" >= "1" )); do
+       # Scan each argument
+       key="$1"
+       case $key in
+       -a|--autoscreen)
+               AUTO_SCREEN_SESSION="$2"
+               shift
+               ;;
+       -f|--fastload)
+               SERIAL_PORT="$2"
+               shift
+               ;;
+       -h|--help)
+               echo "Usage: $PROG_NAME [options...]"
+               echo ""
+               echo "Loads the most recent built firmware (@TARGET_BIN@) to the device."
+               echo "  (load.teensy)"
+               echo ""
+               echo "Arguments:"
+               echo " -a, --autoscreen SERIAL_PORT  Use screen on the specified serial port after loading."
+               echo "                               e.g. /dev/ttyACM0"
+               echo " -f, --fastload SERIAL_PORT    Send the reload command to the debug terminal."
+               echo "                               e.g. /dev/ttyACM0"
+               echo "                               NOTE: May not work due to non-functional terminal, or disable remote flashing"
+               echo " -h, --help                    This message."
+               exit 1
+               ;;
+       *)
+               echo "INVALID ARG: '$1'"
+               exit 2
+               ;;
+       esac
+
+       # Shift to the next argument
+       shift
+done
+
+# First check to see teensy-loader-cli has been compiled
 if [ ! -e teensy-loader-cli/teensy-loader-cli ]; then
        # Compile teensy-loader-cli
        mkdir -p teensy-loader-cli
@@ -10,8 +54,23 @@ if [ ! -e teensy-loader-cli/teensy-loader-cli ]; then
        cd -
 fi
 
-#| Loads the hex file onto the teensy
+# If a SERIAL_PORT was specified set the uC into reflash mode
+# XXX May not be successful if uC is not in a good state (or does not allow remote flashing)
+if [[ "$SERIAL_PORT" != "" ]] && [[ -e "$SERIAL_PORT" ]]; then
+       echo "NOTE: This may fail if the uC is in a bad state or does not support remote flashing"
+       printf "reload\r" > $SERIAL_PORT
+       sleep 1
+fi
+
+# Loads the hex file onto the teensy
 teensy-loader-cli/teensy-loader-cli -mmcu=@MCU@ -w @TARGET_HEX@
+EXIT_STATUS=$?
+
+# Load Screen Session if specified
+if (( "$EXIT_STATUS" == "0" )) && [[ "$AUTO_SCREEN_SESSION" != "" ]]; then
+       sleep 0.1
+       screen $AUTO_SCREEN_SESSION
+fi
 
-exit $?
+exit $EXIT_STATUS
 
index f22d70402e75e039a55b07fb0a15d8b4ca94e301..6d354fa82535e3906496a48f51329f9d334eebbe 100755 (executable)
@@ -1,6 +1,49 @@
 #!/bin/bash
+# Convenience script for loading firmware onto a teensy type device
+# By default, initiates teensy-load-cli
 
-#| First check to see teensy-loader-cli has been compiled
+SERIAL_PORT=""
+AUTO_SCREEN_SESSION=""
+PROG_NAME=$(basename $0)
+
+# Parse all the command line arguments
+while (( "$#" >= "1" )); do
+       # Scan each argument
+       key="$1"
+       case $key in
+       -a|--autoscreen)
+               AUTO_SCREEN_SESSION="$2"
+               shift
+               ;;
+       -f|--fastload)
+               SERIAL_PORT="$2"
+               shift
+               ;;
+       -h|--help)
+               echo "Usage: $PROG_NAME [options...]"
+               echo ""
+               echo "Loads the most recent built firmware (@TARGET_BIN@) to the device."
+               echo "Requires Cygwin."
+               echo "  (winload.teensy)"
+               echo ""
+               echo "Arguments:"
+               echo " -f, --fastload SERIAL_PORT    Send the reload command to the debug terminal."
+               echo "                               e.g. /dev/ttyACM0"
+               echo "                               NOTE: May not work due to non-functional terminal, or disable remote flashing"
+               echo " -h, --help                    This message."
+               exit 1
+               ;;
+       *)
+               echo "INVALID ARG: '$1'"
+               exit 2
+               ;;
+       esac
+
+       # Shift to the next argument
+       shift
+done
+
+# First check to see teensy-loader-cli has been compiled
 if [ ! -e teensy-loader-cli/teensy-loader-cli ]; then
        # Compile teensy-loader-cli
        mkdir -p teensy-loader-cli
@@ -10,8 +53,17 @@ if [ ! -e teensy-loader-cli/teensy-loader-cli ]; then
        cd -
 fi
 
-#| Loads the hex file onto the teensy
+# If a SERIAL_PORT was specified set the uC into reflash mode
+# XXX May not be successful if uC is not in a good state (or does not allow remote flashing)
+if [[ "$SERIAL_PORT" != "" ]] && [[ -e "$SERIAL_PORT" ]]; then
+       echo "NOTE: This may fail if the uC is in a bad state or does not support remote flashing"
+       printf "reload\r" > $SERIAL_PORT
+       sleep 1
+fi
+
+# Loads the hex file onto the teensy
 teensy-loader-cli/teensy-loader-cli -mmcu=@MCU@ -w @TARGET_HEX@
+EXIT_STATUS=$?
 
-exit $?
+exit $EXIT_STATUS