Skip to content

Commit

Permalink
use upload protocol to figure out how much flash space the bootloader…
Browse files Browse the repository at this point in the history
… occupies
  • Loading branch information
MCUdude committed Nov 6, 2023
1 parent 9450150 commit 6f8c2d7
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions builder/frameworks/arduino.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,27 @@


def get_bootloader_size():
upload_protocol = env.subst("$UPLOAD_PROTOCOL")
max_size = board.get("upload.maximum_size")
if (
build_core in ("MightyCore", "MegaCore", "MiniCore", "MajorCore", "MicroCore") and \
board.get("bootloader.type", "urboot").lower() == "urboot"
):
if upload_protocol == "urclock":
if max_size >= 65536 or board.get("build.mcu").startswith("at90can32"):
return 512
elif max_size >= 4096:
return 384
else:
return 256
else:
elif upload_protocol == "arduino":
if max_size >= 65536 or board.get("build.mcu").startswith("at90can32"):
return 1024
elif max_size > 4096 and max_size <= 32768:
return 512
elif upload_protocol == "avr109":
return 4096
elif upload_protocol == "wiring":
if max_size > 131072:
return 8192
else:
return 4096
return 0


Expand Down Expand Up @@ -145,10 +150,7 @@ def get_bootloader_size():
# Take into account bootloader size
#

if (
build_core in ("MiniCore", "MegaCore", "MightyCore", "MajorCore")
and board.get("hardware.uart", "uart0") != "no_bootloader"
):
if build_core in ("MiniCore", "MegaCore", "MightyCore", "MajorCore", "MicroCore"):
upload_section = board.get("upload")
upload_section["maximum_size"] -= board.get(
"bootloader.size", get_bootloader_size()
Expand Down

0 comments on commit 6f8c2d7

Please sign in to comment.