diff --git a/boards/AVR64DD14.json b/boards/AVR64DD14.json index f5ce226..697d90e 100644 --- a/boards/AVR64DD14.json +++ b/boards/AVR64DD14.json @@ -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" diff --git a/boards/AVR64DD20.json b/boards/AVR64DD20.json index 930c297..61ec872 100644 --- a/boards/AVR64DD20.json +++ b/boards/AVR64DD20.json @@ -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" diff --git a/boards/AVR64DD28.json b/boards/AVR64DD28.json index 7b1d1e3..31164a2 100644 --- a/boards/AVR64DD28.json +++ b/boards/AVR64DD28.json @@ -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" diff --git a/boards/AVR64DD32.json b/boards/AVR64DD32.json index 9b4b57c..e84272f 100644 --- a/boards/AVR64DD32.json +++ b/boards/AVR64DD32.json @@ -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" diff --git a/boards/curiosity_nano_da.json b/boards/curiosity_nano_da.json index fbc24bb..2715339 100644 --- a/boards/curiosity_nano_da.json +++ b/boards/curiosity_nano_da.json @@ -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" diff --git a/boards/curiosity_nano_db.json b/boards/curiosity_nano_db.json index 2b3beeb..ab4c537 100644 --- a/boards/curiosity_nano_db.json +++ b/boards/curiosity_nano_db.json @@ -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" diff --git a/builder/bootloader.py b/builder/bootloader.py index e286e30..fbd9680 100644 --- a/builder/bootloader.py +++ b/builder/bootloader.py @@ -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( @@ -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) @@ -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", diff --git a/builder/frameworks/arduino.py b/builder/frameworks/arduino.py index 9b255e9..d1fb2ea 100644 --- a/builder/frameworks/arduino.py +++ b/builder/frameworks/arduino.py @@ -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"]) @@ -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", diff --git a/builder/fuses.py b/builder/fuses.py index 03500b4..edda251 100644 --- a/builder/fuses.py +++ b/builder/fuses.py @@ -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", diff --git a/builder/main.py b/builder/main.py index 21a63a7..5d96b77 100644 --- a/builder/main.py +++ b/builder/main.py @@ -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 "", diff --git a/platform.json b/platform.json index c28360a..80e0a89 100644 --- a/platform.json +++ b/platform.json @@ -53,7 +53,7 @@ "framework-arduino-megaavr-dxcore": { "type": "framework", "optional": true, - "version": "~1.4.5" + "version": "~1.5.6" }, "tool-avrdude-megaavr": { "type": "uploader", diff --git a/platform.py b/platform.py index 679ba33..7dd25d6 100644 --- a/platform.py +++ b/platform.py @@ -35,7 +35,7 @@ def configure_default_packages(self, variables, targets): if build_core in ("megatinycore", "dxcore"): self.packages["toolchain-atmelavr"]["version"] = "~3.70300.0" - if build_core in ("MegaCoreX", "megatinycore"): + 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) @@ -43,7 +43,7 @@ def configure_default_packages(self, variables, targets): 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