Skip to content

Instantly share code, notes, and snippets.

@adeonhy
Created October 16, 2019 03:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adeonhy/ca2dc2713de07e936c2e72ee8e473e4b to your computer and use it in GitHub Desktop.
Save adeonhy/ca2dc2713de07e936c2e72ee8e473e4b to your computer and use it in GitHub Desktop.
#!/bin/sh
printf "Detecting USB port, reset your controller now."
ls /dev/tty* > /tmp/1
while [ -z $USB ]; do
sleep 0.5
printf "."
ls /dev/tty* > /tmp/2
USB=`comm -13 /tmp/1 /tmp/2 | grep -o '/dev/tty.*'`
mv /tmp/2 /tmp/1
done
echo ""
echo "Device $USB has appeared; assuming it is the controller."
printf "Waiting for $USB to become writable."
while [ ! -w "$USB" ]; do
sleep 0.5; printf ".";
done;
echo ""
avrdude -p atmega32u4 -c avr109 -P $USB -U flash:w:$1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment