Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/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