Skip to content

Commit

Permalink
feat: add autoflash script for automatic device flashing
Browse files Browse the repository at this point in the history
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
  • Loading branch information
TokenRat committed Sep 7, 2024
1 parent 5b54bcd commit 787f084
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions autoflash.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 787f084

Please sign in to comment.