Skip to content

Instantly share code, notes, and snippets.

@orumin
Forked from nyomo/avrdude.sh
Last active April 4, 2021 08:53
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 orumin/26e4840fd8aa23cbaac9fdf11e3df01f to your computer and use it in GitHub Desktop.
Save orumin/26e4840fd8aa23cbaac9fdf11e3df01f to your computer and use it in GitHub Desktop.
WSLでavrdudeを簡単に使う為の奴
#!/bin/bash
if [ $# != 1 ]; then
echo "usage: $0 <target firmware>.hex"
exit 0
fi
read -p "target file is $1. correct? [Yn] " yn
case "$yn" in
"" | [yY]*);;
*) echo "abort";exit 0;;
esac
TOOLBOXDIR='/home/orumin/qmk_toolbox/' # change this variable for your environment
MODECMD='/mnt/c/Windows/System32/mode.com'
GET_COMPORT='/mnt/c/Windows/System32/reg.exe query HKLM\HARDWARE\DEVICEMAP\SERIALCOMM'
CONNECTED_COMPORT=$(${MODECMD}|grep -oE 'COM[0-9]+'| tr '\n' '|' | sed -e 's/|$//g')
echo "connected port: $CONNECTED_COMPORT"
TARGET_COMPORT=""
while [ "$TARGET_COMPORT" = "" ];do
sleep 0.5
printf "."
if [ -z "$CONNECTED_COMPORT" ]; then
TARGET_COMPORT=$(${GET_COMPORT}|grep -oE 'COM[0-9]+')
else
TARGET_COMPORT=$(${GET_COMPORT}|grep -vE $CONNECTED_COMPORT|grep -oE 'COM[0-9]+')
fi
done
echo ""
echo $TARGET_COMPORT
${TOOLBOXDIR}windows/QMK\ Toolbox/avrdude.exe -C ${TOOLBOXDIR}common/avrdude.conf -c avr109 -p m32u4 -P ${TARGET_COMPORT} -U flash:w:$1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment