Kiibohd Controller
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

winload.teensy 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #!/usr/bin/env bash
  2. # Convenience script for loading firmware onto a teensy type device
  3. # By default, initiates teensy-load-cli
  4. SERIAL_PORT=""
  5. AUTO_SCREEN_SESSION=""
  6. PROG_NAME=$(basename $0)
  7. # Parse all the command line arguments
  8. while (( "$#" >= "1" )); do
  9. # Scan each argument
  10. key="$1"
  11. case $key in
  12. -a|--autoscreen)
  13. AUTO_SCREEN_SESSION="$2"
  14. shift
  15. ;;
  16. -f|--fastload)
  17. SERIAL_PORT="$2"
  18. shift
  19. ;;
  20. -h|--help)
  21. echo "Usage: $PROG_NAME [options...]"
  22. echo ""
  23. echo "Loads the most recent built firmware (@TARGET_BIN@) to the device."
  24. echo "Requires Cygwin."
  25. echo " (winload.teensy)"
  26. echo ""
  27. echo "Arguments:"
  28. echo " -f, --fastload SERIAL_PORT Send the reload command to the debug terminal."
  29. echo " e.g. /dev/ttyACM0"
  30. echo " NOTE: May not work due to non-functional terminal, or disable remote flashing"
  31. echo " -h, --help This message."
  32. exit 1
  33. ;;
  34. *)
  35. echo "INVALID ARG: '$1'"
  36. exit 2
  37. ;;
  38. esac
  39. # Shift to the next argument
  40. shift
  41. done
  42. # First check to see teensy-loader-cli has been compiled
  43. if [ ! -e teensy-loader-cli/teensy-loader-cli ]; then
  44. # Compile teensy-loader-cli
  45. mkdir -p teensy-loader-cli
  46. cd teensy-loader-cli
  47. cmake -G "Unix Makefiles" $(cygpath -u @CMAKE_SOURCE_DIR@/LoadFile)
  48. make || exit 3
  49. cd -
  50. fi
  51. # If a SERIAL_PORT was specified set the uC into reflash mode
  52. # XXX May not be successful if uC is not in a good state (or does not allow remote flashing)
  53. if [[ "$SERIAL_PORT" != "" ]] && [[ -e "$SERIAL_PORT" ]]; then
  54. echo "NOTE: This may fail if the uC is in a bad state or does not support remote flashing"
  55. printf "reload\r" > $SERIAL_PORT
  56. sleep 1
  57. fi
  58. # Loads the hex file onto the teensy
  59. teensy-loader-cli/teensy-loader-cli -mmcu=@MCU@ -w @TARGET_HEX@
  60. EXIT_STATUS=$?
  61. exit $EXIT_STATUS