-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-and-flash
executable file
·35 lines (29 loc) · 990 Bytes
/
build-and-flash
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
#!/bin/bash
set -e
# -- Config --
board_variant="3_3V" # "3_3V" or "5V"
programmer="-p /dev/ttyUSB0" # alt. "-P usbasp"
app_name=gardensensor
libraries="./libraries/KnxTpUart"
# -- Run --
if [ "${board_variant}" = "3_3V" ]; then
# Arduino pro mini 3,3V 8MHz
board_name="arduino:avr:pro:cpu=8MHzatmega328"
elif [ "${board_variant}" = "5V" ]; then
# Arduino pro mini 5V 16MHz
board_name="arduino:avr:pro:cpu=16MHzatmega328"
else
echo "Error: Unknown board variant selected: ${board_variant}"
exit 1
fi
echo "== Compiling application ${app_name} for board ${board_name} / variant ${board_variant}..."
arduino-cli compile -v \
--libraries ${libraries} \
--fqbn ${board_name} \
--build-property build.extra_flags=-DBOARD_VOLTAGE=VOLTAGE_${board_variant} \
${app_name}
echo "== Compilation done."
echo
echo "== Flashing binary to board ${board_name}..."
arduino-cli upload -v ${programmer} --fqbn ${board_name} ${app_name}
echo "== Flashing done."