diff --git a/boards/arduino-leonardo/leonardo-runner.sh b/boards/arduino-leonardo/leonardo-runner.sh index be1ca342cc..9decf7f4b3 100755 --- a/boards/arduino-leonardo/leonardo-runner.sh +++ b/boards/arduino-leonardo/leonardo-runner.sh @@ -1,6 +1,35 @@ #!/usr/bin/env sh set -e +case "$(uname -s)" in + Linux*) OS="Linux";; + Darwin*) OS="Mac";; + *) OS="Unknown";; +esac + +if ! command -v numfmt &> /dev/null +then + echo "numfmt is needed for human-readable sizes." >&2 + echo "please install https://command-not-found.com/numfmt" >&2 + alias numfmt=true +fi + +if ! command -v avrdude &> /dev/null +then + echo "required avrdude could not be found!" >&2 + echo "please install https://command-not-found.com/avrdude" >&2 + exit 1 +fi + +if [ $OS = "Linux" ]; then + SERIAL_PORT="/dev/ttyACM0" +elif [ $OS = "Mac" ]; then + SERIAL_PORT="/dev/cu.usbmodem146201" +else + echo "unsupported OS, things might not work" >&2 + SERIAL_PORT="/dev/ttyACM0" +fi + if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then echo "usage: $0 " >&2 exit 1 @@ -28,4 +57,4 @@ read -r printf "Attempting to flash ...\n" printf "\n" -avrdude -qq -C/etc/avrdude.conf -patmega32u4 -cavr109 -P/dev/ttyACM0 -b57600 -D "-Uflash:w:$1:e" +avrdude -qq -patmega32u4 -cavr109 -P"${SERIAL_PORT}" -b57600 -D "-Uflash:w:$1:e" diff --git a/boards/arduino-uno/uno-runner.sh b/boards/arduino-uno/uno-runner.sh index db3f6942b7..b76daf5053 100755 --- a/boards/arduino-uno/uno-runner.sh +++ b/boards/arduino-uno/uno-runner.sh @@ -1,6 +1,35 @@ #!/usr/bin/env sh set -e +case "$(uname -s)" in + Linux*) OS="Linux";; + Darwin*) OS="Mac";; + *) OS="Unknown";; +esac + +if ! command -v numfmt &> /dev/null +then + echo "numfmt is needed for human-readable sizes." >&2 + echo "please install https://command-not-found.com/numfmt" >&2 + alias numfmt=true +fi + +if ! command -v avrdude &> /dev/null +then + echo "required avrdude could not be found!" >&2 + echo "please install https://command-not-found.com/avrdude" >&2 + exit 1 +fi + +if [ $OS = "Linux" ]; then + SERIAL_PORT="/dev/ttyACM0" +elif [ $OS = "Mac" ]; then + SERIAL_PORT="/dev/cu.usbmodem146201" +else + echo "unsupported OS, things might not work" >&2 + SERIAL_PORT="/dev/ttyACM0" +fi + if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then echo "usage: $0 " >&2 exit 1 @@ -26,4 +55,4 @@ printf "\n" printf "Attempting to flash ...\n" printf "\n" -avrdude -q -C/etc/avrdude.conf -patmega328p -carduino -P/dev/ttyACM0 -D "-Uflash:w:$1:e" +avrdude -q -patmega328p -carduino -P"${SERIAL_PORT}" -D "-Uflash:w:$1:e" diff --git a/boards/sparkfun-pro-micro/pro-micro-runner.sh b/boards/sparkfun-pro-micro/pro-micro-runner.sh index be1ca342cc..5383e5f68b 100755 --- a/boards/sparkfun-pro-micro/pro-micro-runner.sh +++ b/boards/sparkfun-pro-micro/pro-micro-runner.sh @@ -1,6 +1,35 @@ #!/usr/bin/env sh set -e +case "$(uname -s)" in + Linux*) OS="Linux";; + Darwin*) OS="Mac";; + *) OS="Unknown";; +esac + +if ! command -v numfmt &> /dev/null +then + echo "numfmt is needed for human-readable sizes." >&2 + echo "please install https://command-not-found.com/numfmt" >&2 + alias numfmt=true +fi + +if ! command -v avrdude &> /dev/null +then + echo "required avrdude could not be found!" >&2 + echo "please install https://command-not-found.com/avrdude" >&2 + exit 1 +fi + +if [ $OS = "Linux" ]; then + SERIAL_PORT="/dev/ttyACM0" +elif [ $OS = "Mac" ]; then + SERIAL_PORT="/dev/cu.usbmodem146201" +else + echo "unsupported OS, things might not work" >&2 + SERIAL_PORT="/dev/ttyACM0" +fi + if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then echo "usage: $0 " >&2 exit 1 @@ -28,4 +57,4 @@ read -r printf "Attempting to flash ...\n" printf "\n" -avrdude -qq -C/etc/avrdude.conf -patmega32u4 -cavr109 -P/dev/ttyACM0 -b57600 -D "-Uflash:w:$1:e" +avrdude -qq -patmega32u4 -cavr109 -P"${SERIAL_PORT}" -b57600 -D "-Uflash:w:$1:e"