diff options
| author | Selene ToyKeeper | 2023-11-03 10:53:34 -0600 |
|---|---|---|
| committer | Selene ToyKeeper | 2023-11-03 10:53:34 -0600 |
| commit | c798ab3e78d4ca857c9aa6dc283176df1769becd (patch) | |
| tree | a880468721171db1ace5b8e968fe29480b694466 /bin/detect-mcu.sh | |
| parent | moved variant builds under their parent, like "d4-219" -> "d4/219" (diff) | |
| download | anduril-c798ab3e78d4ca857c9aa6dc283176df1769becd.tar.gz anduril-c798ab3e78d4ca857c9aa6dc283176df1769becd.tar.bz2 anduril-c798ab3e78d4ca857c9aa6dc283176df1769becd.zip | |
moved ATTINY and MODEL_NUMBER into $target/arch and $target/model,
and updated other scripts and files accordingly
Diffstat (limited to '')
| -rwxr-xr-x | bin/detect-mcu.sh | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/bin/detect-mcu.sh b/bin/detect-mcu.sh new file mode 100755 index 0000000..fa3a926 --- /dev/null +++ b/bin/detect-mcu.sh @@ -0,0 +1,41 @@ +#!/bin/sh +# Anduril / FSM MCU type detection script +# Copyright (C) 2014-2023 Selene ToyKeeper +# SPDX-License-Identifier: GPL-3.0-or-later + +if [ -z "$1" ]; then + echo "Usage: detect-mcu.sh FILE" + echo "or: eval $(detect-mcu.sh FILE)" + echo "Example: detect-mcu.sh hw/hank/emisar-d4/anduril.h" + echo "Figures out which MCU a build uses, and sets env vars for it" + exit +fi + +TARGET=$1 +while [ -n "$TARGET" ]; do + #echo "... $TARGET" + if [ -f "$TARGET" ]; then # use the dir/$UI.h file + ATTINY=$(grep 'ATTINY:' $TARGET | awk '{ print $3 }') + if [ -n "$ATTINY" ]; then + echo "export MCUNAME=attiny${ATTINY}" + echo "export MCU=0x${ATTINY}" + echo "export ATTINY=${ATTINY}" + echo "export MCUFLAGS=\"-DMCUNAME=attiny${ATTINY} -DMCU=0x${ATTINY} -DATTINY=${ATTINY}\"" + exit + fi + else # use the dir/arch file + if [ -f "${TARGET}/arch" ]; then + MCU=$(head -1 "${TARGET}/arch") + if [ -n "$MCU" ]; then + NUM=$( echo "$MCU" | sed 's/^avr//; s/^attiny//;' ) + echo "export MCUNAME=${MCU}" + echo "export MCU=0x${NUM}" + echo "export ATTINY=${NUM}" + echo "export MCUFLAGS=\"-DMCUNAME=${MCU} -DMCU=0x${NUM} -DATTINY=${NUM}\"" + exit + fi + fi + fi + TARGET=$(dirname $TARGET) +done + |
