Skip to content

Commit 6d40be3

Browse files
committed
2.6.4 try
1 parent 956c155 commit 6d40be3

272 files changed

Lines changed: 167850 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Binary file not shown.
Binary file not shown.
498 KB
Binary file not shown.
495 KB
Binary file not shown.

firmware-2.6.4.b89355f/bleota.bin

604 KB
Binary file not shown.
Lines changed: 295 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,295 @@
1+
@ECHO OFF
2+
SETLOCAL EnableDelayedExpansion
3+
TITLE Meshtastic device-install
4+
5+
SET "SCRIPT_NAME=%~nx0"
6+
SET "DEBUG=0"
7+
SET "PYTHON="
8+
SET "WEB_APP=0"
9+
SET "TFT_BUILD=0"
10+
SET "BIGDB8=0"
11+
SET "BIGDB16=0"
12+
SET "ESPTOOL_BAUD=115200"
13+
SET "ESPTOOL_CMD="
14+
SET "LOGCOUNTER=0"
15+
16+
@REM FIXME: Determine mcu from PlatformIO variant, this is unmaintainable.
17+
SET "S3=s3 v3 t-deck wireless-paper wireless-tracker station-g2 unphone"
18+
SET "C3=esp32c3"
19+
@REM FIXME: Determine flash size from PlatformIO variant, this is unmaintainable.
20+
SET "BIGDB_8MB=picomputer-s3 unphone seeed-sensecap-indicator crowpanel-esp32s3 heltec_capsule_sensor_v3 heltec-v3 heltec-vision-master-e213 heltec-vision-master-e290 heltec-vision-master-t190 heltec-wireless-paper heltec-wireless-tracker heltec-wsl-v3 icarus seeed-xiao-s3 tbeam-s3-core t-watch-s3 tracksenger"
21+
SET "BIGDB_16MB=t-deck mesh-tab t-energy-s3 dreamcatcher ESP32-S3-Pico m5stack-cores3 station-g2 t-eth-elite"
22+
23+
GOTO getopts
24+
:help
25+
ECHO Flash image file to device, but first erasing and writing system information.
26+
ECHO.
27+
ECHO Usage: %SCRIPT_NAME% -f filename [-p PORT] [-P python] (--web)
28+
ECHO.
29+
ECHO Options:
30+
ECHO -f filename The firmware .bin file to flash. Custom to your device type and region. (required)
31+
ECHO The file must be located in this current directory.
32+
ECHO -p PORT Set the environment variable for ESPTOOL_PORT.
33+
ECHO If not set, ESPTOOL iterates all ports (Dangerous).
34+
ECHO -P python Specify alternate python interpreter to use to invoke esptool. (default: python)
35+
ECHO If supplied the script will use python.
36+
ECHO If not supplied the script will try to find esptool in Path.
37+
ECHO --web Enable WebUI. (default: false)
38+
ECHO.
39+
ECHO Example: %SCRIPT_NAME% -f firmware-t-deck-tft-2.6.0.0b106d4.bin -p COM11
40+
ECHO Example: %SCRIPT_NAME% -f firmware-unphone-2.6.0.0b106d4.bin -p COM11 --web
41+
GOTO eof
42+
43+
:version
44+
ECHO %SCRIPT_NAME% [Version 2.6.1]
45+
ECHO Meshtastic
46+
GOTO eof
47+
48+
:getopts
49+
IF "%~1"=="" GOTO endopts
50+
IF /I "%~1"=="-?" GOTO help
51+
IF /I "%~1"=="-h" GOTO help
52+
IF /I "%~1"=="--help" GOTO help
53+
IF /I "%~1"=="-v" GOTO version
54+
IF /I "%~1"=="--version" GOTO version
55+
IF /I "%~1"=="--debug" SET "DEBUG=1" & CALL :LOG_MESSAGE DEBUG "DEBUG mode: enabled."
56+
IF /I "%~1"=="-f" SET "FILENAME=%~2" & SHIFT
57+
IF "%~1"=="-p" SET "ESPTOOL_PORT=%~2" & SHIFT
58+
IF /I "%~1"=="--port" SET "ESPTOOL_PORT=%~2" & SHIFT
59+
IF "%~1"=="-P" SET "PYTHON=%~2" & SHIFT
60+
IF /I "%~1"=="--web" SET "WEB_APP=1"
61+
SHIFT
62+
GOTO getopts
63+
:endopts
64+
65+
CALL :LOG_MESSAGE DEBUG "Checking FILENAME parameter..."
66+
IF "__!FILENAME!__"=="____" (
67+
CALL :LOG_MESSAGE DEBUG "Missing -f filename input."
68+
GOTO help
69+
) ELSE (
70+
CALL :LOG_MESSAGE DEBUG "Filename: !FILENAME!"
71+
IF NOT "__!FILENAME: =!__"=="__!FILENAME!__" (
72+
CALL :LOG_MESSAGE ERROR "Filename containing spaces are not supported."
73+
GOTO help
74+
)
75+
IF "__!FILENAME:firmware-=!__"=="__!FILENAME!__" (
76+
CALL :LOG_MESSAGE ERROR "Filename must be a firmware-* file."
77+
GOTO help
78+
)
79+
@REM Remove ".\" or "./" file prefix if present.
80+
SET "FILENAME=!FILENAME:.\=!"
81+
SET "FILENAME=!FILENAME:./=!"
82+
)
83+
84+
CALL :LOG_MESSAGE DEBUG "Checking if !FILENAME! exists..."
85+
IF NOT EXIST !FILENAME! (
86+
CALL :LOG_MESSAGE ERROR "File does not exist: !FILENAME!. Terminating."
87+
GOTO eof
88+
)
89+
90+
IF NOT "!FILENAME:update=!"=="!FILENAME!" (
91+
CALL :LOG_MESSAGE DEBUG "We are working with a *update* file. !FILENAME!"
92+
CALL :LOG_MESSAGE INFO "Use script device-update.bat to flash update !FILENAME!."
93+
GOTO eof
94+
) ELSE (
95+
CALL :LOG_MESSAGE DEBUG "We are NOT working with a *update* file. !FILENAME!"
96+
)
97+
98+
CALL :LOG_MESSAGE DEBUG "Determine the correct esptool command to use..."
99+
IF NOT "__%PYTHON%__"=="____" (
100+
SET "ESPTOOL_CMD=!PYTHON! -m esptool"
101+
CALL :LOG_MESSAGE DEBUG "Python interpreter supplied."
102+
) ELSE (
103+
CALL :LOG_MESSAGE DEBUG "Python interpreter NOT supplied. Looking for esptool...
104+
WHERE esptool >nul 2>&1
105+
IF %ERRORLEVEL% EQU 0 (
106+
@REM WHERE exits with code 0 if esptool is found.
107+
SET "ESPTOOL_CMD=esptool"
108+
) ELSE (
109+
SET "ESPTOOL_CMD=python -m esptool"
110+
CALL :RESET_ERROR
111+
)
112+
)
113+
114+
CALL :LOG_MESSAGE DEBUG "Checking esptool command !ESPTOOL_CMD!..."
115+
!ESPTOOL_CMD! >nul 2>&1
116+
IF %ERRORLEVEL% GEQ 2 (
117+
@REM esptool exits with code 1 if help is displayed.
118+
CALL :LOG_MESSAGE ERROR "esptool not found: !ESPTOOL_CMD!"
119+
EXIT /B 1
120+
GOTO eof
121+
)
122+
IF %DEBUG% EQU 1 (
123+
CALL :LOG_MESSAGE DEBUG "Skipping ESPTOOL_CMD steps."
124+
SET "ESPTOOL_CMD=REM !ESPTOOL_CMD!"
125+
)
126+
127+
CALL :LOG_MESSAGE DEBUG "Using esptool command: !ESPTOOL_CMD!"
128+
IF "__!ESPTOOL_PORT!__" == "____" (
129+
CALL :LOG_MESSAGE WARN "Using esptool port: UNSET."
130+
) ELSE (
131+
SET "ESPTOOL_CMD=!ESPTOOL_CMD! --port !ESPTOOL_PORT!"
132+
CALL :LOG_MESSAGE INFO "Using esptool port: !ESPTOOL_PORT!."
133+
)
134+
CALL :LOG_MESSAGE INFO "Using esptool baud: !ESPTOOL_BAUD!."
135+
136+
@REM Check if FILENAME contains "-tft-" and set target partitionScheme accordingly.
137+
@REM https://github.com/meshtastic/web-flasher/blob/main/types/resources.ts#L3
138+
IF NOT "!FILENAME:-tft-=!"=="!FILENAME!" (
139+
CALL :LOG_MESSAGE DEBUG "We are working with a *-tft-* file. !FILENAME!"
140+
IF %WEB_APP% EQU 1 (
141+
CALL :LOG_MESSAGE ERROR "Cannot enable WebUI (--web) and MUI." & GOTO eof
142+
)
143+
SET "TFT_BUILD=1"
144+
) ELSE (
145+
CALL :LOG_MESSAGE DEBUG "We are NOT working with a *-tft-* file. !FILENAME!"
146+
)
147+
148+
FOR %%a IN (%BIGDB_8MB%) DO (
149+
IF NOT "!FILENAME:%%a=!"=="!FILENAME!" (
150+
@REM We are working with any of %BIGDB_8MB%.
151+
SET "BIGDB8=1"
152+
GOTO end_loop_bigdb_8mb
153+
)
154+
)
155+
:end_loop_bigdb_8mb
156+
157+
FOR %%a IN (%BIGDB_16MB%) DO (
158+
IF NOT "!FILENAME:%%a=!"=="!FILENAME!" (
159+
@REM We are working with any of %BIGDB_16MB%.
160+
SET "BIGDB16=1"
161+
GOTO end_loop_bigdb_16mb
162+
)
163+
)
164+
:end_loop_bigdb_16mb
165+
166+
IF %BIGDB8% EQU 1 CALL :LOG_MESSAGE INFO "BigDB 8mb partition selected."
167+
IF %BIGDB16% EQU 1 CALL :LOG_MESSAGE INFO "BigDB 16mb partition selected."
168+
169+
@REM Extract BASENAME from %FILENAME% for later use.
170+
SET "BASENAME=!FILENAME:firmware-=!"
171+
CALL :LOG_MESSAGE DEBUG "Computed firmware basename: !BASENAME!"
172+
173+
@REM Account for S3 and C3 board's different OTA partition.
174+
FOR %%a IN (%S3%) DO (
175+
IF NOT "!FILENAME:%%a=!"=="!FILENAME!" (
176+
@REM We are working with any of %S3%.
177+
SET "OTA_FILENAME=bleota-s3.bin"
178+
GOTO :end_loop_s3
179+
)
180+
)
181+
182+
FOR %%a IN (%C3%) DO (
183+
IF NOT "!FILENAME:%%a=!"=="!FILENAME!" (
184+
@REM We are working with any of %C3%.
185+
SET "OTA_FILENAME=bleota-c3.bin"
186+
GOTO :end_loop_c3
187+
)
188+
)
189+
190+
@REM Everything else
191+
SET "OTA_FILENAME=bleota.bin"
192+
:end_loop_s3
193+
:end_loop_c3
194+
CALL :LOG_MESSAGE DEBUG "Set OTA_FILENAME to: !OTA_FILENAME!"
195+
196+
@REM Check if (--web) is enabled and prefix BASENAME with "littlefswebui-" else "littlefs-".
197+
IF %WEB_APP% EQU 1 (
198+
CALL :LOG_MESSAGE INFO "WebUI selected."
199+
SET "SPIFFS_FILENAME=littlefswebui-%BASENAME%"
200+
) ELSE (
201+
SET "SPIFFS_FILENAME=littlefs-%BASENAME%"
202+
)
203+
CALL :LOG_MESSAGE DEBUG "Set SPIFFS_FILENAME to: !SPIFFS_FILENAME!"
204+
205+
@REM Default offsets.
206+
@REM https://github.com/meshtastic/web-flasher/blob/main/stores/firmwareStore.ts#L202
207+
SET "OTA_OFFSET=0x260000"
208+
SET "SPIFFS_OFFSET=0x300000"
209+
210+
@REM Offsets for BigDB 8mb.
211+
IF %BIGDB8% EQU 1 (
212+
SET "OTA_OFFSET=0x340000"
213+
SET "SPIFFS_OFFSET=0x670000"
214+
)
215+
216+
@REM Offsets for BigDB 16mb.
217+
IF %BIGDB16% EQU 1 (
218+
SET "OTA_OFFSET=0x650000"
219+
SET "SPIFFS_OFFSET=0xc90000"
220+
)
221+
222+
CALL :LOG_MESSAGE DEBUG "Set OTA_OFFSET to: !OTA_OFFSET!"
223+
CALL :LOG_MESSAGE DEBUG "Set SPIFFS_OFFSET to: !SPIFFS_OFFSET!"
224+
225+
@REM Ensure target files exist before flashing operations.
226+
IF NOT EXIST !FILENAME! CALL :LOG_MESSAGE ERROR "File does not exist: "!FILENAME!". Terminating." & EXIT /B 2 & GOTO eof
227+
IF NOT EXIST !OTA_FILENAME! CALL :LOG_MESSAGE ERROR "File does not exist: "!OTA_FILENAME!". Terminating." & EXIT /B 2 & GOTO eof
228+
IF NOT EXIST !SPIFFS_FILENAME! CALL :LOG_MESSAGE ERROR "File does not exist: "!SPIFFS_FILENAME!". Terminating." & EXIT /B 2 & GOTO eof
229+
230+
@REM Flashing operations.
231+
CALL :LOG_MESSAGE INFO "Trying to flash "!FILENAME!", but first erasing and writing system information..."
232+
CALL :RUN_ESPTOOL !ESPTOOL_BAUD! erase_flash || GOTO eof
233+
CALL :RUN_ESPTOOL !ESPTOOL_BAUD! write_flash 0x00 "!FILENAME!" || GOTO eof
234+
235+
CALL :LOG_MESSAGE INFO "Trying to flash BLEOTA "!OTA_FILENAME!" at OTA_OFFSET !OTA_OFFSET!..."
236+
CALL :RUN_ESPTOOL !ESPTOOL_BAUD! write_flash !OTA_OFFSET! "!OTA_FILENAME!" || GOTO eof
237+
238+
CALL :LOG_MESSAGE INFO "Trying to flash SPIFFS "!SPIFFS_FILENAME!" at SPIFFS_OFFSET !SPIFFS_OFFSET!..."
239+
CALL :RUN_ESPTOOL !ESPTOOL_BAUD! write_flash !SPIFFS_OFFSET! "!SPIFFS_FILENAME!" || GOTO eof
240+
241+
CALL :LOG_MESSAGE INFO "Script complete!."
242+
243+
:eof
244+
ENDLOCAL
245+
EXIT /B %ERRORLEVEL%
246+
247+
248+
:RUN_ESPTOOL
249+
@REM Subroutine used to run ESPTOOL_CMD with arguments.
250+
@REM Also handles %ERRORLEVEL%.
251+
@REM CALL :RUN_ESPTOOL [Baud] [erase_flash|write_flash] [OFFSET] [Filename]
252+
@REM.
253+
@REM Example:: CALL :RUN_ESPTOOL 115200 write_flash 0x10000 "firmwarefile.bin"
254+
IF %DEBUG% EQU 1 CALL :LOG_MESSAGE DEBUG "About to run command: !ESPTOOL_CMD! --baud %~1 %~2 %~3 %~4"
255+
CALL :RESET_ERROR
256+
!ESPTOOL_CMD! --baud %~1 %~2 %~3 %~4
257+
IF %ERRORLEVEL% NEQ 0 (
258+
CALL :LOG_MESSAGE ERROR "Error running command: !ESPTOOL_CMD! --baud %~1 %~2 %~3 %~4"
259+
EXIT /B %ERRORLEVEL%
260+
)
261+
GOTO :eof
262+
263+
:LOG_MESSAGE
264+
@REM Subroutine used to print log messages in four different levels.
265+
@REM DEBUG messages only get printed if [-d] flag is passed to script.
266+
@REM CALL :LOG_MESSAGE [ERROR|INFO|WARN|DEBUG] "Message"
267+
@REM.
268+
@REM Example:: CALL :LOG_MESSAGE INFO "Message."
269+
SET /A LOGCOUNTER=LOGCOUNTER+1
270+
IF "%1" == "ERROR" CALL :GET_TIMESTAMP & ECHO %1 ^| !TIMESTAMP! !LOGCOUNTER! %~2
271+
IF "%1" == "INFO" CALL :GET_TIMESTAMP & ECHO %1 ^| !TIMESTAMP! !LOGCOUNTER! %~2
272+
IF "%1" == "WARN" CALL :GET_TIMESTAMP & ECHO %1 ^| !TIMESTAMP! !LOGCOUNTER! %~2
273+
IF "%1" == "DEBUG" IF %DEBUG% EQU 1 CALL :GET_TIMESTAMP & ECHO %1 ^| !TIMESTAMP! !LOGCOUNTER! %~2
274+
GOTO :eof
275+
276+
:GET_TIMESTAMP
277+
@REM Subroutine used to set !TIMESTAMP! to HH:MM:ss.
278+
@REM CALL :GET_TIMESTAMP
279+
@REM.
280+
@REM Updates: !TIMESTAMP!
281+
FOR /F "tokens=1,2,3 delims=:,." %%a IN ("%TIME%") DO (
282+
SET "HH=%%a"
283+
SET "MM=%%b"
284+
SET "ss=%%c"
285+
)
286+
SET "TIMESTAMP=!HH!:!MM!:!ss!"
287+
GOTO :eof
288+
289+
:RESET_ERROR
290+
@REM Subroutine to reset %ERRORLEVEL% to 0.
291+
@REM CALL :RESET_ERROR
292+
@REM.
293+
@REM Updates: %ERRORLEVEL%
294+
EXIT /B 0
295+
GOTO :eof

0 commit comments

Comments
 (0)