Skip to content

Instantly share code, notes, and snippets.

Created October 16, 2019 03:41
What would you like to do?
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
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 ".";
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