Skip to content

Commit

Permalink
runners: Add support for MacOS
Browse files Browse the repository at this point in the history
  • Loading branch information
explicite committed Oct 13, 2020
1 parent bad9277 commit 7337cd7
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 3 deletions.
31 changes: 30 additions & 1 deletion boards/arduino-leonardo/leonardo-runner.sh
Original file line number Diff line number Diff line change
@@ -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 <application.elf>" >&2
exit 1
Expand Down Expand Up @@ -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"
31 changes: 30 additions & 1 deletion boards/arduino-uno/uno-runner.sh
Original file line number Diff line number Diff line change
@@ -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 <application.elf>" >&2
exit 1
Expand All @@ -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"
31 changes: 30 additions & 1 deletion boards/sparkfun-pro-micro/pro-micro-runner.sh
Original file line number Diff line number Diff line change
@@ -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 <application.elf>" >&2
exit 1
Expand Down Expand Up @@ -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"

0 comments on commit 7337cd7

Please sign in to comment.