From b16004dcdf7a102ad16566483666b6bc8b2d0914 Mon Sep 17 00:00:00 2001 From: michelepagot Date: Sun, 23 May 2021 01:46:31 +0200 Subject: [PATCH 1/2] .bat porting of install and update scripts --- bin/device-install.bat | 40 ++++++++++++++++++++++++++++++++++++++++ bin/device-update.bat | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 bin/device-install.bat create mode 100644 bin/device-update.bat diff --git a/bin/device-install.bat b/bin/device-install.bat new file mode 100644 index 00000000..db48d30c --- /dev/null +++ b/bin/device-install.bat @@ -0,0 +1,40 @@ +@ECHO OFF + +set PYTHON=python + +goto GETOPTS +:HELP +echo Usage: %~nx0 [-h] [-p ESPTOOL_PORT] [-P PYTHON] [-f FILENAME^|FILENAME] +echo Flash image file to device, but first erasing and writing system information +echo. +echo -h Display this help and exit +echo -p ESPTOOL_PORT Set the environment variable for ESPTOOL_PORT. If not set, ESPTOOL iterates all ports (Dangerrous). +echo -P PYTHON Specify alternate python interpreter to use to invoke esptool. (Default: %PYTHON%) +echo -f FILENAME The .bin file to flash. Custom to your device type and region. +goto EOF + +:GETOPTS +if /I "%1"=="-h" goto HELP +if /I "%1"=="--help" goto HELP +if /I "%1"=="-F" set "FILENAME=%2" & SHIFT +if /I "%1"=="-p" set ESPTOOL_PORT=%2 & SHIFT +if /I "%1"=="-P" set PYTHON=%2 & SHIFT +SHIFT +IF NOT "__%1__"=="____" goto GETOPTS + +IF "__%FILENAME%__" == "____" ( + echo "Missing FILENAME" + goto HELP +) +IF EXIST %FILENAME% ( + echo Trying to flash update %FILENAME%, but first erasing and writing system information" + %PYTHON% -m esptool --baud 921600 erase_flash + %PYTHON% -m esptool --baud 921600 write_flash 0x1000 system-info.bin + %PYTHON% -m esptool --baud 921600 write_flash 0x00390000 spiffs-*.bin + %PYTHON% -m esptool --baud 921600 write_flash 0x10000 %FILENAME% +) else ( + echo "Invalid file: %FILENAME%" + goto HELP +) + +:EOF \ No newline at end of file diff --git a/bin/device-update.bat b/bin/device-update.bat new file mode 100644 index 00000000..4cede3db --- /dev/null +++ b/bin/device-update.bat @@ -0,0 +1,39 @@ +@ECHO OFF + +set PYTHON=python + +goto GETOPTS +:HELP +echo Usage: %~nx0 [-h] [-p ESPTOOL_PORT] [-P PYTHON] [-f FILENAME^|FILENAME] +echo Flash image file to device, leave existing system intact. +echo. +echo -h Display this help and exit +echo -p ESPTOOL_PORT Set the environment variable for ESPTOOL_PORT. If not set, ESPTOOL iterates all ports (Dangerrous). +echo -P PYTHON Specify alternate python interpreter to use to invoke esptool. (Default: %PYTHON%) +echo -f FILENAME The .bin file to flash. Custom to your device type and region. +goto EOF + +:GETOPTS +if /I "%1"=="-h" goto HELP +if /I "%1"=="--help" goto HELP +if /I "%1"=="-F" set "FILENAME=%2" & SHIFT +if /I "%1"=="-p" set ESPTOOL_PORT=%2 & SHIFT +if /I "%1"=="-P" set PYTHON=%2 & SHIFT +SHIFT +IF NOT "__%1__"=="____" goto GETOPTS + +IF "__%FILENAME%__" == "____" ( + echo "Missing FILENAME" + goto HELP +) +IF EXIST %FILENAME% ( + echo Trying to flash update %FILENAME% + %PYTHON% -m esptool --baud 921600 write_flash 0x10000 %FILENAME% + echo Erasing the otadata partition, which will turn off flash flippy-flop and force the first image to be used + %PYTHON% -m esptool --baud 921600 erase_region 0xe000 0x2000 +) else ( + echo "Invalid file: %FILENAME%" + goto HELP +) + +:EOF \ No newline at end of file From 0206e6515286232516b591ded07a6f18d166c740 Mon Sep 17 00:00:00 2001 From: michelepagot Date: Sun, 23 May 2021 02:33:15 +0200 Subject: [PATCH 2/2] fix device-install.bat about star usage --- bin/device-install.bat | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/device-install.bat b/bin/device-install.bat index db48d30c..4837d61b 100644 --- a/bin/device-install.bat +++ b/bin/device-install.bat @@ -30,7 +30,9 @@ IF EXIST %FILENAME% ( echo Trying to flash update %FILENAME%, but first erasing and writing system information" %PYTHON% -m esptool --baud 921600 erase_flash %PYTHON% -m esptool --baud 921600 write_flash 0x1000 system-info.bin - %PYTHON% -m esptool --baud 921600 write_flash 0x00390000 spiffs-*.bin + for %%f in (spiffs-*.bin) do ( + %PYTHON% -m esptool --baud 921600 write_flash 0x00390000 %%f + ) %PYTHON% -m esptool --baud 921600 write_flash 0x10000 %FILENAME% ) else ( echo "Invalid file: %FILENAME%"