From c798ab3e78d4ca857c9aa6dc283176df1769becd Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Fri, 3 Nov 2023 10:53:34 -0600 Subject: moved ATTINY and MODEL_NUMBER into $target/arch and $target/model, and updated other scripts and files accordingly --- bin/detect-mcu.sh | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100755 bin/detect-mcu.sh (limited to 'bin/detect-mcu.sh') 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 + -- cgit v1.2.3