Skip to content

Instantly share code, notes, and snippets.

@xeaone
Forked from nooges/avrdude-flash.sh
Created September 5, 2018 05:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xeaone/8ea4e41e946148715df529e78b1e1d99 to your computer and use it in GitHub Desktop.
Save xeaone/8ea4e41e946148715df529e78b1e1d99 to your computer and use it in GitHub Desktop.
Script for flashing .hex file onto Pro Micro with avrdude
#!/usr/bin/env bash
MCU=atmega32u4
if grep -q -s Microsoft /proc/version; then
echo 'ERROR: Pro Micros can not be flashed within the Windows Subsystem for Linux (WSL) currently. Instead, take the .hex file generated and flash it using AVRDUDE, AVRDUDESS, or XLoader.'
exit 1
fi
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <path to .hex file>"
exit 1
fi
ls /dev/tty* > /tmp/1
echo -n "Detecting Pro Micro port, reset your Pro Micro now."
while [ -z $USB ]; do
sleep 1
echo -n "."
ls /dev/tty* > /tmp/2
USB=`diff /tmp/1 /tmp/2 | grep -o '/dev/tty.*'`
done;
echo ""
echo "Detected Pro Micro port at $USB"
sleep 0.5
avrdude -p $MCU -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