-
Notifications
You must be signed in to change notification settings - Fork 12
/
flash
executable file
·40 lines (34 loc) · 946 Bytes
/
flash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#! /bin/bash
[ -n "$1" ] && ESPPORT="$1"
if [ -z "$ESPPORT" ]; then
ESPPORT=()
# Find out what port is the NodeMCU by looking for CH341.
for i in /sys/class/tty/ttyUSB*/device/driver; do
DRIVER="$(basename "$(readlink $i)")"
if [ "$DRIVER" == "ch341-uart" ]; then
ESPPORT[${#ESPPORT[@]}]=$(echo $i | grep -o ttyUSB.)
fi
done
if [ "${#ESPPORT[@]}" -gt 1 ]; then
echo "Multiple CH341 ports detected, please choose one or set ESPPORT before running this script."
select i in "${ESPPORT[@]}"; do
ESPPORT="/$i"
break
done
fi
if [ -z "$ESPPORT" ]; then
echo "Failed to find any CH341 usb-serial ports."
echo "Please set ESPPORT to /dev/something or run:"
echo "$0 <port>"
exit 1
fi
ESPPORT="/dev/$ESPPORT"
fi
$ESPTOOL \
--port $ESPPORT --baud 230400 \
write_flash \
--flash_freq 40m \
--flash_mode qio \
--flash_size 32m \
0x00000 $BIN_PATH/eagle.flash.bin \
0x20000 $BIN_PATH/eagle.irom0text.bin