Safemode refactor

* Safemode refactor

* Looks nicer

* rm littlefs upload

* Delete littlefs.bin

* Create placeholder

* Delete tasmota32-minicustom.bin

* Delete tasmota32c3-minicustom.bin

* rm littlefs

* rename to *-safemode.bin
This commit is contained in:
Jason2866 2022-05-02 23:24:52 +02:00 committed by GitHub
parent ec981e0efd
commit f789225e02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 42 additions and 31 deletions

View File

@ -32,10 +32,6 @@
[
"0x10000",
"variants/tasmota/tasmota32-minicustom.bin"
],
[
"0x3B0000",
"variants/tasmota/littlefs.bin"
]
]
},

View File

@ -29,10 +29,6 @@
[
"0x10000",
"variants/tasmota/tasmota32c3-minicustom.bin"
],
[
"0x3B0000",
"variants/tasmota/littlefs.bin"
]
]
},

View File

@ -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,

1 # Name Type SubType Offset Size Flags
2 nvs data nvs 0x9000 0x5000
3 otadata data ota 0xe000 0x2000
4 factory app factory 0x10000 0xD0000
5 app0 app ota_0 0xE0000 0x2D0000
6 spiffs data spiffs 0x3B0000 0x50000

View File

@ -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)

View File

@ -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]

View File

@ -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}

Binary file not shown.

1
safemode/placeholder Normal file
View File

@ -0,0 +1 @@

Binary file not shown.

Binary file not shown.