Skip to content

Commit 389a98b

Browse files
committed
Batch upload script
1 parent c69f69f commit 389a98b

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
3+
FIRMWARE_PATH="../../docs/firmware/openspool-esp32s3.factory.bin"
4+
DEVICE_PREFIX="/dev/cu.usbmodem"
5+
6+
RED='\033[0;31m'
7+
GREEN='\033[0;32m'
8+
NC='\033[0m' # No Color
9+
10+
print_red() {
11+
echo -e "${RED}$1${NC}"
12+
}
13+
14+
print_green() {
15+
echo -e "${GREEN}$1${NC}"
16+
}
17+
18+
flash_device() {
19+
local device=$1
20+
echo "Flashing device: $device"
21+
esptool.py --chip esp32-s3 -p "$device" --baud 921600 --before default_reset --after hard_reset write_flash 0x0 "$FIRMWARE_PATH"
22+
if [ $? -eq 0 ]; then
23+
print_green "Flashing successful: $device"
24+
else
25+
print_red "Flashing failed: $device"
26+
fi
27+
}
28+
29+
watch_for_devices() {
30+
local old_devices=""
31+
while true; do
32+
local new_devices=$(ls ${DEVICE_PREFIX}* 2>/dev/null)
33+
for device in $new_devices; do
34+
if [[ ! $old_devices =~ $device ]]; then
35+
echo "New device detected: $device"
36+
flash_device "$device"
37+
fi
38+
done
39+
old_devices="$new_devices"
40+
sleep 1
41+
done
42+
}
43+
44+
echo "Starting ESP32-S3 flashing script"
45+
echo "Firmware path: $FIRMWARE_PATH"
46+
echo "Watching for devices with prefix: $DEVICE_PREFIX"
47+
watch_for_devices

0 commit comments

Comments
 (0)