Skip to content

Instantly share code, notes, and snippets.

@deividaspetraitis
Forked from nicinabox/flash.sh
Created July 10, 2022 09:44
Show Gist options
  • Save deividaspetraitis/b1b4be422e00b8165c915d367682ca32 to your computer and use it in GitHub Desktop.
Save deividaspetraitis/b1b4be422e00b8165c915d367682ca32 to your computer and use it in GitHub Desktop.
Find the Pro Micro serial port automatically and flash it
#!/bin/bash
# Usage
# ./flash.sh path/to/your.hex
TARGET=$1
ls /dev/tty* > /tmp/1
echo "Reset your Pro Micro now"
while [[ -z $USB ]]; do
sleep 1
ls /dev/tty* > /tmp/2
USB=`diff /tmp/1 /tmp/2 | grep -o '/dev/tty.*'`
done
avrdude -p atmega32u4 -c avr109 -P $USB -U flash:w:$TARGET
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment