-
Notifications
You must be signed in to change notification settings - Fork 7
/
icsp_program_all.sh
executable file
·55 lines (44 loc) · 1.1 KB
/
icsp_program_all.sh
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
#!/bin/bash
#
# A command line script to program a POWER POALY 3V8 board via the ICSP connector.
# Requires an installed avrdude software and having a working programmer.
# See avrdude command line options here http://www.nongnu.org/avrdude/user-manual/avrdude.html
# Set this to the code of the programmer you have. See above link for programmer codes.
#
PROGRAMMER_CODE="avrispmkII"
# NOTE: add multiple '-v' flags to increase verbosity.
STD_ARGS="
-B 4 \
-c ${PROGRAMMER_CODE} \
-p m328p \
"
# Assert that the last command terminated with OK status
function check_last_cmd() {
status=$?
if [ "$status" -ne "0" ]; then
echo "$1 failed (status: $status)"
echo "ABORTED"
exit 1
fi
echo "$1 was ok"
}
avrdude \
${STD_ARGS} \
-u \
-U lfuse:w:0xff:m
check_last_cmd "Programming L fuses"
avrdude \
${STD_ARGS} \
-u \
-U hfuse:w:0xda:m
check_last_cmd "Programming H fuses"
avrdude \
${STD_ARGS} \
-u \
-U efuse:w:0x05:m
check_last_cmd "Programming E fuses"
avrdude \
${STD_ARGS} \
-U flash:w:pmon_3v8_flash.hex:i
check_last_cmd "Programming flash"
echo "ALL DONE OK"