esptool v5.0.0 changes for post pio esp32 script (#23650)

This commit is contained in:
Jason2866 2025-07-08 22:05:14 +02:00 committed by GitHub
parent d8b40263e2
commit dc14f1c3bd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 26 deletions

View File

@ -1,22 +1,11 @@
Import("env") Import("env")
import os import os
import tasmotapiolib
from os.path import join from os.path import join
import subprocess
def firm_metrics(source, target, env): def firm_metrics(source, target, env):
print() print()
if env["PIOPLATFORM"] == "espressif32": if env["PIOPLATFORM"] == "espressif8266":
try:
import tasmota_metrics
map_file = str(tasmotapiolib.get_source_map_path(env).resolve())
subprocess.run([
env.subst("$PYTHONEXE"), "-m", "tasmota_metrics", map_file
], check=False)
except:
pass
elif env["PIOPLATFORM"] == "espressif8266":
map_file = join(env.subst("$BUILD_DIR")) + os.sep + "firmware.map" map_file = join(env.subst("$BUILD_DIR")) + os.sep + "firmware.map"
with open(map_file,'r', encoding='utf-8') as f: with open(map_file,'r', encoding='utf-8') as f:
phrase = "_text_end = ABSOLUTE (.)" phrase = "_text_end = ABSOLUTE (.)"

View File

@ -38,7 +38,6 @@ from platformio.project.config import ProjectConfig
esptoolpy = os.path.join(ProjectConfig.get_instance().get("platformio", "packages_dir"), "tool-esptoolpy") esptoolpy = os.path.join(ProjectConfig.get_instance().get("platformio", "packages_dir"), "tool-esptoolpy")
sys.path.append(esptoolpy) sys.path.append(esptoolpy)
import esptool import esptool
config = env.GetProjectConfig() config = env.GetProjectConfig()
@ -103,8 +102,8 @@ def esp32_detect_flashsize():
if not "esptool" in uploader: if not "esptool" in uploader:
return "4MB",False return "4MB",False
else: else:
esptoolpy_flags = ["flash_id"] esptoolpy_flags = ["flash-id"]
esptoolpy_cmd = [env["PYTHONEXE"], esptoolpy] + esptoolpy_flags esptoolpy_cmd = esptoolpy + esptoolpy_flags
try: try:
output = subprocess.run(esptoolpy_cmd, capture_output=True).stdout.splitlines() output = subprocess.run(esptoolpy_cmd, capture_output=True).stdout.splitlines()
for l in output: for l in output:
@ -282,14 +281,14 @@ def esp32_create_combined_bin(source, target, env):
cmd = [ cmd = [
"--chip", "--chip",
chip, chip,
"merge_bin", "merge-bin",
"-o", "-o",
new_file_name, new_file_name,
"--flash_mode", "--flash-mode",
flash_mode, flash_mode,
"--flash_freq", "--flash-freq",
flash_freq, flash_freq,
"--flash_size", "--flash-size",
flash_size, flash_size,
] ]
# platformio estimates the flash space used to store the firmware. # platformio estimates the flash space used to store the firmware.
@ -320,8 +319,8 @@ def esp32_create_combined_bin(source, target, env):
if(upload_protocol == "esptool") and (fs_offset != -1): if(upload_protocol == "esptool") and (fs_offset != -1):
fs_bin = join(env.subst("$BUILD_DIR"),"littlefs.bin") fs_bin = join(env.subst("$BUILD_DIR"),"littlefs.bin")
if exists(fs_bin): if exists(fs_bin):
before_reset = env.BoardConfig().get("upload.before_reset", "default_reset") before_reset = env.BoardConfig().get("upload.before_reset", "default-reset")
after_reset = env.BoardConfig().get("upload.after_reset", "hard_reset") after_reset = env.BoardConfig().get("upload.after_reset", "hard-reset")
print(f" - {hex(fs_offset).ljust(8)} | {fs_bin}") print(f" - {hex(fs_offset).ljust(8)} | {fs_bin}")
print() print()
cmd += [hex(fs_offset), fs_bin] cmd += [hex(fs_offset), fs_bin]
@ -332,12 +331,12 @@ def esp32_create_combined_bin(source, target, env):
"--baud", "$UPLOAD_SPEED", "--baud", "$UPLOAD_SPEED",
"--before", before_reset, "--before", before_reset,
"--after", after_reset, "--after", after_reset,
"write_flash", "-z", "write-flash", "-z",
"--flash_mode", "${__get_board_flash_mode(__env__)}", "--flash-mode", "${__get_board_flash_mode(__env__)}",
"--flash_freq", "${__get_board_f_flash(__env__)}", "--flash-freq", "${__get_board_f_flash(__env__)}",
"--flash_size", flash_size "--flash-size", flash_size
], ],
UPLOADCMD='"$PYTHONEXE" "$UPLOADER" $UPLOADERFLAGS ' + " ".join(cmd[7:]) UPLOADCMD='"$UPLOADER" $UPLOADERFLAGS ' + " ".join(cmd[7:])
) )
print(Fore.GREEN + "Will use custom upload command for flashing operation to add file system defined for this build target.") print(Fore.GREEN + "Will use custom upload command for flashing operation to add file system defined for this build target.")
print() print()