Skip to content

Commit

Permalink
Merge branch 'release/v1.8.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
valeros committed Mar 28, 2023
2 parents ab0c685 + 3962e25 commit cd7be58
Show file tree
Hide file tree
Showing 12 changed files with 73 additions and 25 deletions.
2 changes: 1 addition & 1 deletion boards/AVR64DD14.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"extra_flags": "-DARDUINO_AVR_AVR64DD14 -DARDUINO_avrdd",
"f_cpu": "24000000L",
"mcu": "avr64dd14",
"variant": "14pin-standard"
"variant": "14pin-ddseries"
},
"hardware": {
"oscillator": "internal"
Expand Down
2 changes: 1 addition & 1 deletion boards/AVR64DD20.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"extra_flags": "-DARDUINO_AVR_AVR64DD20 -DARDUINO_avrdd",
"f_cpu": "24000000L",
"mcu": "avr64dd20",
"variant": "20pin-standard"
"variant": "20pin-ddseries"
},
"hardware": {
"oscillator": "internal"
Expand Down
2 changes: 1 addition & 1 deletion boards/AVR64DD28.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"extra_flags": "-DARDUINO_AVR_AVR64DD28 -DARDUINO_avrdd",
"f_cpu": "24000000L",
"mcu": "avr64dd28",
"variant": "28pin-standard"
"variant": "28pin-ddseries"
},
"hardware": {
"oscillator": "internal"
Expand Down
2 changes: 1 addition & 1 deletion boards/AVR64DD32.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"extra_flags": "-DARDUINO_AVR_AVR64DD32 -DARDUINO_avrdd",
"f_cpu": "24000000L",
"mcu": "avr64dd32",
"variant": "32pin-standard"
"variant": "32pin-ddseries"
},
"hardware": {
"oscillator": "internal"
Expand Down
2 changes: 1 addition & 1 deletion boards/curiosity_nano_da.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"build": {
"core": "dxcore",
"extra_flags": "-DARDUINO_AVR_AVR128DA48 -DARDUINO_avrda -DLED_BUILTIN=PIN_PC6",
"extra_flags": "-DARDUINO_AVR_AVR128DA48 -DARDUINO_avrda -DLED_BUILTIN=PIN_PC6 -DSerial=Serial1",
"f_cpu": "24000000L",
"mcu": "avr128da48",
"variant": "48pin-standard"
Expand Down
2 changes: 1 addition & 1 deletion boards/curiosity_nano_db.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"build": {
"core": "dxcore",
"extra_flags": "-DARDUINO_AVR_AVR128DB48 -DARDUINO_avrdb -DLED_BUILTIN=PIN_PB3",
"extra_flags": "-DARDUINO_AVR_AVR128DB48 -DARDUINO_avrdb -DLED_BUILTIN=PIN_PB3 -DSerial=Serial3",
"f_cpu": "24000000L",
"mcu": "avr128db48",
"variant": "48pin-standard"
Expand Down
33 changes: 32 additions & 1 deletion builder/bootloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,32 @@ def get_suitable_optiboot_binary(framework_dir, board_config):
return bootloader_path


def get_bootloader_dxcore(framework_dir, board_config):
btld = board_config.get("bootloader.class", "")
port = board_config.get("bootloader.port", "")
entry = board_config.get("bootloader.entrycond", "")

if not btld:
sys.stderr.write("Error: invalid `bootloader.class` in board config!\n")
env.Exit(1)
if not port:
sys.stderr.write("Error: invalid `bootloader.port` in board config!\n")
env.Exit(1)

bootloader_file = f"{btld}_{port}_{entry}.hex" if entry else f"{btld}_{port}.hex"

bootloader_path = os.path.join(
framework_dir,
"bootloaders",
"hex",
bootloader_file,
)

print(f"Using bootloader `{bootloader_file}`.")

return bootloader_path


framework_dir = ""
if env.get("PIOFRAMEWORK", []):
framework_dir = platform.get_package_dir(platform.frameworks[env.get(
Expand All @@ -60,6 +86,9 @@ def get_suitable_optiboot_binary(framework_dir, board_config):
sys.stderr.write("Error: `no bootloader` selected in board config!\n")
env.Exit(1)
bootloader_path = get_suitable_optiboot_binary(framework_dir, board)
elif core == "dxcore":
if not os.path.isfile(bootloader_path):
bootloader_path = get_bootloader_dxcore(framework_dir, board)
else:
if not os.path.isfile(bootloader_path):
bootloader_path = os.path.join(framework_dir, "bootloaders", bootloader_path)
Expand All @@ -83,7 +112,9 @@ def get_suitable_optiboot_binary(framework_dir, board_config):
"-C",
os.path.join(
env.PioPlatform().get_package_dir(
"tool-avrdude" if core in ("MegaCoreX", "megatinycore") else "tool-avrdude-megaavr"
"tool-avrdude"
if core in ("MegaCoreX", "megatinycore", "dxcore")
else "tool-avrdude-megaavr"
)
or "",
"avrdude.conf",
Expand Down
19 changes: 17 additions & 2 deletions builder/frameworks/arduino.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,12 @@

oscillator_type = board.get("hardware", {}).get("oscillator", "internal")
if build_core in ("megatinycore", "dxcore"):
env.Append(CPPDEFINES=[("CLOCK_SOURCE", 2 if oscillator_type == "external" else 0)])
if oscillator_type == "external":
env.Append(CPPDEFINES=[("CLOCK_SOURCE", 2)])
elif oscillator_type == "crystal":
env.Append(CPPDEFINES=[("CLOCK_SOURCE", 1)])
else:
env.Append(CPPDEFINES=[("CLOCK_SOURCE", 0)])
elif oscillator_type == "external" and build_core == "MegaCoreX":
env.Append(CPPDEFINES=["USE_EXTERNAL_OSCILLATOR"])

Expand Down Expand Up @@ -116,10 +121,20 @@
],
)
elif build_core == "dxcore":
bootloader = board.get("hardware.uart", "no_bootloader").lower()
optiboot = "" if bootloader != "no_bootloader" else ""

if board.get("hardware.mvio_enable", "no").lower() == "yes":
if "db" in board.get("build.mcu").lower():
env.Append(CPPDEFINES=["MVIO_ENABLED"])

if bootloader != "no_bootloader":
env.Append(CPPDEFINES=["USING_OPTIBOOT"])

env.Append(
CPPDEFINES=[
"TWI_MORS_SINGLE",
"MILLIS_USE_TIMERB2",
"MILLIS_USE_TIMER" + board.get("hardware.millistimer", "B2"),
],
LINKFLAGS=[
"-mrelax",
Expand Down
2 changes: 1 addition & 1 deletion builder/fuses.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def calculate_fuses(board_config, predefined_fuses):
"-C",
os.path.join(
env.PioPlatform().get_package_dir(
"tool-avrdude" if core in ("MegaCoreX", "megatinycore") else "tool-avrdude-megaavr"
"tool-avrdude" if core in ("MegaCoreX", "megatinycore", "dxcore") else "tool-avrdude-megaavr"
)
or "",
"avrdude.conf",
Expand Down
2 changes: 1 addition & 1 deletion builder/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621
join(
env.PioPlatform().get_package_dir(
"tool-avrdude"
if env.BoardConfig().get("build.core", "") in ("MegaCoreX", "megatinycore")
if env.BoardConfig().get("build.core", "") in ("MegaCoreX", "megatinycore", "dxcore")
else "tool-avrdude-megaavr"
)
or "",
Expand Down
10 changes: 8 additions & 2 deletions platform.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"type": "git",
"url": "https://github.com/platformio/platform-atmelmegaavr.git"
},
"version": "1.7.0",
"version": "1.8.0",
"frameworks": {
"arduino": {
"package": "framework-arduino-megaavr",
Expand Down Expand Up @@ -53,14 +53,20 @@
"framework-arduino-megaavr-dxcore": {
"type": "framework",
"optional": true,
"version": "~1.4.5"
"version": "~1.5.6"
},
"tool-avrdude-megaavr": {
"type": "uploader",
"optional": true,
"owner": "platformio",
"version": "~1.60300.0",
"optionalVersions": ["~3.60300.0"]
},
"tool-avrdude": {
"type": "uploader",
"optional": true,
"owner": "platformio",
"version": "~1.70100.0"
}
}
}
20 changes: 8 additions & 12 deletions platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,18 @@ def configure_default_packages(self, variables, targets):
self.packages[framework_package]["optional"] = False
self.packages["framework-arduino-megaavr"]["optional"] = True

if build_core in ("MegaCoreX", "megatinycore"):
# MegaCoreX and megatinycore require AVRDUDE v7.1 currently available
# only in atmelavr platform
self.packages.pop("tool-avrdude-megaavr", None)
self.packages["tool-avrdude"] = {
"type": "uploader",
"optional": True,
"owner": "platformio",
"version": "~1.70100.0"
}

if build_core in ("megatinycore", "dxcore"):
self.packages["toolchain-atmelavr"]["version"] = "~3.70300.0"

if build_core in ("MegaCoreX", "megatinycore", "dxcore"):
# MegaCoreX and megatinycore require AVRDUDE v7.1 currently available
# only in atmelavr platform
self.packages.pop("tool-avrdude-megaavr", None)
else:
self.packages.pop("tool-avrdude", None)

if any(t in targets for t in ("fuses", "bootloader")):
if build_core in ("MegaCoreX", "megatinycore"):
if build_core in ("MegaCoreX", "megatinycore", "dxcore"):
self.packages["tool-avrdude"]["optional"] = False
else:
self.packages["tool-avrdude-megaavr"]["optional"] = False
Expand Down

0 comments on commit cd7be58

Please sign in to comment.