-
Notifications
You must be signed in to change notification settings - Fork 1
/
erase_flash.sh
executable file
·41 lines (33 loc) · 861 Bytes
/
erase_flash.sh
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
#!/bin/bash
function msg() {
echo -e "[\e[0;92m*\e[0m]" "$@"
}
if [ "$1" == "" ] || [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
echo "Usage: $0 /dev/ttySERIAL_PORT"
exit 1
fi
tty="$1"
build_venv="build-venv"
if ! [ "$2" == "" ]; then
build_venv="$2"
fi
if [ ! -e "$tty" ]; then
echo "Serial port does not exist"
exit 1
fi
if [ ! -e "$build_venv/bin/python" ]; then
echo "Build virtual environment does not exist or is broken. Run ./build_image.sh first to set it up."
exit 1
fi
source $build_venv/bin/activate
echo "Ready to erase: do the following"
echo
echo "- Hold down the BOOT button"
echo "- Press and release the RESET button"
echo "- Release the BOOT button"
echo
read -p "Press Enter when you are ready or Ctrl+C to cancel."
msg "erase flash"
esptool.py --chip esp32 --port "$tty" erase_flash
echo
echo "Now reset the board."