-
Notifications
You must be signed in to change notification settings - Fork 323
/
flash
executable file
·38 lines (30 loc) · 897 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
#!/bin/bash
function usage() {
echo
echo "usage: $0 <version> <port>"
echo
echo ' version should be formatted <major>-<minor>-<patch>'
echo
echo 'Execute from the root dir of the repo.'
echo " ex: '$0 3-0-1 /dev/cu.SLAB_USBtoUART '"
exit 1
}
if [ "$#" == 0 ]; then
usage
fi
VERSION="$1"
PORT=${2:-/dev/cu.wchusbserial1410}
BUILD_PATH=build
if [ ! -d "${BUILD_PATH}" ] ; then
echo "No matching build version - trying releases"
BUILD_PATH="firmware/releases/${VERSION}"
fi
IMAGE_NAME="${BUILD_PATH}/konnected-esp8266-${VERSION}.bin"
# Make sure the files exist as expected before flashing
if ! [ -f ${IMAGE_NAME} ] ; then
echo "Image not found...expected at '${IMAGE_NAME}'"
usage
fi
esptool.py "--port=${PORT}" write_flash --flash_mode dio --flash_size detect 0x0 "${IMAGE_NAME}"
tput bel
echo "Completed flashing of ${BUILD_PATH}"