#!/bin/bash # SPDX-License-Identifier: Apache-2.0 # Copyright (c) 2012-2024 Scott Penrose and WII5 Buoy contributors # # This file is part of WII5 Buoy firmware. # See LICENSE for full terms. # Build and flash the WII5 Buoy firmware locally. Configure via env vars: : "${WII5_SERIAL:?set to your serial port, e.g. /dev/ttyUSB0}" : "${WII5_FULL_HEX:?path to the built .hex file, e.g. \$BUILD_DIR/wii5_buoy.ino.hex}" : "${WII5_AVRDUDE_CONF:?path to avrdude.conf}" : "${WII5_ARDUINO_BIN:=arduino}" : "${WII5_AVRDUDE_BIN:=avrdude}" set -e VERSION="dev" SHORT=$(git log -1 --pretty=format:%h) VERSION_STRING="WII5Buoy_$SHORT" # TODO: Inject VERSION via build_local.sh argument or VERSION header file "$WII5_ARDUINO_BIN" \ --pref compiler.cpp.extra_flags="-DWII5_SOFTWARE_VERSION=\"$VERSION_STRING\" -DWII5_SOFTWARE_COMMIT=\"$SHORT\" " \ --verify app/wii5_buoy/wii5_buoy.ino \ --board WII:avr:wii5_v2_2560_3V:cpu=atmega25603V3_11MHz230400 sleep 1 "$WII5_AVRDUDE_BIN" \ -C"$WII5_AVRDUDE_CONF" -v \ -patmega2560 \ -carduino \ -P"$WII5_SERIAL" -b230400 \ -D \ -Uflash:w:"$WII5_FULL_HEX":i