From 787f08444947a4586eb58e9378e5e611bd5f9c1e Mon Sep 17 00:00:00 2001 From: Token Date: Sat, 7 Sep 2024 02:54:12 +0200 Subject: [PATCH] feat: add autoflash script for automatic device flashing Introduce `autoflash.sh` to continuously monitor a specified device port, automatically flash firmware upon device detection, and log results. This enhances the flashing process by making it more efficient and less manual. Yay for two days of continuous preparing and flashing! :D --- autoflash.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 autoflash.sh diff --git a/autoflash.sh b/autoflash.sh new file mode 100755 index 0000000..2976d86 --- /dev/null +++ b/autoflash.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +# Example usage: ./autoflash.sh /dev/ttyACM0 autoflash_ACM0.log + +PORT=${1:-/dev/ttyACM0} +OUTFILE=${2:-autoflash_ACM0.log} + +while true; do + echo "" + echo "# Waiting for new device on ${PORT}…" + while [ ! -e "${PORT}" ]; do + sleep 0.5 + done + echo "# Found new device!" + sleep 1 + + echo "" | tee -a ${OUTFILE} + echo -n "========== " | tee -a ${OUTFILE} + echo -n $(date -Iseconds) | tee -a ${OUTFILE} + echo -n " ${PORT}" | tee -a ${OUTFILE} + echo " ==========" | tee -a ${OUTFILE} + + pio run --upload-port ${PORT} --target upload 2>&1 | tee -a ${OUTFILE} + + sleep 1 + echo "# Waiting for device disconnect…" + while [ -e "${PORT}" ]; do + sleep 0.5 + done +done