diff --git a/bin/device-install.bat b/bin/device-install.bat index 419e8d6bd..15c2db352 100755 --- a/bin/device-install.bat +++ b/bin/device-install.bat @@ -26,7 +26,7 @@ IF "__%FILENAME%__" == "____" ( echo "Missing FILENAME" goto HELP ) -IF EXIST %FILENAME% ( +IF EXIST %FILENAME% IF x%FILENAME:update=%==x%FILENAME% ( echo Trying to flash update %FILENAME%, but first erasing and writing system information" %PYTHON% -m esptool --baud 115200 erase_flash %PYTHON% -m esptool --baud 115200 write_flash 0x00 %FILENAME% @@ -37,6 +37,9 @@ IF EXIST %FILENAME% ( ) else ( echo "Invalid file: %FILENAME%" goto HELP +) else ( + echo "Invalid file: %FILENAME%" + goto HELP ) :EOF diff --git a/bin/device-install.sh b/bin/device-install.sh index a55e553c7..bc14d440b 100755 --- a/bin/device-install.sh +++ b/bin/device-install.sh @@ -14,6 +14,7 @@ Flash image file to device, but first erasing and writing system information" -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 .bin file to flash. Custom to your device type and region. + EOF } @@ -44,7 +45,7 @@ shift "$((OPTIND-1))" shift } -if [ -f "${FILENAME}" ]; then +if [ -f "${FILENAME}" ] && [ "${FILENAME}" != *"update"* ]; then echo "Trying to flash ${FILENAME}, but first erasing and writing system information" "$PYTHON" -m esptool erase_flash "$PYTHON" -m esptool write_flash 0x00 ${FILENAME} @@ -52,8 +53,8 @@ if [ -f "${FILENAME}" ]; then "$PYTHON" -m esptool write_flash 0x300000 littlefs-*.bin else - echo "Invalid file: ${FILENAME}" show_help + echo "Invalid file: ${FILENAME}" fi exit 0 diff --git a/bin/device-update.bat b/bin/device-update.bat index 103fbad6e..2ac649be4 100755 --- a/bin/device-update.bat +++ b/bin/device-update.bat @@ -26,12 +26,15 @@ IF "__%FILENAME%__" == "____" ( echo "Missing FILENAME" goto HELP ) -IF EXIST %FILENAME% ( +IF EXIST %FILENAME% IF NOT x%FILENAME:update=%==x%FILENAME% ( echo Trying to flash update %FILENAME% %PYTHON% -m esptool --baud 115200 write_flash 0x10000 %FILENAME% ) else ( echo "Invalid file: %FILENAME%" goto HELP +) else ( + echo "Invalid file: %FILENAME%" + goto HELP ) :EOF diff --git a/bin/device-update.sh b/bin/device-update.sh index bd06fb25a..0959f0e3c 100755 --- a/bin/device-update.sh +++ b/bin/device-update.sh @@ -12,6 +12,7 @@ Flash image file to device, leave existing system intact." -p ESPTOOL_PORT Set the environment variable for ESPTOOL_PORT. If not set, ESPTOOL iterates all ports (Dangerrous). -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. + EOF } @@ -42,12 +43,12 @@ shift "$((OPTIND-1))" shift } -if [ -f "${FILENAME}" ]; then - echo "Trying to flash update ${FILENAME}." +if [ -f "${FILENAME}" ] && [ $FILENAME == *"update"* ]; then + printf "Trying to flash update ${FILENAME}" $PYTHON -m esptool --baud 115200 write_flash 0x10000 ${FILENAME} else - echo "Invalid file: ${FILENAME}" show_help + echo "Invalid file: ${FILENAME}" fi exit 0