Kiibohd Controller
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

load.dfu 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/bin/bash
  2. # Convenience script for loading firmware onto a dfu type device
  3. # By default, initiates dfu-util
  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 " (load.dfu)"
  25. echo ""
  26. echo "Arguments:"
  27. echo " -a, --autoscreen SERIAL_PORT Use screen on the specified serial port after loading."
  28. echo " e.g. /dev/ttyACM0"
  29. echo " -f, --fastload SERIAL_PORT Send the reload command to the debug terminal."
  30. echo " e.g. /dev/ttyACM0"
  31. echo " NOTE: May not work due to non-functional terminal, or disable remote flashing"
  32. echo " -h, --help This message."
  33. exit 1
  34. ;;
  35. *)
  36. echo "INVALID ARG: '$1'"
  37. exit 2
  38. ;;
  39. esac
  40. # Shift to the next argument
  41. shift
  42. done
  43. # If a SERIAL_PORT was specified set the uC into reflash mode
  44. # XXX May not be successful if uC is not in a good state (or does not allow remote flashing)
  45. if [[ "$SERIAL_PORT" != "" ]] && [[ -e "$SERIAL_PORT" ]]; then
  46. echo "NOTE: This may fail if the uC is in a bad state or does not support remote flashing"
  47. printf "reload\r" > $SERIAL_PORT
  48. sleep 1
  49. fi
  50. # Load via dfu-util
  51. # Used for McHCK based uCs
  52. dfu-util -D @TARGET_BIN@
  53. EXIT_STATUS=$?
  54. # Load Screen Session if specified
  55. if (( "$EXIT_STATUS" == "0" )) && [[ "$AUTO_SCREEN_SESSION" != "" ]]; then
  56. sleep 0.1
  57. screen $AUTO_SCREEN_SESSION
  58. fi
  59. exit $EXIT_STATUS