Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve DxCore support #48

Merged
merged 34 commits into from
Mar 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
e9506f3
add EA boards
brunob45 Aug 20, 2022
a84acf4
add build.millistimer option
brunob45 Aug 20, 2022
b9953dd
fix curiosity_nano_dx
brunob45 Aug 20, 2022
4152751
begin work to upload bootloader to AVR Dx
brunob45 Aug 21, 2022
42a0d0d
change bootloader based on mcu_size
brunob45 Aug 21, 2022
069ddf2
use optiboot by default
brunob45 Aug 21, 2022
41c3839
add default hardware_serial for curiosity
brunob45 Aug 21, 2022
db5cb43
dxcore serial can use both serialx and serx
brunob45 Aug 21, 2022
906bfc3
move millistimer to hardware
brunob45 Aug 21, 2022
4a13e72
move default millistimer to arduino.py
brunob45 Aug 21, 2022
93724fe
use hardware.uart to define Serial#
brunob45 Aug 21, 2022
585fff2
print the selected bootloader
brunob45 Aug 21, 2022
1cab600
AVR-DD uses specific variant
brunob45 Aug 22, 2022
1d1a27f
add MVIO_ENABLED cppdefine if enabled
brunob45 Aug 22, 2022
fc1bbd8
define USING_OPTIBOOT only if using bootloader
brunob45 Aug 22, 2022
d47bdd5
remove bootloader definition for curiosity nano
brunob45 Aug 22, 2022
3e58ea0
Serial links to CDC Serial for curiosity nano boards
brunob45 Aug 22, 2022
5bc6ce1
disable -DUSING_OPTIBOOT by default
brunob45 Aug 22, 2022
2c7007c
add oscillator=crystal
brunob45 Aug 22, 2022
40952d9
improve the MVIO condition readability
brunob45 Aug 22, 2022
dca1c16
Merge remote-tracking branch 'upstream/master' into dev/avrea
brunob45 Feb 10, 2023
aa80455
dxcore needs new version of avrdude
brunob45 Feb 10, 2023
e5ca771
remove AVR-DD and EA boards
brunob45 Feb 10, 2023
10d53d3
Minor improvements
valeros Mar 22, 2023
fa178de
Sync with latest changes
valeros Mar 22, 2023
3c487dd
Merge branch 'develop' into dev/avrea
valeros Mar 22, 2023
8eeb453
update platform revision
brunob45 Mar 23, 2023
976c8cc
fix avr dd series variant
brunob45 Mar 23, 2023
ce38586
fix MVIO support
brunob45 Mar 23, 2023
c2b6e5f
fix bootloader for dxcore
brunob45 Mar 23, 2023
3b6385d
add check for valid bootloader class and port
brunob45 Mar 24, 2023
4078c61
run black on bootloader.py
brunob45 Mar 24, 2023
7d17f51
Minor style fixes
valeros Mar 27, 2023
6bf1a62
Update dxcore package to v1.5.6
valeros Mar 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion platform.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ 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)
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