diff --git a/boards/esp32_4M_2APP.json b/boards/esp32_4M_2APP.json index e2117ef59..e92826140 100644 --- a/boards/esp32_4M_2APP.json +++ b/boards/esp32_4M_2APP.json @@ -32,10 +32,6 @@ [ "0x10000", "variants/tasmota/tasmota32-minicustom.bin" - ], - [ - "0x3B0000", - "variants/tasmota/littlefs.bin" ] ] }, diff --git a/boards/esp32c3_2APP.json b/boards/esp32c3_2APP.json index a523062e6..cc40ed091 100644 --- a/boards/esp32c3_2APP.json +++ b/boards/esp32c3_2APP.json @@ -29,10 +29,6 @@ [ "0x10000", "variants/tasmota/tasmota32c3-minicustom.bin" - ], - [ - "0x3B0000", - "variants/tasmota/littlefs.bin" ] ] }, diff --git a/esp32_partition_app2880k_spiffs320k.csv b/esp32_partition_app2880k_spiffs320k.csv index 1e319a6b9..ee2ce899c 100644 --- a/esp32_partition_app2880k_spiffs320k.csv +++ b/esp32_partition_app2880k_spiffs320k.csv @@ -1,6 +1,6 @@ # Name, Type, SubType, Offset, Size, Flags nvs, data, nvs, 0x9000, 0x5000, otadata, data, ota, 0xe000, 0x2000, -factory, app, factory, 0x10000,0xD0000, +factory, app, factory, 0x10000, 0xD0000, app0, app, ota_0, 0xE0000, 0x2D0000, spiffs, data, spiffs, 0x3B0000,0x50000, diff --git a/pio-tools/copy_safemode.py b/pio-tools/copy_safemode.py deleted file mode 100644 index ea676af9f..000000000 --- a/pio-tools/copy_safemode.py +++ /dev/null @@ -1,20 +0,0 @@ -import os -import shutil -from os.path import join -from SCons.Script import DefaultEnvironment - -env = DefaultEnvironment() -platform = env.PioPlatform() - -FRAMEWORK_DIR = platform.get_package_dir("framework-arduinoespressif32") - -safemode_dir = join(env["PROJECT_DIR"], "safemode") -variants_dir = join(FRAMEWORK_DIR, "variants", "tasmota") - -if env["PIOPLATFORM"] == "espressif32": - if os.path.exists(safemode_dir): -# print("safemode.bin dir exists") - if os.path.exists(variants_dir): -# print("variants/tasmota exists") - shutil.rmtree(variants_dir) - shutil.copytree(safemode_dir, variants_dir) diff --git a/pio-tools/post_esp32.py b/pio-tools/post_esp32.py index 055582d33..76a83d1df 100644 --- a/pio-tools/post_esp32.py +++ b/pio-tools/post_esp32.py @@ -18,21 +18,47 @@ Import("env") +env = DefaultEnvironment() platform = env.PioPlatform() +from genericpath import exists +import os import sys from os.path import join import csv +import requests +import shutil sys.path.append(join(platform.get_package_dir("tool-esptoolpy"))) import esptool +FRAMEWORK_DIR = platform.get_package_dir("framework-arduinoespressif32") +safemode_dir = join(env["PROJECT_DIR"], "safemode") +variants_dir = join(FRAMEWORK_DIR, "variants", "tasmota") + + +def esp32_fetch_safemode_bin(chip): + safemode_fw_url = "https://github.com/Jason2866/Tasmota-specials/raw/firmware/firmware/tasmota32/other/tasmota" + chip[3:] + "-safemode.bin" + safemode_fw_name = safemode_dir + "/tasmota" + chip[3:] + "-safemode.bin" + if(exists(safemode_fw_name)): + print("Safemode binary already downloaded.") + return safemode_fw_name + print("Will download safemode binary from URL:") + print(safemode_fw_url) + response = requests.get(safemode_fw_url) + open(safemode_fw_name, "wb").write(response.content) + print("Safemode binary written to safemode dir.") + return safemode_fw_name + + def esp32_create_combined_bin(source, target, env): #print("Generating combined binary for serial flashing") # The offset from begin of the file where the app0 partition starts # This is defined in the partition .csv file - app_offset = 0x10000 # default value + factory_offset = -1 # error code value + app_offset = 0x10000 # default value for "old" scheme + spiffs_offset = -1 # error code value with open(env.BoardConfig().get("build.partitions")) as csv_file: print("Read partitions from ",env.BoardConfig().get("build.partitions")) csv_reader = csv.reader(csv_file, delimiter=',') @@ -46,12 +72,17 @@ def esp32_create_combined_bin(source, target, env): line_count += 1 if(row[0] == 'app0'): app_offset = int(row[3],base=16) + elif(row[0] == 'factory'): + factory_offset = int(row[3],base=16) + elif(row[0] == 'spiffs'): + spiffs_offset = int(row[3],base=16) # print("Got app_offset from .csv:", row[3]) new_file_name = env.subst("$BUILD_DIR/${PROGNAME}.factory.bin") sections = env.subst(env.get("FLASH_EXTRA_IMAGES")) firmware_name = env.subst("$BUILD_DIR/${PROGNAME}.bin") chip = env.get("BOARD_MCU") + esp32_fetch_safemode_bin(chip) flash_size = env.BoardConfig().get("upload.flash_size") cmd = [ "--chip", @@ -69,6 +100,14 @@ def esp32_create_combined_bin(source, target, env): print(f" - {sect_adr} | {sect_file}") cmd += [sect_adr, sect_file] + if os.path.exists(safemode_dir): + #print("safemode.bin dir exists") + if os.path.exists(variants_dir): + #print("variants/tasmota exists") + shutil.rmtree(variants_dir) + shutil.copytree(safemode_dir, variants_dir) + + # "main" firmware to app0 - mandatory print(f" - {hex(app_offset)} | {firmware_name}") cmd += [hex(app_offset), firmware_name] diff --git a/platformio_tasmota32.ini b/platformio_tasmota32.ini index 38f17ebd3..8c604f663 100644 --- a/platformio_tasmota32.ini +++ b/platformio_tasmota32.ini @@ -34,7 +34,6 @@ build_flags = ${esp_defaults.build_flags} -Wl,--wrap=panicHandler -Wl,--wrap=xt_unhandled_exception -Wl,--wrap=_Z11analogWritehi ; `analogWrite(unsigned char, int)` use the Tasmota version of analogWrite for deeper integration and phase control extra_scripts = pre:pio-tools/add_c_flags.py - pre:pio-tools/copy_safemode.py post:pio-tools/post_esp32.py ${esp_defaults.extra_scripts} diff --git a/safemode/littlefs.bin b/safemode/littlefs.bin deleted file mode 100644 index 796a29308..000000000 Binary files a/safemode/littlefs.bin and /dev/null differ diff --git a/safemode/placeholder b/safemode/placeholder new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/safemode/placeholder @@ -0,0 +1 @@ + diff --git a/safemode/tasmota32-minicustom.bin b/safemode/tasmota32-minicustom.bin deleted file mode 100644 index e614201ff..000000000 Binary files a/safemode/tasmota32-minicustom.bin and /dev/null differ diff --git a/safemode/tasmota32c3-minicustom.bin b/safemode/tasmota32c3-minicustom.bin deleted file mode 100644 index fc5631e42..000000000 Binary files a/safemode/tasmota32c3-minicustom.bin and /dev/null differ