25
25
# Extends: https://github.com/platformio/platform-espressif32/blob/develop/builder/main.py
26
26
27
27
from os .path import abspath , basename , isdir , isfile , join
28
- from copy import deepcopy
29
28
from SCons .Script import DefaultEnvironment , SConscript
30
29
31
30
env = DefaultEnvironment ()
37
36
)
38
37
39
38
FRAMEWORK_DIR = platform .get_package_dir ("framework-arduinoespressif32" )
40
- FRAMEWORK_LIBS_DIR = platform . get_package_dir ( "framework-arduinoespressif32 -libs" )
39
+ FRAMEWORK_LIBS_DIR = join ( FRAMEWORK_DIR , "tools" , "esp32-arduino -libs" )
41
40
assert isdir (FRAMEWORK_DIR )
42
41
43
42
@@ -101,8 +100,9 @@ def generate_bootloader_image(bootloader_elf):
101
100
env .VerboseAction (" " .join ([
102
101
'"$PYTHONEXE" "$OBJCOPY"' ,
103
102
"--chip" , build_mcu , "elf2image" ,
103
+ "--dont-append-digest" ,
104
104
"--flash_mode" , "${__get_board_flash_mode(__env__)}" ,
105
- "--flash_freq" , "${__get_board_f_flash (__env__)}" ,
105
+ "--flash_freq" , "${__get_board_img_freq (__env__)}" ,
106
106
"--flash_size" , board_config .get ("upload.flash_size" , "4MB" ),
107
107
"-o" , "$TARGET" , "$SOURCES"
108
108
]), "Building $TARGET" ),
@@ -176,9 +176,14 @@ def add_tinyuf2_extra_image():
176
176
libs = []
177
177
178
178
variants_dir = join (FRAMEWORK_DIR , "variants" )
179
+ try :
180
+ build_variants_dir = join (board_config .get ("build.variants_dir" ))
181
+ except :
182
+ build_variants_dir = ""
179
183
180
184
if "build.variants_dir" in board_config :
181
- variants_dir = join ("$PROJECT_DIR" , board_config .get ("build.variants_dir" ))
185
+ if len (build_variants_dir ) > 1 :
186
+ variants_dir = join ("$PROJECT_DIR" , board_config .get ("build.variants_dir" ))
182
187
183
188
if "build.variant" in board_config :
184
189
env .Append (CPPPATH = [join (variants_dir , board_config .get ("build.variant" ))])
@@ -201,6 +206,15 @@ def add_tinyuf2_extra_image():
201
206
# Process framework extra images
202
207
#
203
208
209
+ # Tasmota places extra images "safeboot" in custom variants folder in project directory
210
+ build_name = join (board_config .get ("name" ))
211
+ if len (build_variants_dir ) > 1 :
212
+ EXTRA_IMG_DIR = join (variants_dir )
213
+ else :
214
+ EXTRA_IMG_DIR = FRAMEWORK_DIR
215
+ if "tasmota" in build_name .lower ():
216
+ EXTRA_IMG_DIR = join (EXTRA_IMG_DIR , "variants" , "tasmota" )
217
+
204
218
env .Append (
205
219
LIBSOURCE_DIRS = [join (FRAMEWORK_DIR , "libraries" )],
206
220
FLASH_EXTRA_IMAGES = [
@@ -212,7 +226,7 @@ def add_tinyuf2_extra_image():
212
226
("0xe000" , join (FRAMEWORK_DIR , "tools" , "partitions" , "boot_app0.bin" )),
213
227
]
214
228
+ [
215
- (offset , join (FRAMEWORK_DIR , img ))
229
+ (offset , join (EXTRA_IMG_DIR , img ))
216
230
for offset , img in board_config .get ("upload.arduino.flash_extra_images" , [])
217
231
],
218
232
)
@@ -239,13 +253,3 @@ def add_tinyuf2_extra_image():
239
253
),
240
254
)
241
255
env .Depends ("$BUILD_DIR/$PROGNAME$PROGSUFFIX" , partition_table )
242
-
243
- #
244
- # Adjust the `esptoolpy` command in the `ElfToBin` builder with firmware checksum offset
245
- #
246
-
247
- action = deepcopy (env ["BUILDERS" ]["ElfToBin" ].action )
248
- action .cmd_list = env ["BUILDERS" ]["ElfToBin" ].action .cmd_list .replace (
249
- "-o" , "--elf-sha256-offset 0xb0 -o"
250
- )
251
- env ["BUILDERS" ]["ElfToBin" ].action = action
0 commit comments