diff --git a/boards/esp32c3_2APP.json b/boards/esp32c3_2APP.json index 58d029c3c..1d21ff1df 100644 --- a/boards/esp32c3_2APP.json +++ b/boards/esp32c3_2APP.json @@ -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": [ diff --git a/boards/esp32s2_2APP.json b/boards/esp32s2_2APP.json new file mode 100644 index 000000000..0227a4a11 --- /dev/null +++ b/boards/esp32s2_2APP.json @@ -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" +} diff --git a/boards/esp32s3_2APP.json b/boards/esp32s3_2APP.json new file mode 100644 index 000000000..1a37483e4 --- /dev/null +++ b/boards/esp32s3_2APP.json @@ -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" +} diff --git a/pio-tools/post_esp32.py b/pio-tools/post_esp32.py index 0207fb8ce..d149d9405 100644 --- a/pio-tools/post_esp32.py +++ b/pio-tools/post_esp32.py @@ -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)) diff --git a/platformio_tasmota_env32.ini b/platformio_tasmota_env32.ini index 16426521e..93f980e3d 100644 --- a/platformio_tasmota_env32.ini +++ b/platformio_tasmota_env32.ini @@ -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 diff --git a/safemode/placeholder b/safemode/placeholder deleted file mode 100644 index 8b1378917..000000000 --- a/safemode/placeholder +++ /dev/null @@ -1 +0,0 @@ -