mirror of https://github.com/arendst/Tasmota.git
Safemode refactor (again ;-) ) (#15529)
* add more safemode boards.json * no safemode folder * staars changes
This commit is contained in:
parent
156c254a9a
commit
1b7c182656
|
@ -22,7 +22,7 @@
|
|||
"arduino",
|
||||
"espidf"
|
||||
],
|
||||
"name": "Espressif Generic ESP32-C3 4M Flash, Tasmota 1856k Code/OTA, 320k FS",
|
||||
"name": "Espressif Generic ESP32-C3 4M Flash, Tasmota 2880k Code/OTA, 320k FS",
|
||||
"upload": {
|
||||
"arduino": {
|
||||
"flash_extra_images": [
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
{
|
||||
"build": {
|
||||
"arduino":{
|
||||
"ldscript": "esp32s2_out.ld"
|
||||
},
|
||||
"core": "esp32",
|
||||
"extra_flags": "-DBOARD_HAS_PSRAM -DARDUINO_USB_MODE=0 -DARDUINO_USB_CDC_ON_BOOT=0 -DARDUINO_USB_MSC_ON_BOOT=0 -DARDUINO_USB_DFU_ON_BOOT=0 -DESP32_4M -DESP32S2",
|
||||
"f_cpu": "240000000L",
|
||||
"f_flash": "80000000L",
|
||||
"flash_mode": "dout",
|
||||
"mcu": "esp32s2",
|
||||
"variant": "esp32s2",
|
||||
"partitions": "esp32_partition_app2880k_spiffs320k.csv"
|
||||
},
|
||||
"connectivity": [
|
||||
"wifi"
|
||||
],
|
||||
"debug": {
|
||||
"openocd_target": "esp32s2.cfg"
|
||||
},
|
||||
"frameworks": [
|
||||
"espidf",
|
||||
"arduino"
|
||||
],
|
||||
"name": "Espressif Generic ESP32-S2 4M Flash, Tasmota 2880k Code/OTA, 320k FS",
|
||||
"upload": {
|
||||
"arduino": {
|
||||
"flash_extra_images": [
|
||||
[
|
||||
"0x10000",
|
||||
"variants/tasmota/tasmota32s2-safemode.bin"
|
||||
]
|
||||
]
|
||||
},
|
||||
"flash_size": "4MB",
|
||||
"maximum_ram_size": 327680,
|
||||
"maximum_size": 4194304,
|
||||
"require_upload_port": true,
|
||||
"speed": 460800
|
||||
},
|
||||
"url": "https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/hw-reference/esp32s2/user-guide-saola-1-v1.2.html",
|
||||
"vendor": "Espressif"
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
{
|
||||
"build": {
|
||||
"arduino":{
|
||||
"ldscript": "esp32s3_out.ld",
|
||||
"memory_type": "qspi_qspi"
|
||||
},
|
||||
"core": "esp32",
|
||||
"extra_flags": "-DBOARD_HAS_PSRAM -DARDUINO_USB_MODE=0 -DARDUINO_USB_CDC_ON_BOOT=0 -DARDUINO_USB_MSC_ON_BOOT=0 -DARDUINO_USB_DFU_ON_BOOT=0 -DESP32_4M -DESP32S3",
|
||||
"f_cpu": "240000000L",
|
||||
"f_flash": "80000000L",
|
||||
"flash_mode": "dio",
|
||||
"mcu": "esp32s3",
|
||||
"variant": "esp32s3",
|
||||
"partitions": "esp32_partition_app2880k_spiffs320k.csv"
|
||||
},
|
||||
"connectivity": [
|
||||
"wifi",
|
||||
"bluetooth",
|
||||
"ethernet"
|
||||
],
|
||||
"debug": {
|
||||
"openocd_target": "esp32s3.cfg"
|
||||
},
|
||||
"frameworks": [
|
||||
"espidf",
|
||||
"arduino"
|
||||
],
|
||||
"name": "Espressif Generic ESP32-S3 4M Flash, Tasmota 2880k Code/OTA, 320k FS",
|
||||
"upload": {
|
||||
"arduino": {
|
||||
"flash_extra_images": [
|
||||
[
|
||||
"0x10000",
|
||||
"variants/tasmota/tasmota32s3-safemode.bin"
|
||||
]
|
||||
]
|
||||
},
|
||||
"flash_size": "4MB",
|
||||
"maximum_ram_size": 327680,
|
||||
"maximum_size": 4194304,
|
||||
"require_upload_port": true,
|
||||
"speed": 460800
|
||||
},
|
||||
"url": "https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/hw-reference/esp32s3/",
|
||||
"vendor": "Espressif"
|
||||
}
|
|
@ -33,23 +33,25 @@ 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/arendst/Tasmota-firmware/raw/main/firmware/tasmota32/tasmota" + chip[3:] + "-safemode.bin"
|
||||
safemode_fw_name = safemode_dir + "/tasmota" + chip[3:] + "-safemode.bin"
|
||||
safemode_fw_name = join(variants_dir,"tasmota" + chip[3:] + "-safemode.bin")
|
||||
if(exists(safemode_fw_name)):
|
||||
print("Safemode binary already downloaded.")
|
||||
return safemode_fw_name
|
||||
print("Safemode binary already in place.")
|
||||
return
|
||||
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
|
||||
print("Safemode binary written to variants dir.")
|
||||
|
||||
def esp32_copy_new_safemode_bin(chip,new_local_safemode_fw):
|
||||
print("Copy new local safemode firmware to variants dir -> using it for further flashing operations")
|
||||
safemode_fw_name = join(variants_dir,"tasmota" + chip[3:] + "-safemode.bin")
|
||||
if os.path.exists(variants_dir):
|
||||
shutil.copy(new_local_safemode_fw, safemode_fw_name)
|
||||
|
||||
def esp32_create_combined_bin(source, target, env):
|
||||
#print("Generating combined binary for serial flashing")
|
||||
|
@ -72,17 +74,22 @@ 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])
|
||||
# elif(row[0] == 'factory'):
|
||||
# factory_offset = int(row[3],base=16)
|
||||
# elif(row[0] == 'spiffs'):
|
||||
# spiffs_offset = int(row[3],base=16)
|
||||
|
||||
|
||||
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)
|
||||
if not os.path.exists(variants_dir):
|
||||
os.makedirs(variants_dir)
|
||||
if("safemode" in firmware_name):
|
||||
esp32_copy_new_safemode_bin(chip,firmware_name)
|
||||
else:
|
||||
esp32_fetch_safemode_bin(chip)
|
||||
flash_size = env.BoardConfig().get("upload.flash_size")
|
||||
cmd = [
|
||||
"--chip",
|
||||
|
@ -100,16 +107,12 @@ 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]
|
||||
# "main" firmware to app0 - mandatory, except we just built a new safemode bin locally
|
||||
if("safemode" not in firmware_name):
|
||||
print(f" - {hex(app_offset)} | {firmware_name}")
|
||||
cmd += [hex(app_offset), firmware_name]
|
||||
else:
|
||||
print("Upload new safemode binary only")
|
||||
|
||||
#print('Using esptool.py arguments: %s' % ' '.join(cmd))
|
||||
|
||||
|
|
|
@ -118,6 +118,7 @@ lib_ignore =
|
|||
|
||||
[env:tasmota32-safemode]
|
||||
extends = env:tasmota32_base
|
||||
board = esp32_4M_2APP
|
||||
build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_SAFEMODE
|
||||
lib_extra_dirs = lib/lib_ssl, lib/libesp32
|
||||
lib_ignore =
|
||||
|
@ -128,7 +129,7 @@ lib_ignore =
|
|||
|
||||
[env:tasmota32s2-safemode]
|
||||
extends = env:tasmota32_base
|
||||
board = esp32s2
|
||||
board = esp32s2_2APP
|
||||
build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_SAFEMODE
|
||||
lib_extra_dirs = lib/lib_ssl, lib/libesp32
|
||||
lib_ignore =
|
||||
|
@ -139,7 +140,7 @@ lib_ignore =
|
|||
|
||||
[env:tasmota32s3-safemode]
|
||||
extends = env:tasmota32_base
|
||||
board = esp32s3
|
||||
board = esp32s3_2APP
|
||||
build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_SAFEMODE
|
||||
lib_extra_dirs = lib/lib_ssl, lib/libesp32
|
||||
lib_ignore =
|
||||
|
@ -150,7 +151,7 @@ lib_ignore =
|
|||
|
||||
[env:tasmota32c3-safemode]
|
||||
extends = env:tasmota32_base
|
||||
board = esp32c3
|
||||
board = esp32c3_2APP
|
||||
build_unflags = ${env:tasmota32_base.build_unflags}
|
||||
-flto
|
||||
-mtarget-align
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
|
Loading…
Reference in New Issue