Skip to content

Commit

Permalink
Refactoring of storing safeboot bin (#19858)
Browse files Browse the repository at this point in the history
* Folder for storing safeboot is now configurable
* Platform 2023.10.06
* Platform 2023.10.12
  • Loading branch information
Jason2866 authored Oct 28, 2023
1 parent dfa6f9a commit 75ec9da
Show file tree
Hide file tree
Showing 22 changed files with 48 additions and 23 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ data
unpacked_fs
unpacked_boards
tasmota/user_config_override.h
variants
variants3
build
build_output/*
firmware.map
Expand Down
2 changes: 1 addition & 1 deletion boards/esp32-fix.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"flash_extra_images": [
[
"0x10000",
"variants/tasmota/tasmota32-safeboot.bin"
"tasmota32-safeboot.bin"
]
]
},
Expand Down
2 changes: 1 addition & 1 deletion boards/esp32.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"flash_extra_images": [
[
"0x10000",
"variants/tasmota/tasmota32-safeboot.bin"
"tasmota32-safeboot.bin"
]
]
},
Expand Down
2 changes: 1 addition & 1 deletion boards/esp32_solo1.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"flash_extra_images": [
[
"0x10000",
"variants/tasmota/tasmota32solo1-safeboot.bin"
"tasmota32solo1-safeboot.bin"
]
]
},
Expand Down
2 changes: 1 addition & 1 deletion boards/esp32c2.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"flash_extra_images": [
[
"0x10000",
"variants/tasmota/tasmota32c2-safeboot.bin"
"tasmota32c2-safeboot.bin"
]
]
},
Expand Down
2 changes: 1 addition & 1 deletion boards/esp32c2_2M.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"flash_extra_images": [
[
"0x10000",
"variants/tasmota/tasmota32c2-safeboot.bin"
"tasmota32c2-safeboot.bin"
]
]
},
Expand Down
2 changes: 1 addition & 1 deletion boards/esp32c3.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"flash_extra_images": [
[
"0x10000",
"variants/tasmota/tasmota32c3-safeboot.bin"
"tasmota32c3-safeboot.bin"
]
]
},
Expand Down
2 changes: 1 addition & 1 deletion boards/esp32c3cdc.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"flash_extra_images": [
[
"0x10000",
"variants/tasmota/tasmota32c3cdc-safeboot.bin"
"tasmota32c3cdc-safeboot.bin"
]
]
},
Expand Down
2 changes: 1 addition & 1 deletion boards/esp32c6.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"flash_extra_images": [
[
"0x10000",
"variants/tasmota/tasmota32c6-safeboot.bin"
"tasmota32c6-safeboot.bin"
]
]
},
Expand Down
2 changes: 1 addition & 1 deletion boards/esp32c6cdc.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"flash_extra_images": [
[
"0x10000",
"variants/tasmota/tasmota32c6cdc-safeboot.bin"
"tasmota32c6cdc-safeboot.bin"
]
]
},
Expand Down
2 changes: 1 addition & 1 deletion boards/esp32s2.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"flash_extra_images": [
[
"0x10000",
"variants/tasmota/tasmota32s2-safeboot.bin"
"tasmota32s2-safeboot.bin"
]
]
},
Expand Down
2 changes: 1 addition & 1 deletion boards/esp32s2cdc.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"flash_extra_images": [
[
"0x10000",
"variants/tasmota/tasmota32s2cdc-safeboot.bin"
"tasmota32s2cdc-safeboot.bin"
]
]
},
Expand Down
2 changes: 1 addition & 1 deletion boards/esp32s3-qio_opi.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"flash_extra_images": [
[
"0x10000",
"variants/tasmota/tasmota32s3-safeboot.bin"
"tasmota32s3-safeboot.bin"
]
]
},
Expand Down
2 changes: 1 addition & 1 deletion boards/esp32s3-qio_qspi.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"flash_extra_images": [
[
"0x10000",
"variants/tasmota/tasmota32s3-safeboot.bin"
"tasmota32s3-safeboot.bin"
]
]
},
Expand Down
2 changes: 1 addition & 1 deletion boards/esp32s3cdc-qio_opi.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"flash_extra_images": [
[
"0x10000",
"variants/tasmota/tasmota32s3cdc-safeboot.bin"
"tasmota32s3cdc-safeboot.bin"
]
]
},
Expand Down
2 changes: 1 addition & 1 deletion boards/esp32s3cdc-qio_qspi.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"flash_extra_images": [
[
"0x10000",
"variants/tasmota/tasmota32s3cdc-safeboot.bin"
"tasmota32s3cdc-safeboot.bin"
]
]
},
Expand Down
30 changes: 25 additions & 5 deletions pio-tools/post_esp32.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# - 0x1000 | ~\.platformio\packages\framework-arduinoespressif32\tools\sdk\esp32\bin\bootloader_dout_40m.bin
# - 0x8000 | ~\Tasmota\.pio\build\<env name>\partitions.bin
# - 0xe000 | ~\.platformio\packages\framework-arduinoespressif32\tools\partitions\boot_app0.bin
# - 0x10000 | ~\.platformio/packages/framework-arduinoespressif32/variants/tasmota/\<env name>-safeboot.bin
# - 0x10000 | ~\Tasmota\<variants_dir>/<env name>-safeboot.bin
# - 0xe0000 | ~\Tasmota\.pio\build\<env name>/firmware.bin
# - 0x3b0000| ~\Tasmota\.pio\build\<env name>/littlefs.bin

Expand All @@ -37,6 +37,13 @@
sys.path.append(join(platform.get_package_dir("tool-esptoolpy")))
import esptool

variants_dir = env.BoardConfig().get("build.variants_dir", "")
variant = env.BoardConfig().get("build.variant", "")
sections = env.subst(env.get("FLASH_EXTRA_IMAGES"))
chip = env.get("BOARD_MCU")
mcu_build_variant = env.BoardConfig().get("build.variant", "").lower()

# Copy safeboots firmwares in place when running in Github
github_actions = os.getenv('GITHUB_ACTIONS')
extra_flags = ''.join([element.replace("-D", " ") for element in env.BoardConfig().get("build.extra_flags", "")])
build_flags = ''.join([element.replace("-D", " ") for element in env.GetProjectOption("build_flags")])
Expand All @@ -45,16 +52,31 @@
FRAMEWORK_DIR = platform.get_package_dir("framework-arduino-solo1")
if github_actions and os.path.exists("./firmware/firmware"):
shutil.copytree("./firmware/firmware", "/home/runner/.platformio/packages/framework-arduino-solo1/variants/tasmota")
if variants_dir:
shutil.copytree("./firmware/firmware", variants_dir, dirs_exist_ok=True)
elif "CORE32ITEAD" in extra_flags or "FRAMEWORK_ARDUINO_ITEAD" in build_flags:
FRAMEWORK_DIR = platform.get_package_dir("framework-arduino-ITEAD")
if github_actions and os.path.exists("./firmware/firmware"):
shutil.copytree("./firmware/firmware", "/home/runner/.platformio/packages/framework-arduino-ITEAD/variants/tasmota")
if variants_dir:
shutil.copytree("./firmware/firmware", variants_dir, dirs_exist_ok=True)
else:
FRAMEWORK_DIR = platform.get_package_dir("framework-arduinoespressif32")
if github_actions and os.path.exists("./firmware/firmware"):
shutil.copytree("./firmware/firmware", "/home/runner/.platformio/packages/framework-arduinoespressif32/variants/tasmota")
if variants_dir:
shutil.copytree("./firmware/firmware", variants_dir, dirs_exist_ok=True)

# Copy pins_arduino.h to variants folder
if variants_dir:
mcu_build_variant_path = join(FRAMEWORK_DIR, "variants", mcu_build_variant, "pins_arduino.h")
custom_variant_build = join(env.subst("$PROJECT_DIR"), variants_dir , mcu_build_variant, "pins_arduino.h")
os.makedirs(join(env.subst("$PROJECT_DIR"), variants_dir , mcu_build_variant), exist_ok=True)
shutil.copy(mcu_build_variant_path, custom_variant_build)

variants_dir = join(FRAMEWORK_DIR, "variants", "tasmota")
if not variants_dir:
variants_dir = join(FRAMEWORK_DIR, "variants", "tasmota")
env.BoardConfig().update("build.variants_dir", variants_dir)

def esp32_detect_flashsize():
uploader = env.subst("$UPLOADER")
Expand Down Expand Up @@ -195,9 +217,7 @@ def esp32_create_combined_bin(source, target, env):


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")
tasmota_platform = esp32_create_chip_string(chip)

if "-DUSE_USB_CDC_CONSOLE" in env.BoardConfig().get("build.extra_flags") and "cdc" not in tasmota_platform:
Expand Down Expand Up @@ -274,8 +294,8 @@ def esp32_create_combined_bin(source, target, env):
)
print("Will use custom upload command for flashing operation to add file system defined for this build target.")

#print('Using esptool.py arguments: %s' % ' '.join(cmd))
if("safeboot" not in firmware_name):
#print('Using esptool.py arguments: %s' % ' '.join(cmd))
esptool.main(cmd)


Expand Down
1 change: 1 addition & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ platform_packages = ${core.platform_packages}
framework = arduino
board = esp8266_1M
board_build.filesystem = littlefs
board_build.variants_dir = variants/tasmota
custom_unpack_dir = unpacked_littlefs
build_unflags = ${core.build_unflags}
build_flags = ${core.build_flags}
Expand Down
2 changes: 1 addition & 1 deletion platformio_tasmota32.ini
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ lib_ignore = ${esp32_defaults.lib_ignore}
ccronexpr

[core32]
platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.10.05/platform-espressif32.zip
platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.10.06/platform-espressif32.zip
platform_packages =
build_unflags = ${esp32_defaults.build_unflags}
build_flags = ${esp32_defaults.build_flags}
3 changes: 2 additions & 1 deletion platformio_tasmota_core3_env_sample.ini
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
; tasmota32c6cdc-safeboot

[core32_30]
platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.10.11/platform-espressif32.zip
platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.10.12/platform-espressif32.zip
platform_packages =

build_unflags = ${core32.build_unflags}
Expand Down Expand Up @@ -50,6 +50,7 @@ framework = ${common.framework}
platform = ${core32_30.platform}
platform_packages = ${core32_30.platform_packages}
board_build.filesystem = ${common.board_build.filesystem}
board_build.variants_dir = variants/tasmota_ard3
custom_unpack_dir = ${common.custom_unpack_dir}
board = esp32
monitor_speed = 115200
Expand Down
1 change: 1 addition & 0 deletions platformio_tasmota_env32.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ platform = ${core32.platform}
platform_packages = ${core32.platform_packages}
board_build.filesystem = ${common.board_build.filesystem}
custom_unpack_dir = ${common.custom_unpack_dir}
board_build.variants_dir = ${common.board_build.variants_dir}
board = esp32
monitor_speed = ${common.monitor_speed}
monitor_echo = ${common.monitor_echo}
Expand Down
2 changes: 1 addition & 1 deletion tasmota/tasmota.ino
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ bool tasconsole_serial = false;

#if ARDUINO_USB_MODE
//#warning **** TasConsole ARDUINO_USB_MODE ****
TASCONSOLE TasConsole{USBSerial}; // ESP32C3/C6/S3 embedded USB using JTAG interface
TASCONSOLE TasConsole{HWCDCSerial}; // ESP32C3/C6/S3 embedded USB using JTAG interface
//#warning **** TasConsole uses HWCDC ****
#else // No ARDUINO_USB_MODE
#include "USB.h"
Expand Down

0 comments on commit 75ec9da

Please sign in to comment.