diff options
Diffstat (limited to 'bin/build.sh')
| -rwxr-xr-x | bin/build.sh | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/bin/build.sh b/bin/build.sh index 41abfc7..8743260 100755 --- a/bin/build.sh +++ b/bin/build.sh @@ -1,4 +1,7 @@ #!/bin/bash +# Anduril / FSM build script +# Copyright (C) 2014-2023 Selene ToyKeeper +# SPDX-License-Identifier: GPL-3.0-or-later # Instead of using a Makefile, since most of the firmwares here build in the # same exact way, here's a script to do the same thing @@ -12,12 +15,16 @@ fi TARGET=$1 ; shift UI=$(basename $TARGET .h) +MODEL=$(dirname $TARGET) +PROGRAM="ui/$UI/$UI" -ATTINY=$(grep 'ATTINY:' $TARGET | awk '{ print $3 }') -if [ -z "$ATTINY" ]; then ATTINY=85 ; fi +# figure out the model number +MODEL_NUMBER=$(head -1 $MODEL/model) -PROGRAM="ui/$UI/$UI" +# figure out the MCU type and set some vars +eval $( bin/detect-mcu.sh "$TARGET" ) +# TODO: add support for AVR DD # give a more useful error message when AVR DFP is needed but not installed # (Atmel ATtiny device family pack, for attiny1616 support) # http://packs.download.atmel.com/ @@ -31,21 +38,20 @@ if [[ $SERIES1 =~ " $ATTINY " ]]; then fi fi -export MCU=attiny$ATTINY export CC=avr-gcc export CPP=avr-cpp export OBJCOPY=avr-objcopy -export DFPFLAGS="-B $ATTINY_DFP/gcc/dev/$MCU/ -I $ATTINY_DFP/include/" +export DFPFLAGS="-B $ATTINY_DFP/gcc/dev/$MCUNAME/ -I $ATTINY_DFP/include/" # TODO: include $user/ first so it can override other stuff INCLUDES="-I ui -I hw -I. -I.. -I../.. -I../../.." -export CFLAGS=" -Wall -g -Os -mmcu=$MCU -c -std=gnu99 -fgnu89-inline -fwhole-program -DATTINY=$ATTINY $INCLUDES -fshort-enums $DFPFLAGS" -export CPPFLAGS="-Wall -g -Os -mmcu=$MCU -C -std=gnu99 -fgnu89-inline -fwhole-program -DATTINY=$ATTINY $INCLUDES -fshort-enums $DFPFLAGS" -export OFLAGS="-Wall -g -Os -mmcu=$MCU -mrelax $DFPFLAGS" +export CFLAGS=" -Wall -g -Os -mmcu=$MCUNAME -c -std=gnu99 -fgnu89-inline -fwhole-program $MCUFLAGS $INCLUDES -fshort-enums $DFPFLAGS" +export CPPFLAGS="-Wall -g -Os -mmcu=$MCUNAME -C -std=gnu99 -fgnu89-inline -fwhole-program $MCUFLAGS $INCLUDES -fshort-enums $DFPFLAGS" +export OFLAGS="-Wall -g -Os -mmcu=$MCUNAME -mrelax $DFPFLAGS" export LDFLAGS="-fgnu89-inline" export OBJCOPYFLAGS='--set-section-flags=.eeprom=alloc,load --change-section-lma .eeprom=0 --no-change-warnings -O ihex --remove-section .fuse' export OBJS=$PROGRAM.o -OTHERFLAGS="-DCFG_H=$TARGET" +OTHERFLAGS="-DCFG_H=$TARGET -DMODEL_NUMBER=\"$MODEL_NUMBER\"" for arg in "$*" ; do OTHERFLAGS="$OTHERFLAGS $arg" done @@ -63,5 +69,5 @@ run $CC $OTHERFLAGS $CFLAGS -o $PROGRAM.o -c $PROGRAM.c run $CC $OFLAGS $LDFLAGS -o $PROGRAM.elf $PROGRAM.o run $OBJCOPY $OBJCOPYFLAGS $PROGRAM.elf $PROGRAM.hex # deprecated -#run avr-size -C --mcu=$MCU $PROGRAM.elf | grep Full +#run avr-size -C --mcu=$MCUNAME $PROGRAM.elf | grep Full run avr-objdump -Pmem-usage $PROGRAM.elf | grep -E 'Full|Device' | sed 's/^/ /;' |
