-
-
Save orumin/26e4840fd8aa23cbaac9fdf11e3df01f to your computer and use it in GitHub Desktop.
WSLでavrdudeを簡単に使う為の奴
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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