diff --git a/boards/avr_iot_wg.json b/boards/avr_iot_wg.json index 04cb5aa..14043ea 100644 --- a/boards/avr_iot_wg.json +++ b/boards/avr_iot_wg.json @@ -16,7 +16,7 @@ "upload": { "maximum_ram_size": 6144, "maximum_size": 49152, - "protocol": "curiosity_updi" + "protocol": "pkobn_updi" }, "url": "https://www.microchip.com/developmenttools/ProductDetails/AC164160", "vendor": "Microchip" diff --git a/boards/curiosity_nano_4809.json b/boards/curiosity_nano_4809.json index 501b2f5..c5ae330 100644 --- a/boards/curiosity_nano_4809.json +++ b/boards/curiosity_nano_4809.json @@ -16,7 +16,7 @@ "upload": { "maximum_ram_size": 6144, "maximum_size": 49152, - "protocol": "curiosity_updi" + "protocol": "pkobn_updi" }, "url": "https://www.microchip.com/developmenttools/ProductDetails/DM320115", "vendor": "Microchip" diff --git a/builder/bootloader.py b/builder/bootloader.py index ebba454..e286e30 100644 --- a/builder/bootloader.py +++ b/builder/bootloader.py @@ -81,8 +81,13 @@ def get_suitable_optiboot_binary(framework_dir, board_config): "-p", "$BOARD_MCU", "-C", - os.path.join(env.PioPlatform().get_package_dir( - "tool-avrdude-megaavr") or "", "avrdude.conf"), + os.path.join( + env.PioPlatform().get_package_dir( + "tool-avrdude" if core in ("MegaCoreX", "megatinycore") else "tool-avrdude-megaavr" + ) + or "", + "avrdude.conf", + ), ], BOOTFLAGS=["-U", "flash:w:%s:i" % bootloader_path], UPLOADBOOTCMD="$BOOTUPLOADER $BOOTUPLOADERFLAGS $UPLOAD_FLAGS $BOOTFLAGS", diff --git a/builder/frameworks/arduino.py b/builder/frameworks/arduino.py index 9415929..9b255e9 100644 --- a/builder/frameworks/arduino.py +++ b/builder/frameworks/arduino.py @@ -26,6 +26,8 @@ from SCons.Script import DefaultEnvironment +from platformio.package.version import pepver_to_semver + env = DefaultEnvironment() platform = env.PioPlatform() board = env.BoardConfig() @@ -78,19 +80,18 @@ # if build_core in ("dxcore", "megatinycore"): - package_version = platform.get_package_version( + package_version = pepver_to_semver(platform.get_package_version( "framework-arduino-megaavr-%s" % build_core - ) - major, minor, patch = package_version.split(".") + )) core_macro_name = build_core.upper() env.Append( CCFLAGS=["-mrelax"], CPPDEFINES=[ (core_macro_name, '\\"%s\\"' % package_version), - ("%s_MAJOR" % core_macro_name, "%sUL" % major), - ("%s_MINOR" % core_macro_name, "%sUL" % minor), - ("%s_PATCH" % core_macro_name, "%sUL" % patch), + ("%s_MAJOR" % core_macro_name, "%sUL" % package_version.major), + ("%s_MINOR" % core_macro_name, "%sUL" % package_version.minor), + ("%s_PATCH" % core_macro_name, "%sUL" % package_version.patch), ("%s_RELEASED" % core_macro_name, 1), "CORE_ATTACH_ALL", ] diff --git a/builder/fuses.py b/builder/fuses.py index b98ba42..03500b4 100644 --- a/builder/fuses.py +++ b/builder/fuses.py @@ -223,7 +223,10 @@ def calculate_fuses(board_config, predefined_fuses): "$BOARD_MCU", "-C", os.path.join( - env.PioPlatform().get_package_dir("tool-avrdude-megaavr") or "", + env.PioPlatform().get_package_dir( + "tool-avrdude" if core in ("MegaCoreX", "megatinycore") else "tool-avrdude-megaavr" + ) + or "", "avrdude.conf", ), ], diff --git a/builder/main.py b/builder/main.py index 06970d8..21a63a7 100644 --- a/builder/main.py +++ b/builder/main.py @@ -73,8 +73,15 @@ def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621 UPLOADER="avrdude", UPLOADERFLAGS=[ "-p", "$BOARD_MCU", "-C", - join(env.PioPlatform().get_package_dir( - "tool-avrdude-megaavr") or "", "avrdude.conf"), + join( + env.PioPlatform().get_package_dir( + "tool-avrdude" + if env.BoardConfig().get("build.core", "") in ("MegaCoreX", "megatinycore") + else "tool-avrdude-megaavr" + ) + or "", + "avrdude.conf", + ), "-c", "$UPLOAD_PROTOCOL" ], UPLOADCMD="$UPLOADER $UPLOADERFLAGS -U flash:w:$SOURCES:i", diff --git a/examples/arduino-blink/.gitignore b/examples/arduino-blink/.gitignore index 6c69f4c..03f4a3c 100644 --- a/examples/arduino-blink/.gitignore +++ b/examples/arduino-blink/.gitignore @@ -1,2 +1 @@ -.pioenvs -.piolibdeps +.pio diff --git a/examples/arduino-external-libs/.gitignore b/examples/arduino-external-libs/.gitignore index 6c69f4c..03f4a3c 100644 --- a/examples/arduino-external-libs/.gitignore +++ b/examples/arduino-external-libs/.gitignore @@ -1,2 +1 @@ -.pioenvs -.piolibdeps +.pio diff --git a/examples/arduino-internal-libs/.gitignore b/examples/arduino-internal-libs/.gitignore index 6c69f4c..03f4a3c 100644 --- a/examples/arduino-internal-libs/.gitignore +++ b/examples/arduino-internal-libs/.gitignore @@ -1,2 +1 @@ -.pioenvs -.piolibdeps +.pio diff --git a/examples/native-blink/.gitignore b/examples/native-blink/.gitignore index 6c69f4c..03f4a3c 100644 --- a/examples/native-blink/.gitignore +++ b/examples/native-blink/.gitignore @@ -1,2 +1 @@ -.pioenvs -.piolibdeps +.pio diff --git a/platform.json b/platform.json index 32f740e..40e9e47 100644 --- a/platform.json +++ b/platform.json @@ -18,7 +18,7 @@ "type": "git", "url": "https://github.com/platformio/platform-atmelmegaavr.git" }, - "version": "1.6.0", + "version": "1.7.0", "frameworks": { "arduino": { "package": "framework-arduino-megaavr", @@ -42,13 +42,13 @@ "type": "framework", "optional": true, "owner": "platformio", - "version": "~1.0.10" + "version": "~1.1.1" }, "framework-arduino-megaavr-megatinycore": { "type": "framework", "optional": true, "owner": "platformio", - "version": "~2.5.0" + "version": "~2.6.5" }, "framework-arduino-megaavr-dxcore": { "type": "framework", diff --git a/platform.py b/platform.py index 4ae4b8e..f48abb5 100644 --- a/platform.py +++ b/platform.py @@ -32,12 +32,25 @@ 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", "dxcore"): + 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" - self.packages["tool-avrdude-megaavr"]["version"] = "~3.60300.0" if any(t in targets for t in ("fuses", "bootloader")): - self.packages["tool-avrdude-megaavr"]["optional"] = False + if build_core in ("MegaCoreX", "megatinycore"): + self.packages["tool-avrdude"]["optional"] = False + else: + self.packages["tool-avrdude-megaavr"]["optional"] = False return super().configure_default_packages( variables, targets)