-
Notifications
You must be signed in to change notification settings - Fork 3
/
upload.command
executable file
·73 lines (54 loc) · 1.29 KB
/
upload.command
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
cd ${0%/*}
PROGRAMMER=$(head -n 1 programmer)
listOutput=$(ls *.hex)
count=0
for j in $listOutput
do
count=$(( count + 1 ))
file[count]=$j
done
if [ "$count" = 0 ] ; then
echo "No relevant HEX files"
echo
exit
fi
if [ "$count" = 1 ] ; then
input=1
echo "One relevant HEX file so selecting it automatically : ${file[$input]}"
echo
else
echo "The following is a list of the available HEX files:"
echo
i=0
for j in $listOutput
do
i=$(( i + 1 ))
echo "$i. $j"
done
echo
echo "Choose a file number"
echo
read input
fi
echo "Flashing: ${file[$input]}"
echo
echo "##############################################################################"
echo
if [[ "$OSTYPE" == "linux-gnu" ]]; then
BINARY="avrdude"
CONF="/etc/avrdude.conf"
elif [[ "$OSTYPE" == "darwin"* ]]; then
BINARY="./avrdude.mac"
CONF="./avrdude.conf.mac"
else
echo "Operating system not supported"
fi
"$BINARY" -C"$CONF" -pm328p -carduino -P"$PROGRAMMER" -Uflash:w:"${file[$input]}":a
while read -s -n1 -p "Hit ENTER to run command again or ESC to restart" result; do
if [ "$result" = "$(echo -e '\033')" ]; then
ScriptLoc=$(readlink -f "$0")
exec "$ScriptLoc"
fi
"$BINARY" -C"$CONF" -pm328p -carduino -P"$PROGRAMMER" -Uflash:w:"${file[$input]}":a
done