@@ -93,7 +93,7 @@ def _update_max_upload_size(env):
93
93
if p ['type' ] in ("0" , "app" )
94
94
]
95
95
if sizes :
96
- env . BoardConfig () .update ("upload.maximum_size" , max (sizes ))
96
+ board .update ("upload.maximum_size" , max (sizes ))
97
97
98
98
99
99
def _to_unix_slashes (path ):
@@ -129,6 +129,7 @@ def __fetch_spiffs_size(target, source, env):
129
129
130
130
env = DefaultEnvironment ()
131
131
platform = env .PioPlatform ()
132
+ board = env .BoardConfig ()
132
133
133
134
env .Replace (
134
135
__get_board_f_flash = _get_board_f_flash ,
@@ -177,8 +178,7 @@ def __fetch_spiffs_size(target, source, env):
177
178
"elf2image" ,
178
179
"--flash_mode" , "$BOARD_FLASH_MODE" ,
179
180
"--flash_freq" , "${__get_board_f_flash(__env__)}" ,
180
- "--flash_size" , env .BoardConfig ().get (
181
- "upload.flash_size" , "detect" ),
181
+ "--flash_size" , board .get ("upload.flash_size" , "detect" ),
182
182
"-o" , "$TARGET" , "$SOURCES"
183
183
]), "Building $TARGET" ),
184
184
suffix = ".bin"
@@ -252,7 +252,7 @@ def __fetch_spiffs_size(target, source, env):
252
252
#
253
253
254
254
upload_protocol = env .subst ("$UPLOAD_PROTOCOL" )
255
- debug_tools = env . BoardConfig () .get ("debug.tools" , {})
255
+ debug_tools = board .get ("debug.tools" , {})
256
256
upload_actions = []
257
257
258
258
# Compatibility with old OTA configurations
@@ -328,27 +328,31 @@ def __fetch_spiffs_size(target, source, env):
328
328
]
329
329
330
330
elif upload_protocol in debug_tools :
331
- openocd_dir = platform .get_package_dir ("tool-openocd-esp32" ) or ""
332
- uploader_flags = ["-s" , _to_unix_slashes (openocd_dir )]
333
- if not int (ARGUMENTS .get ("PIOVERBOSE" , 0 )):
334
- uploader_flags .append ("--debug=1" )
335
- uploader_flags .extend (
331
+ openocd_args = ["-d%d" % (2 if int (ARGUMENTS .get ("PIOVERBOSE" , 0 )) else 1 )]
332
+ openocd_args .extend (
336
333
debug_tools .get (upload_protocol ).get ("server" ).get ("arguments" , []))
337
- uploader_flags .extend (["-c" , 'program_esp32 {{$SOURCE}} 0x10000 verify' ])
334
+ openocd_args .extend ([
335
+ "-c" ,
336
+ "program_esp32 {{$SOURCE}} %s verify" %
337
+ board .get ("upload.offset_address" , "0x10000" )
338
+ ])
338
339
for image in env .get ("FLASH_EXTRA_IMAGES" , []):
339
- uploader_flags .extend (
340
- ["-c" , 'program_esp32 {{%s}} %s verify' % (
341
- _to_unix_slashes (image [1 ]), image [0 ])])
342
- uploader_flags .extend (["-c" , "reset run; shutdown" ])
343
- for i , item in enumerate (uploader_flags ):
344
- if "$PACKAGE_DIR" in item :
345
- uploader_flags [i ] = item .replace (
346
- "$PACKAGE_DIR" , _to_unix_slashes (openocd_dir ))
347
-
348
- env .Replace (
349
- UPLOADER = "openocd" ,
350
- UPLOADERFLAGS = uploader_flags ,
351
- UPLOADCMD = "$UPLOADER $UPLOADERFLAGS" )
340
+ openocd_args .extend ([
341
+ "-c" ,
342
+ 'program_esp32 {{%s}} %s verify' %
343
+ (_to_unix_slashes (image [1 ]), image [0 ])
344
+ ])
345
+ openocd_args .extend (["-c" , "reset run; shutdown" ])
346
+ openocd_args = [
347
+ f .replace (
348
+ "$PACKAGE_DIR" ,
349
+ _to_unix_slashes (
350
+ platform .get_package_dir ("tool-openocd-esp32" ) or "" ))
351
+ for f in openocd_args
352
+ ]
353
+ env .Replace (UPLOADER = "openocd" ,
354
+ UPLOADERFLAGS = openocd_args ,
355
+ UPLOADCMD = "$UPLOADER $UPLOADERFLAGS" )
352
356
upload_actions = [env .VerboseAction ("$UPLOADCMD" , "Uploading $SOURCE" )]
353
357
354
358
# custom upload tool
@@ -366,7 +370,8 @@ def __fetch_spiffs_size(target, source, env):
366
370
367
371
AlwaysBuild (
368
372
env .Alias ("erase" , None , [
369
- env .VerboseAction (env .AutodetectUploadPort , "Looking for serial port..." ),
373
+ env .VerboseAction (env .AutodetectUploadPort ,
374
+ "Looking for serial port..." ),
370
375
env .VerboseAction ("$ERASECMD" , "Erasing..." )
371
376
]))
372
377
0 commit comments