aboutsummaryrefslogtreecommitdiff
path: root/bin/flash-avr32dd20.sh
diff options
context:
space:
mode:
authorSelene ToyKeeper2023-11-30 09:19:45 -0700
committerSelene ToyKeeper2023-11-30 09:19:45 -0700
commitf745e12c3bc48d8fe544893871191086cf3cccc9 (patch)
tree0e7f6c2c5f362719ac4efad9d5c2365f3ed3c159 /bin/flash-avr32dd20.sh
parentadded md5sum to build-all.sh output per target (diff)
parenteliminated direct CCP register access from arch/attiny1616 (diff)
downloadanduril-f745e12c3bc48d8fe544893871191086cf3cccc9.tar.gz
anduril-f745e12c3bc48d8fe544893871191086cf3cccc9.tar.bz2
anduril-f745e12c3bc48d8fe544893871191086cf3cccc9.zip
Merge branch 'avr32dd20-devkit' into trunk
Added support for AVR DD MCUs, particularly avr32dd20. Also did a bunch of refactoring for how MCU support works, cleaned up the ADC code, switched to consistent internal formats for voltage and temperature, fixed the FW3X, and some other little things. * avr32dd20-devkit: (28 commits) eliminated direct CCP register access from arch/attiny1616 made the avr32dd20 flashing script more universal added a build target for FW3X with manually-fixed RGB aux wiring prevent future issues like the FW3X had fixed FW3X thermal regulation fixed incorrect temperature history for a few seconds after waking fsm/adc: removed dead code FW3X: fixed external temperature sensor FW3X: multiple upgrades... fw3x: fixed swapped red+blue, fixed battery measurements, added police color strobe fixed ADC on sp10-pro fixed ADC on attiny85 and related builds fixed ADC on attiny1634 and related builds more ADC / DAC / MCU progress... avr32dd20-devkit: make the defaults a bit more dev friendly (realtime voltage colors, and no simple UI by default) ADC voltage: battcheck 3 digits, fixed t1616, switched back to 8-bit internal volt unit got ADC voltage+temp working on avrdd... but broke all other builds/MCUs 1.55V AA battery should not show as "white" voltage color, only purple started refactoring fsm/adc.*, but need a checkpoint before continuing added dac-scale.py: short script to calculate avrdd DAC+Vref values from level_calc.py ramp data ...
Diffstat (limited to 'bin/flash-avr32dd20.sh')
-rwxr-xr-xbin/flash-avr32dd20.sh40
1 files changed, 40 insertions, 0 deletions
diff --git a/bin/flash-avr32dd20.sh b/bin/flash-avr32dd20.sh
new file mode 100755
index 0000000..dcd4967
--- /dev/null
+++ b/bin/flash-avr32dd20.sh
@@ -0,0 +1,40 @@
+#!/usr/bin/env bash
+# AVR firmware flashing script, a wrapper for other tools
+# Copyright (C) 2023 Selene ToyKeeper
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+# Usage: flash-MCUTYPE.sh hex/foo.hex
+# (where the script name specifies the type of MCU chip,
+# and the first parameter is the path to a .hex file)
+# Example:
+# ./bin/flash-avr32dd20.sh hex/anduril.thefreeman-avr32dd20-devkit.hex
+
+set -e
+
+# Get the path to a .hex file
+[[ -z "$1" ]] && echo "No .hex file specified." && exit 1
+HEX="$1"
+
+# assume the highest-numbered USB serial device is the correct one,
+# since it was probably the most recently plugged in
+TTYUSB=$(ls -1 /dev/tty* | grep -i usb | tail -1)
+
+# figure out the MCU type...
+# TODO: find the relevant hw/*/arch file and use that to get MCU type
+# use $2 if it exists, and use the name of this script maybe
+MCUTYPE="unset"
+[[ -n "$2" ]] && MCUTYPE="$2"
+#MCUTYPE=$(echo "$0" | sed 's/.*flash-\(.*\).sh.*/\1/')
+[[ "$0" =~ flash-(.*).sh ]] && MCUTYPE="${BASH_REMATCH[1]}"
+
+# Do the actual flashing
+echo "Flashing $MCUTYPE MCU on port $TTYUSB: $HEX"
+echo pymcuprog write \
+ --erase \
+ --verify \
+ --timing \
+ -t uart \
+ -u "$TTYUSB" \
+ -d "$MCUTYPE" \
+ -f "$HEX"
+