diff --git a/pio-tools/custom_target.py b/pio-tools/custom_target.py index 29a31f6d9..9bf136a1e 100644 --- a/pio-tools/custom_target.py +++ b/pio-tools/custom_target.py @@ -14,6 +14,7 @@ import sys from os.path import isfile, join from enum import Enum import os +import tasmotapiolib import subprocess import shutil @@ -327,13 +328,11 @@ def upload_factory(*args, **kwargs): esptoolpy = join(platform.get_package_dir("tool-esptoolpy") or "", "esptool.py") upload_speed = join(str(board.get("upload.speed", "115200"))) upload_port = join(env.get("UPLOAD_PORT", "none")) - cur_env = (env["PIOENV"]) - firm_name = cur_env + "%s" % (".bin" if mcu == "esp8266" else (".factory.bin")) - target_firm = join(env.subst("$PROJECT_DIR"), "build_output","firmware",firm_name) + target_firm = join(env.subst("$PROJECT_DIR"),tasmotapiolib.get_final_bin_path(env).with_suffix(".bin" if mcu == "esp8266" else (".factory.bin"))) if "none" in upload_port: env.AutodetectUploadPort() upload_port = join(env.get("UPLOAD_PORT", "none")) - if "tasmota" in cur_env: + if "tasmota" in target_firm: esptoolpy_flags = [ "--chip", mcu, "--port", upload_port, diff --git a/pio-tools/set_partition_table.py b/pio-tools/set_partition_table.py index 364d55d60..77f937d3a 100644 --- a/pio-tools/set_partition_table.py +++ b/pio-tools/set_partition_table.py @@ -9,6 +9,7 @@ Import("env") import os +import tasmotapiolib from os.path import isfile, join import shutil from SCons.Script import COMMAND_LINE_TARGETS @@ -16,19 +17,19 @@ from SCons.Script import COMMAND_LINE_TARGETS board_config = env.BoardConfig() if "nobuild" in COMMAND_LINE_TARGETS: - if not os.path.isfile(join(env.subst("$BUILD_DIR"),"firmware.bin")): + prog_name = join(env.subst("$BUILD_DIR"),"firmware.bin") + if not os.path.isfile(prog_name): #print ("No firmware in path:",join(env.subst("$BUILD_DIR"))) env.CleanProject() cur_env = (env["PIOENV"]) firm_name = cur_env + ".bin" - source_firm = join(env.subst("$PROJECT_DIR"), "build_output","firmware",firm_name) + source_firm = tasmotapiolib.get_final_bin_path(env) if not os.path.exists(join(env.subst("$BUILD_DIR"))): os.makedirs(join(env.subst("$BUILD_DIR"))) if os.path.isfile(source_firm): shutil.copy(source_firm, join(env.subst("$BUILD_DIR"))) target_ren = join(env.subst("$BUILD_DIR"), firm_name) - renamed = join(env.subst("$BUILD_DIR"), "firmware.bin") - os.rename(target_ren, renamed) + os.rename(target_ren, prog_name) if env["PIOPLATFORM"] != "espressif32": framework_dir = env.PioPlatform().get_package_dir("framework-arduinoespressif8266")