Skip to content

Commit 737b5a0

Browse files
1 parent 65ad17f commit 737b5a0

File tree

314 files changed

+212425
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

314 files changed

+212425
-0
lines changed
Binary file not shown.
Binary file not shown.
498 KB
Binary file not shown.
495 KB
Binary file not shown.

firmware-2.6.13.0561f2c/bleota.bin

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

0 commit comments

Comments
 (0)