File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change
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
You can’t perform that action at this time.
0 commit comments