From c7a8f83c21ab123031bf6e2102e915fd570f85f5 Mon Sep 17 00:00:00 2001 From: Kalle <15094562+ThatKalle@users.noreply.github.com> Date: Tue, 6 May 2025 22:28:20 +0200 Subject: [PATCH] add change-mode support --- bin/device-install.sh | 1 + bin/device-update.sh | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/bin/device-install.sh b/bin/device-install.sh index b104e7a8a..8de61b01a 100755 --- a/bin/device-install.sh +++ b/bin/device-install.sh @@ -114,6 +114,7 @@ done if [[ $WEB_APP == true ]]; then $ESPTOOL_CMD --baud 1200 --after no_reset read_flash_status + exit 0 fi [ -z "$FILENAME" -a -n "$1" ] && { diff --git a/bin/device-update.sh b/bin/device-update.sh index ae7b52ea2..a62e9f468 100755 --- a/bin/device-update.sh +++ b/bin/device-update.sh @@ -1,6 +1,7 @@ #!/bin/sh PYTHON=${PYTHON:-$(which python3 python|head -n 1)} +CHANGE_MODE=false # Determine the correct esptool command to use if "$PYTHON" -m esptool version >/dev/null 2>&1; then @@ -17,14 +18,15 @@ fi # Usage info show_help() { cat << EOF -Usage: $(basename $0) [-h] [-p ESPTOOL_PORT] [-P PYTHON] [-f FILENAME|FILENAME] -Flash image file to device, leave existing system intact." +Usage: $(basename $0) [-h] [-p ESPTOOL_PORT] [-P PYTHON] [-f FILENAME|FILENAME] [--change-mode] +Flash image file to device, leave existing system intact. -h Display this help and exit -p ESPTOOL_PORT Set the environment variable for ESPTOOL_PORT. If not set, ESPTOOL iterates all ports (Dangerous). -P PYTHON Specify alternate python interpreter to use to invoke esptool. (Default: "$PYTHON") -f FILENAME The *update.bin file to flash. Custom to your device type. - + --change-mode Attempt to place the device in correct mode. Some hardware requires this twice. (1200bps Reset) + EOF } @@ -41,6 +43,9 @@ while getopts ":hp:P:f:" opt; do ;; f) FILENAME=${OPTARG} ;; + --change-mode) + CHANGE_MODE=true + ;; *) echo "Invalid flag." show_help >&2 @@ -50,6 +55,11 @@ while getopts ":hp:P:f:" opt; do done shift "$((OPTIND-1))" +if [[ $WEB_APP == true ]]; then + $ESPTOOL_CMD --baud 1200 --after no_reset read_flash_status + exit 0 +fi + [ -z "$FILENAME" -a -n "$1" ] && { FILENAME=$1 shift