-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlittlefs-flash-mac
executable file
·66 lines (59 loc) · 2.16 KB
/
littlefs-flash-mac
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/sh
cd "$(dirname "$0")"
echo "\x1b[32m\n1) ESP8266 \n2) ESP32\n\x1b[0m\nEnter 1 or 2"
read esp
if [ $esp = 1 ]; then
esp_path=~/Library/Arduino15/packages/esp8266/hardware/esp8266
else
esp_path=~/Library/Arduino15/packages/esp32/hardware/esp32
esp_tool_path=~/Library/Arduino15/packages/esp32/tools/esptool_py
fi
for dir in $(find $esp_path -depth 1 -type d); do
esp_version="$(basename $dir)"
break
done
for dir in $(find $esp_tool_path -depth 1 -type d); do
esp_tool_version="$(basename $dir)"
break
done
if ! [ -f $(which python) ]; then
echo "...Issue with Python, Fix?"
sudo mkdir -p -m 775 /usr/local/bin
sudo ln -s -f $(which python3) /usr/local/bin/python
fi
echo " > Over The Air (OTA)? (y/n)"
read yn
if [ $yn = y ]; then
$esp_path/$esp_version/tools/espota.py -r -i 192.168.8.8 -p 8266 -s -f build/flash-littlefs.bin
else
shopt -s nocasematch
echo "\x1b[32m\n1) USB to Serial (TTL)\n2) Native USB\n\x1b[0m\nEnter 1 or 2"
read connect
if [ $connect = 1 ]; then
hdw=$(ls /dev/cu.* && ls /dev/tty.usb*)
for serial in $hdw; do
if [[ $serial == *usb* ]] || [[ $serial == *ch34* ]] || [[ $serial == *pl23* ]] ; then
echo $serial
if [ $esp = 1 ]; then
$esp_path/$esp_version/tools/esptool/esptool.py --port $serial --baud 115200 write_flash 0x100000 build/flash-littlefs.bin
else
$esp_tool_path/$esp_tool_version/esptool --port $serial --baud 115200 write_flash 0x210000 build/flash-littlefs.bin
fi
break
fi
done
else
hdw=$(ls /dev/cu.usb*)
for usb in $hdw; do
if [[ $usb == *usb* ]]; then
echo $usb
if [ $esp = 1 ]; then
$esp_path/$esp_version/tools/esptool/esptool.py --port $usb --baud 115200 write_flash 0x100000 build/flash-littlefs.bin
else
sudo $esp_tool_path/$esp_tool_version/esptool --port $usb --baud 115200 write_flash 0x210000 build/flash-littlefs.bin
fi
break
fi
done
fi
fi