@@ -322,46 +322,6 @@ def __fetch_fs_size(target, source, env):
322322 "Calculate program size" ,
323323)
324324
325- # Arduino core v2.0.4 contains updated bootloader images that have innacurate default
326- # headers. This results in bootloops if firmware is flashed via OpenOCD (e.g. debugging
327- # or uploading via debug tools). For this reason, before uploading or debugging we need
328- # to adjust the bootloader binary according to --flash-size and --flash-mode arguments.
329- # Note: This behavior doesn't occur if uploading is done via esptoolpy, as esptoolpy
330- # overrides the binary image headers before flashing.
331- bootloader_patch_required = bool (
332- env .get ("PIOFRAMEWORK" , []) == ["arduino" ]
333- and (
334- "debug" in env .GetBuildType ()
335- or env .subst ("$UPLOAD_PROTOCOL" ) in board .get ("debug.tools" , {})
336- )
337- )
338-
339- if bootloader_patch_required :
340- result = []
341- for offset , image in env .get ("FLASH_EXTRA_IMAGES" , []):
342- # 0x1000 for ESP32/S2, 0x0 for others
343- default_bootloader_offsets = ("0x0" , "0x0000" , "0x1000" )
344- if offset in default_bootloader_offsets :
345- original_bootloader_path = env .subst (image )
346- image = join (env .subst ("$BUILD_DIR" ), "patched_bootloader.bin" )
347- env .AddPreAction (
348- target_elf ,
349- env .VerboseAction (" " .join ([
350- '"$PYTHONEXE"' ,
351- join (platform .get_package_dir ("tool-esptoolpy" ) or "" , "esptool.py" ),
352- "--chip" , mcu , "merge_bin" ,
353- "-o" , '"%s"' % image ,
354- "--flash_mode" , _get_board_flash_mode (env ),
355- "--flash_size" , board .get ("upload.flash_size" , "4MB" ),
356- "--target-offset" , offset ,
357- offset , '"%s"' % original_bootloader_path
358- ]), "Updating bootloader headers" )
359- )
360-
361- result .append ((offset , image ))
362-
363- env .Replace (FLASH_EXTRA_IMAGES = result )
364-
365325#
366326# Target: Upload firmware or FS image
367327#
0 commit comments