diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index 85a0588..d55f793 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -8,7 +8,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-16.04, windows-latest, macos-latest] - python-version: [2.7, 3.7] + python-version: [3.7] example: - "examples/arduino-blink" - "examples/arduino-external-libs" diff --git a/boards/ATtiny1604.json b/boards/ATtiny1604.json new file mode 100644 index 0000000..e05a66c --- /dev/null +++ b/boards/ATtiny1604.json @@ -0,0 +1,24 @@ +{ + "build": { + "core": "megatinycore", + "extra_flags": "-DARDUINO_attinyxy4 -DMILLIS_USE_TIMERA0 -DUARTBAUD5V", + "f_cpu": "16000000L", + "mcu": "attiny1604", + "variant": "txy4" + }, + "hardware": { + "oscillator": "internal" + }, + "frameworks": [ + "arduino" + ], + "name": "ATtiny1604", + "upload": { + "maximum_ram_size": 1024, + "maximum_size": 16384, + "protocol": "jtag2updi", + "speed": 115200 + }, + "url": "https://www.microchip.com/wwwproducts/en/ATTINY1604", + "vendor": "Microchip" +} diff --git a/boards/ATtiny1606.json b/boards/ATtiny1606.json new file mode 100644 index 0000000..729d237 --- /dev/null +++ b/boards/ATtiny1606.json @@ -0,0 +1,24 @@ +{ + "build": { + "core": "megatinycore", + "extra_flags": "-DARDUINO_attinyxy6 -DMILLIS_USE_TIMERA0 -DUARTBAUD5V", + "f_cpu": "16000000L", + "mcu": "attiny1606", + "variant": "txy6" + }, + "hardware": { + "oscillator": "internal" + }, + "frameworks": [ + "arduino" + ], + "name": "ATtiny1606", + "upload": { + "maximum_ram_size": 1024, + "maximum_size": 16384, + "protocol": "jtag2updi", + "speed": 115200 + }, + "url": "https://www.microchip.com/wwwproducts/en/ATTINY1606", + "vendor": "Microchip" +} diff --git a/boards/ATtiny1607.json b/boards/ATtiny1607.json new file mode 100644 index 0000000..c3f11ab --- /dev/null +++ b/boards/ATtiny1607.json @@ -0,0 +1,24 @@ +{ + "build": { + "core": "megatinycore", + "extra_flags": "-DARDUINO_attinyxy7 -DMILLIS_USE_TIMERA0 -DUARTBAUD5V", + "f_cpu": "16000000L", + "mcu": "attiny1607", + "variant": "txy7" + }, + "hardware": { + "oscillator": "internal" + }, + "frameworks": [ + "arduino" + ], + "name": "ATtiny1607", + "upload": { + "maximum_ram_size": 1024, + "maximum_size": 16384, + "protocol": "jtag2updi", + "speed": 115200 + }, + "url": "https://www.microchip.com/wwwproducts/en/ATTINY1607", + "vendor": "Microchip" +} diff --git a/boards/ATtiny1614.json b/boards/ATtiny1614.json new file mode 100644 index 0000000..4a5746e --- /dev/null +++ b/boards/ATtiny1614.json @@ -0,0 +1,24 @@ +{ + "build": { + "core": "megatinycore", + "extra_flags": "-DARDUINO_attinyxy4 -DMILLIS_USE_TIMERD0 -DUARTBAUD5V", + "f_cpu": "16000000L", + "mcu": "attiny1614", + "variant": "txy4" + }, + "hardware": { + "oscillator": "internal" + }, + "frameworks": [ + "arduino" + ], + "name": "ATtiny1614", + "upload": { + "maximum_ram_size": 2048, + "maximum_size": 16384, + "protocol": "jtag2updi", + "speed": 115200 + }, + "url": "https://www.microchip.com/wwwproducts/en/ATTINY1614", + "vendor": "Microchip" +} diff --git a/boards/ATtiny1616.json b/boards/ATtiny1616.json new file mode 100644 index 0000000..a69fce8 --- /dev/null +++ b/boards/ATtiny1616.json @@ -0,0 +1,24 @@ +{ + "build": { + "core": "megatinycore", + "extra_flags": "-DARDUINO_attinyxy6 -DMILLIS_USE_TIMERD0 -DUARTBAUD5V", + "f_cpu": "16000000L", + "mcu": "attiny1616", + "variant": "txy6" + }, + "hardware": { + "oscillator": "internal" + }, + "frameworks": [ + "arduino" + ], + "name": "ATtiny1616", + "upload": { + "maximum_ram_size": 2048, + "maximum_size": 16384, + "protocol": "jtag2updi", + "speed": 115200 + }, + "url": "https://www.microchip.com/wwwproducts/en/ATTINY1616", + "vendor": "Microchip" +} diff --git a/boards/ATtiny1617.json b/boards/ATtiny1617.json new file mode 100644 index 0000000..582d158 --- /dev/null +++ b/boards/ATtiny1617.json @@ -0,0 +1,24 @@ +{ + "build": { + "core": "megatinycore", + "extra_flags": "-DARDUINO_attinyxy7 -DMILLIS_USE_TIMERD0 -DUARTBAUD5V", + "f_cpu": "16000000L", + "mcu": "attiny1617", + "variant": "txy7" + }, + "hardware": { + "oscillator": "internal" + }, + "frameworks": [ + "arduino" + ], + "name": "ATtiny1617", + "upload": { + "maximum_ram_size": 2048, + "maximum_size": 16384, + "protocol": "jtag2updi", + "speed": 115200 + }, + "url": "https://www.microchip.com/wwwproducts/en/ATTINY1617", + "vendor": "Microchip" +} diff --git a/boards/ATtiny202.json b/boards/ATtiny202.json new file mode 100644 index 0000000..d353904 --- /dev/null +++ b/boards/ATtiny202.json @@ -0,0 +1,24 @@ +{ + "build": { + "core": "megatinycore", + "extra_flags": "-DARDUINO_attinyxy2 -DMILLIS_USE_TIMERA0 -DUARTBAUD5V", + "f_cpu": "16000000L", + "mcu": "attiny202", + "variant": "txy2" + }, + "hardware": { + "oscillator": "internal" + }, + "frameworks": [ + "arduino" + ], + "name": "ATtiny202", + "upload": { + "maximum_ram_size": 128, + "maximum_size": 2048, + "protocol": "jtag2updi", + "speed": 115200 + }, + "url": "https://www.microchip.com/wwwproducts/en/ATTINY202", + "vendor": "Microchip" +} diff --git a/boards/ATtiny204.json b/boards/ATtiny204.json new file mode 100644 index 0000000..fd4f431 --- /dev/null +++ b/boards/ATtiny204.json @@ -0,0 +1,24 @@ +{ + "build": { + "core": "megatinycore", + "extra_flags": "-DARDUINO_attinyxy4 -DMILLIS_USE_TIMERA0 -DUARTBAUD5V", + "f_cpu": "16000000L", + "mcu": "attiny204", + "variant": "txy4" + }, + "hardware": { + "oscillator": "internal" + }, + "frameworks": [ + "arduino" + ], + "name": "ATtiny204", + "upload": { + "maximum_ram_size": 128, + "maximum_size": 2048, + "protocol": "jtag2updi", + "speed": 115200 + }, + "url": "https://www.microchip.com/wwwproducts/en/ATTINY204", + "vendor": "Microchip" +} diff --git a/boards/ATtiny212.json b/boards/ATtiny212.json new file mode 100644 index 0000000..160eeb3 --- /dev/null +++ b/boards/ATtiny212.json @@ -0,0 +1,24 @@ +{ + "build": { + "core": "megatinycore", + "extra_flags": "-DARDUINO_attinyxy2 -DMILLIS_USE_TIMERD0 -DUARTBAUD5V", + "f_cpu": "16000000L", + "mcu": "attiny212", + "variant": "txy2" + }, + "hardware": { + "oscillator": "internal" + }, + "frameworks": [ + "arduino" + ], + "name": "ATtiny212", + "upload": { + "maximum_ram_size": 128, + "maximum_size": 2048, + "protocol": "jtag2updi", + "speed": 115200 + }, + "url": "https://www.microchip.com/wwwproducts/en/ATTINY212", + "vendor": "Microchip" +} diff --git a/boards/ATtiny214.json b/boards/ATtiny214.json new file mode 100644 index 0000000..f3fd769 --- /dev/null +++ b/boards/ATtiny214.json @@ -0,0 +1,24 @@ +{ + "build": { + "core": "megatinycore", + "extra_flags": "-DARDUINO_attinyxy4 -DMILLIS_USE_TIMERD0 -DUARTBAUD5V", + "f_cpu": "16000000L", + "mcu": "attiny214", + "variant": "txy4" + }, + "hardware": { + "oscillator": "internal" + }, + "frameworks": [ + "arduino" + ], + "name": "ATtiny214", + "upload": { + "maximum_ram_size": 128, + "maximum_size": 2048, + "protocol": "jtag2updi", + "speed": 115200 + }, + "url": "https://www.microchip.com/wwwproducts/en/ATTINY214", + "vendor": "Microchip" +} diff --git a/boards/ATtiny3216.json b/boards/ATtiny3216.json new file mode 100644 index 0000000..0b4ab3e --- /dev/null +++ b/boards/ATtiny3216.json @@ -0,0 +1,24 @@ +{ + "build": { + "core": "megatinycore", + "extra_flags": "-DARDUINO_attinyxy6 -DMILLIS_USE_TIMERD0 -DUARTBAUD5V", + "f_cpu": "16000000L", + "mcu": "attiny3216", + "variant": "txy6" + }, + "hardware": { + "oscillator": "internal" + }, + "frameworks": [ + "arduino" + ], + "name": "ATtiny3216", + "upload": { + "maximum_ram_size": 2048, + "maximum_size": 32768, + "protocol": "jtag2updi", + "speed": 115200 + }, + "url": "https://www.microchip.com/wwwproducts/en/ATTINY3216", + "vendor": "Microchip" +} diff --git a/boards/ATtiny3217.json b/boards/ATtiny3217.json new file mode 100644 index 0000000..f5018c4 --- /dev/null +++ b/boards/ATtiny3217.json @@ -0,0 +1,24 @@ +{ + "build": { + "core": "megatinycore", + "extra_flags": "-DARDUINO_attinyxy7 -DMILLIS_USE_TIMERD0 -DUARTBAUD5V", + "f_cpu": "16000000L", + "mcu": "attiny3217", + "variant": "txy7" + }, + "hardware": { + "oscillator": "internal" + }, + "frameworks": [ + "arduino" + ], + "name": "ATtiny3217", + "upload": { + "maximum_ram_size": 2048, + "maximum_size": 32768, + "protocol": "jtag2updi", + "speed": 115200 + }, + "url": "https://www.microchip.com/wwwproducts/en/ATTINY3217", + "vendor": "Microchip" +} diff --git a/boards/ATtiny402.json b/boards/ATtiny402.json new file mode 100644 index 0000000..303f8f8 --- /dev/null +++ b/boards/ATtiny402.json @@ -0,0 +1,24 @@ +{ + "build": { + "core": "megatinycore", + "extra_flags": "-DARDUINO_attinyxy2 -DMILLIS_USE_TIMERA0 -DUARTBAUD5V", + "f_cpu": "16000000L", + "mcu": "attiny402", + "variant": "txy2" + }, + "hardware": { + "oscillator": "internal" + }, + "frameworks": [ + "arduino" + ], + "name": "ATtiny402", + "upload": { + "maximum_ram_size": 256, + "maximum_size": 4096, + "protocol": "jtag2updi", + "speed": 115200 + }, + "url": "https://www.microchip.com/wwwproducts/en/ATTINY402", + "vendor": "Microchip" +} diff --git a/boards/ATtiny404.json b/boards/ATtiny404.json new file mode 100644 index 0000000..c68ac96 --- /dev/null +++ b/boards/ATtiny404.json @@ -0,0 +1,24 @@ +{ + "build": { + "core": "megatinycore", + "extra_flags": "-DARDUINO_attinyxy4 -DMILLIS_USE_TIMERA0 -DUARTBAUD5V", + "f_cpu": "16000000L", + "mcu": "attiny404", + "variant": "txy4" + }, + "hardware": { + "oscillator": "internal" + }, + "frameworks": [ + "arduino" + ], + "name": "ATtiny404", + "upload": { + "maximum_ram_size": 256, + "maximum_size": 4096, + "protocol": "jtag2updi", + "speed": 115200 + }, + "url": "https://www.microchip.com/wwwproducts/en/ATTINY404", + "vendor": "Microchip" +} diff --git a/boards/ATtiny406.json b/boards/ATtiny406.json new file mode 100644 index 0000000..6a2669d --- /dev/null +++ b/boards/ATtiny406.json @@ -0,0 +1,24 @@ +{ + "build": { + "core": "megatinycore", + "extra_flags": "-DARDUINO_attinyxy6 -DMILLIS_USE_TIMERA0 -DUARTBAUD5V", + "f_cpu": "16000000L", + "mcu": "attiny406", + "variant": "txy6" + }, + "hardware": { + "oscillator": "internal" + }, + "frameworks": [ + "arduino" + ], + "name": "ATtiny406", + "upload": { + "maximum_ram_size": 256, + "maximum_size": 4096, + "protocol": "jtag2updi", + "speed": 115200 + }, + "url": "https://www.microchip.com/wwwproducts/en/ATTINY406", + "vendor": "Microchip" +} diff --git a/boards/ATtiny412.json b/boards/ATtiny412.json new file mode 100644 index 0000000..0e709e0 --- /dev/null +++ b/boards/ATtiny412.json @@ -0,0 +1,24 @@ +{ + "build": { + "core": "megatinycore", + "extra_flags": "-DARDUINO_attinyxy2 -DMILLIS_USE_TIMERD0 -DUARTBAUD5V", + "f_cpu": "16000000L", + "mcu": "attiny412", + "variant": "txy2" + }, + "hardware": { + "oscillator": "internal" + }, + "frameworks": [ + "arduino" + ], + "name": "ATtiny412", + "upload": { + "maximum_ram_size": 256, + "maximum_size": 4096, + "protocol": "jtag2updi", + "speed": 115200 + }, + "url": "https://www.microchip.com/wwwproducts/en/ATTINY412", + "vendor": "Microchip" +} diff --git a/boards/ATtiny414.json b/boards/ATtiny414.json new file mode 100644 index 0000000..0184039 --- /dev/null +++ b/boards/ATtiny414.json @@ -0,0 +1,24 @@ +{ + "build": { + "core": "megatinycore", + "extra_flags": "-DARDUINO_attinyxy4 -DMILLIS_USE_TIMERD0 -DUARTBAUD5V", + "f_cpu": "16000000L", + "mcu": "attiny414", + "variant": "txy4" + }, + "hardware": { + "oscillator": "internal" + }, + "frameworks": [ + "arduino" + ], + "name": "ATtiny414", + "upload": { + "maximum_ram_size": 256, + "maximum_size": 4096, + "protocol": "jtag2updi", + "speed": 115200 + }, + "url": "https://www.microchip.com/wwwproducts/en/ATTINY414", + "vendor": "Microchip" +} diff --git a/boards/ATtiny416.json b/boards/ATtiny416.json new file mode 100644 index 0000000..2435e7f --- /dev/null +++ b/boards/ATtiny416.json @@ -0,0 +1,24 @@ +{ + "build": { + "core": "megatinycore", + "extra_flags": "-DARDUINO_attinyxy6 -DMILLIS_USE_TIMERD0 -DUARTBAUD5V", + "f_cpu": "16000000L", + "mcu": "attiny416", + "variant": "txy6" + }, + "hardware": { + "oscillator": "internal" + }, + "frameworks": [ + "arduino" + ], + "name": "ATtiny416", + "upload": { + "maximum_ram_size": 256, + "maximum_size": 4096, + "protocol": "jtag2updi", + "speed": 115200 + }, + "url": "https://www.microchip.com/wwwproducts/en/ATTINY416", + "vendor": "Microchip" +} diff --git a/boards/ATtiny417.json b/boards/ATtiny417.json new file mode 100644 index 0000000..9b200b7 --- /dev/null +++ b/boards/ATtiny417.json @@ -0,0 +1,24 @@ +{ + "build": { + "core": "megatinycore", + "extra_flags": "-DARDUINO_attinyxy7 -DMILLIS_USE_TIMERD0 -DUARTBAUD5V", + "f_cpu": "16000000L", + "mcu": "attiny417", + "variant": "txy7" + }, + "hardware": { + "oscillator": "internal" + }, + "frameworks": [ + "arduino" + ], + "name": "ATtiny417", + "upload": { + "maximum_ram_size": 256, + "maximum_size": 4096, + "protocol": "jtag2updi", + "speed": 115200 + }, + "url": "https://www.microchip.com/wwwproducts/en/ATTINY417", + "vendor": "Microchip" +} diff --git a/boards/ATtiny804.json b/boards/ATtiny804.json new file mode 100644 index 0000000..8d33408 --- /dev/null +++ b/boards/ATtiny804.json @@ -0,0 +1,24 @@ +{ + "build": { + "core": "megatinycore", + "extra_flags": "-DARDUINO_attinyxy4 -DMILLIS_USE_TIMERA0 -DUARTBAUD5V", + "f_cpu": "16000000L", + "mcu": "attiny804", + "variant": "txy4" + }, + "hardware": { + "oscillator": "internal" + }, + "frameworks": [ + "arduino" + ], + "name": "ATtiny804", + "upload": { + "maximum_ram_size": 512, + "maximum_size": 8192, + "protocol": "jtag2updi", + "speed": 115200 + }, + "url": "https://www.microchip.com/wwwproducts/en/ATTINY804", + "vendor": "Microchip" +} diff --git a/boards/ATtiny806.json b/boards/ATtiny806.json new file mode 100644 index 0000000..538ab2c --- /dev/null +++ b/boards/ATtiny806.json @@ -0,0 +1,24 @@ +{ + "build": { + "core": "megatinycore", + "extra_flags": "-DARDUINO_attinyxy6 -DMILLIS_USE_TIMERA0 -DUARTBAUD5V", + "f_cpu": "16000000L", + "mcu": "attiny806", + "variant": "txy6" + }, + "hardware": { + "oscillator": "internal" + }, + "frameworks": [ + "arduino" + ], + "name": "ATtiny806", + "upload": { + "maximum_ram_size": 512, + "maximum_size": 8192, + "protocol": "jtag2updi", + "speed": 115200 + }, + "url": "https://www.microchip.com/wwwproducts/en/ATTINY806", + "vendor": "Microchip" +} diff --git a/boards/ATtiny807.json b/boards/ATtiny807.json new file mode 100644 index 0000000..20e2893 --- /dev/null +++ b/boards/ATtiny807.json @@ -0,0 +1,24 @@ +{ + "build": { + "core": "megatinycore", + "extra_flags": "-DARDUINO_attinyxy7 -DMILLIS_USE_TIMERA0 -DUARTBAUD5V", + "f_cpu": "16000000L", + "mcu": "attiny807", + "variant": "txy7" + }, + "hardware": { + "oscillator": "internal" + }, + "frameworks": [ + "arduino" + ], + "name": "ATtiny807", + "upload": { + "maximum_ram_size": 512, + "maximum_size": 8192, + "protocol": "jtag2updi", + "speed": 115200 + }, + "url": "https://www.microchip.com/wwwproducts/en/ATTINY807", + "vendor": "Microchip" +} diff --git a/boards/ATtiny814.json b/boards/ATtiny814.json new file mode 100644 index 0000000..5f22523 --- /dev/null +++ b/boards/ATtiny814.json @@ -0,0 +1,24 @@ +{ + "build": { + "core": "megatinycore", + "extra_flags": "-DARDUINO_attinyxy4 -DMILLIS_USE_TIMERD0 -DUARTBAUD5V", + "f_cpu": "16000000L", + "mcu": "attiny814", + "variant": "txy4" + }, + "hardware": { + "oscillator": "internal" + }, + "frameworks": [ + "arduino" + ], + "name": "ATtiny814", + "upload": { + "maximum_ram_size": 512, + "maximum_size": 8192, + "protocol": "jtag2updi", + "speed": 115200 + }, + "url": "https://www.microchip.com/wwwproducts/en/ATTINY814", + "vendor": "Microchip" +} diff --git a/boards/ATtiny816.json b/boards/ATtiny816.json new file mode 100644 index 0000000..53ee85b --- /dev/null +++ b/boards/ATtiny816.json @@ -0,0 +1,24 @@ +{ + "build": { + "core": "megatinycore", + "extra_flags": "-DARDUINO_attinyxy6 -DMILLIS_USE_TIMERD0 -DUARTBAUD5V", + "f_cpu": "16000000L", + "mcu": "attiny816", + "variant": "txy6" + }, + "hardware": { + "oscillator": "internal" + }, + "frameworks": [ + "arduino" + ], + "name": "ATtiny816", + "upload": { + "maximum_ram_size": 512, + "maximum_size": 8192, + "protocol": "jtag2updi", + "speed": 115200 + }, + "url": "https://www.microchip.com/wwwproducts/en/ATTINY816", + "vendor": "Microchip" +} diff --git a/boards/ATtiny817.json b/boards/ATtiny817.json new file mode 100644 index 0000000..f27409d --- /dev/null +++ b/boards/ATtiny817.json @@ -0,0 +1,24 @@ +{ + "build": { + "core": "megatinycore", + "extra_flags": "-DARDUINO_attinyxy7 -DMILLIS_USE_TIMERD0 -DUARTBAUD5V", + "f_cpu": "16000000L", + "mcu": "attiny817", + "variant": "txy7" + }, + "hardware": { + "oscillator": "internal" + }, + "frameworks": [ + "arduino" + ], + "name": "ATtiny817", + "upload": { + "maximum_ram_size": 512, + "maximum_size": 8192, + "protocol": "jtag2updi", + "speed": 115200 + }, + "url": "https://www.microchip.com/wwwproducts/en/ATTINY817", + "vendor": "Microchip" +} diff --git a/builder/bootloader.py b/builder/bootloader.py index 241313a..40eed1a 100644 --- a/builder/bootloader.py +++ b/builder/bootloader.py @@ -81,8 +81,7 @@ def get_suitable_optiboot_binary(framework_dir, board_config): "-p", "$BOARD_MCU", "-C", - '"%s"' - % os.path.join(env.PioPlatform().get_package_dir( + os.path.join(env.PioPlatform().get_package_dir( "tool-avrdude-megaavr") or "", "avrdude.conf"), ], BOOTFLAGS=['-Uflash:w:"%s":i' % bootloader_path], diff --git a/builder/frameworks/arduino.py b/builder/frameworks/arduino.py index 100987b..9b0ff82 100644 --- a/builder/frameworks/arduino.py +++ b/builder/frameworks/arduino.py @@ -72,7 +72,10 @@ # Select oscillator using a special macro # -if board.get("hardware", {}).get("oscillator", "internal") == "external": +oscillator_type = board.get("hardware", {}).get("oscillator", "internal") +if build_core == "megatinycore": + env.Append(CPPDEFINES=[("CLOCKSOURCE", 2 if oscillator_type == "external" else 0)]) +elif oscillator_type == "external" and build_core == "MegaCoreX": env.Append(CPPDEFINES=["USE_EXTERNAL_OSCILLATOR"]) # diff --git a/builder/fuses.py b/builder/fuses.py index fae4bb1..ab55e32 100644 --- a/builder/fuses.py +++ b/builder/fuses.py @@ -34,16 +34,26 @@ def get_tcd0cfg_fuse(): return 0x00 -def get_syscfg0_fuse(eesave, rstpin, uart): +def get_syscfg0_fuse(eesave, pin, uart): eesave_bit = 1 if eesave == "yes" else 0 - if rstpin == "gpio": - if uart == "no_bootloader": - rstpin_bit = 0 + if core == "MegaCoreX": + if pin == "gpio": + if uart == "no_bootloader": + rstpin_bit = 0 + else: + rstpin_bit = 1 else: rstpin_bit = 1 - else: - rstpin_bit = 1 - return 0xC0 | rstpin_bit << 3 | eesave_bit + return 0xC0 | rstpin_bit << 3 | eesave_bit + + elif core == "megatinycore": + if pin == "gpio": + updipin_bits = 0x0 + elif pin == "updi": + updipin_bits = 0x1 + else: + updipin_bits = 0x2 + return 0xC0 | updipin_bits << 2 | eesave_bit def get_syscfg1_fuse(): @@ -78,19 +88,22 @@ def print_fuses_info(fuse_values, fuse_names, lock_fuse): print("------------------------\n") -def calculate_megacorex_fuses(board_config, predefined_fuses): - megacorex_fuses = [] +def calculate_fuses(board_config, predefined_fuses): + megaavr_fuses = [] f_cpu = board_config.get("build.f_cpu", "16000000L").upper() oscillator = board_config.get("hardware.oscillator", "internal").lower() bod = board_config.get("hardware.bod", "2.6v").lower() uart = board_config.get("hardware.uart", "no_bootloader").lower() eesave = board_config.get("hardware.eesave", "yes").lower() - rstpin = board_config.get("hardware.rstpin", "reset").lower() + if core == "MegaCoreX": + pin = board_config.get("hardware.rstpin", "reset").lower() + # Guard that prevents the user from turning the reset pin + # into a GPIO while using a bootloader + if uart != "no_bootloader": + pin = "reset" - # Guard that prevents the user from turning the reset pin - # into a GPIO while using a bootloader - if uart != "no_bootloader": - rstpin = "reset" + elif core == "megatinycore": + pin = board_config.get("hardware.updipin", "updi").lower() print("\nTARGET CONFIGURATION:") print("------------------------") @@ -99,7 +112,8 @@ def calculate_megacorex_fuses(board_config, predefined_fuses): print("Oscillator = %s" % oscillator) print("BOD level = %s" % bod) print("Save EEPROM = %s" % eesave) - print("Reset pin mode = %s" % rstpin) + print("%s = %s" % ( + "Reset pin mode" if core == "MegaCoreX" else "UPDI pin mode", pin)) print("------------------------") return ( @@ -108,7 +122,7 @@ def calculate_megacorex_fuses(board_config, predefined_fuses): predefined_fuses[2] or "0x%.2X" % get_osccfg_fuse(f_cpu, oscillator), "", # reserved predefined_fuses[4] or "0x%.2X" % get_tcd0cfg_fuse(), - predefined_fuses[5] or "0x%.2X" % get_syscfg0_fuse(eesave, rstpin, uart), + predefined_fuses[5] or "0x%.2X" % get_syscfg0_fuse(eesave, pin, uart), predefined_fuses[6] or "0x%.2X" % get_syscfg1_fuse(), predefined_fuses[7] or "0x%.2X" % get_append_fuse(), predefined_fuses[8] or "0x%.2X" % get_bootend_fuse(uart), @@ -143,7 +157,11 @@ def calculate_megacorex_fuses(board_config, predefined_fuses): ) board_fuses = board.get(fuses_section, {}) -if not board_fuses and "FUSESFLAGS" not in env and core != "MegaCoreX": +if ( + not board_fuses + and "FUSESFLAGS" not in env + and core not in ("MegaCoreX", "megatinycore") +): sys.stderr.write( "Error: Dynamic fuses generation for %s / %s is not supported. " "Please specify fuses in platformio.ini\n" % (core, env.subst("$BOARD")) @@ -151,9 +169,10 @@ def calculate_megacorex_fuses(board_config, predefined_fuses): env.Exit(1) fuse_values = [board_fuses.get(fname, "") for fname in fuse_names] -lock_fuse = board_fuses.get("lockbit", hex(get_lockbit_fuse())) -if core == "MegaCoreX": - fuse_values = calculate_megacorex_fuses(board, fuse_values) +lock_fuse = board_fuses.get("lockbit", "0x%.2X" % get_lockbit_fuse()) +if core in ("MegaCoreX", "megatinycore"): + fuse_values = calculate_fuses(board, fuse_values) + env.Append( FUSESUPLOADER="avrdude", @@ -161,8 +180,7 @@ def calculate_megacorex_fuses(board_config, predefined_fuses): "-p", "$BOARD_MCU", "-C", - '"%s"' - % os.path.join( + os.path.join( env.PioPlatform().get_package_dir("tool-avrdude-megaavr") or "", "avrdude.conf", ), diff --git a/builder/main.py b/builder/main.py index fbf97f3..f8120af 100644 --- a/builder/main.py +++ b/builder/main.py @@ -74,7 +74,7 @@ def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621 UPLOADER="avrdude", UPLOADERFLAGS=[ "-p", "$BOARD_MCU", "-C", - '"%s"' % join(env.PioPlatform().get_package_dir( + join(env.PioPlatform().get_package_dir( "tool-avrdude-megaavr") or "", "avrdude.conf"), "-c", "$UPLOAD_PROTOCOL" ], @@ -196,13 +196,13 @@ def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621 env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE") ] + upload_options = env.BoardConfig().get("upload", {}) # jtag2updi seems to be the only protocol that requires serial port if upload_protocol == "jtag2updi": - upload_options = env.BoardConfig().get("upload", {}) - for opt in ("require_upload_port", "use_1200bps_touch", "wait_for_upload_port"): - upload_options[opt] = True + upload_options["require_upload_port"] = True + upload_options["use_1200bps_touch"] = True + upload_options["wait_for_upload_port"] = False elif upload_protocol == "arduino": - upload_options = env.BoardConfig().get("upload", {}) upload_options["require_upload_port"] = True upload_options["use_1200bps_touch"] = False upload_options["wait_for_upload_port"] = False diff --git a/examples/arduino-blink/platformio.ini b/examples/arduino-blink/platformio.ini index 99a7554..7c3afb8 100644 --- a/examples/arduino-blink/platformio.ini +++ b/examples/arduino-blink/platformio.ini @@ -47,3 +47,28 @@ board_build.variant = uno-wifi platform = atmelmegaavr framework = arduino board = avr_iot_wg + +[env:ATtiny1604] +platform = atmelmegaavr +framework = arduino +board = ATtiny1604 + +[env:ATtiny202] +platform = atmelmegaavr +framework = arduino +board = ATtiny202 + +[env:ATtiny3216] +platform = atmelmegaavr +framework = arduino +board = ATtiny3216 + +[env:ATtiny406] +platform = atmelmegaavr +framework = arduino +board = ATtiny406 + +[env:ATtiny817] +platform = atmelmegaavr +framework = arduino +board = ATtiny817 diff --git a/examples/arduino-external-libs/platformio.ini b/examples/arduino-external-libs/platformio.ini index 5a86faf..be840b8 100644 --- a/examples/arduino-external-libs/platformio.ini +++ b/examples/arduino-external-libs/platformio.ini @@ -10,8 +10,8 @@ [common] lib_deps = SPI - Adafruit 9DOF Library - Ethernet + adafruit/Adafruit 9DOF + arduino-libraries/Ethernet [env:uno_wifi_rev2] platform = atmelmegaavr diff --git a/examples/arduino-internal-libs/platformio.ini b/examples/arduino-internal-libs/platformio.ini index ab99066..0672aa4 100644 --- a/examples/arduino-internal-libs/platformio.ini +++ b/examples/arduino-internal-libs/platformio.ini @@ -7,19 +7,12 @@ ; Please visit documentation for the other options and examples ; http://docs.platformio.org/page/projectconf.html -[common] -lib_deps = - SPI - Ethernet - [env:uno_wifi_rev2] platform = atmelmegaavr framework = arduino board = uno_wifi_rev2 -lib_deps = ${common.lib_deps} [env:nano_every] platform = atmelmegaavr framework = arduino board = nano_every -lib_deps = ${common.lib_deps} diff --git a/examples/arduino-internal-libs/src/ChatServer.ino b/examples/arduino-internal-libs/src/ChatServer.ino deleted file mode 100644 index 11a08ac..0000000 --- a/examples/arduino-internal-libs/src/ChatServer.ino +++ /dev/null @@ -1,81 +0,0 @@ -/* - Chat Server - - A simple server that distributes any incoming messages to all - connected clients. To use telnet to your device's IP address and type. - You can see the client's input in the serial monitor as well. - Using an Arduino Wiznet Ethernet shield. - - Circuit: - * Ethernet shield attached to pins 10, 11, 12, 13 - * Analog inputs attached to pins A0 through A5 (optional) - - created 18 Dec 2009 - by David A. Mellis - modified 9 Apr 2012 - by Tom Igoe - - */ - -#include -#include -#include - -// Enter a MAC address and IP address for your controller below. -// The IP address will be dependent on your local network. -// gateway and subnet are optional: -byte mac[] = { - 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED -}; -IPAddress ip(192, 168, 1, 177); -IPAddress gateway(192, 168, 1, 1); -IPAddress subnet(255, 255, 0, 0); - - -// telnet defaults to port 23 -EthernetServer server(23); -boolean alreadyConnected = false; // whether or not the client was connected previously - -void setup() { - // initialize the ethernet device - Ethernet.begin(mac, ip, gateway, subnet); - // start listening for clients - server.begin(); - // Open serial communications and wait for port to open: - Serial.begin(9600); - while (!Serial) { - ; // wait for serial port to connect. Needed for Leonardo only - } - - - Serial.print("Chat server address:"); - Serial.println(Ethernet.localIP()); -} - -void loop() { - // wait for a new client: - EthernetClient client = server.available(); - - // when the client sends the first byte, say hello: - if (client) { - if (!alreadyConnected) { - // clead out the input buffer: - client.flush(); - Serial.println("We have a new client"); - client.println("Hello, client!"); - alreadyConnected = true; - } - - if (client.available() > 0) { - // read the bytes incoming from the client: - char thisChar = client.read(); - // echo the bytes back to the client: - server.write(thisChar); - // echo the bytes to the server as well: - Serial.write(thisChar); - } - } -} - - - diff --git a/examples/arduino-internal-libs/src/eeprom_get.ino b/examples/arduino-internal-libs/src/eeprom_get.ino new file mode 100644 index 0000000..a07cee7 --- /dev/null +++ b/examples/arduino-internal-libs/src/eeprom_get.ino @@ -0,0 +1,68 @@ +/*** + eeprom_get example. + + This shows how to use the EEPROM.get() method. + + To pre-set the EEPROM data, run the example sketch eeprom_put. + This sketch will run without it, however, the values shown + will be shown from what ever is already on the EEPROM. + + This may cause the serial object to print out a large string + of garbage if there is no null character inside one of the strings + loaded. + + Written by Christopher Andrews 2015 + Released under MIT licence. +***/ + +#include + +void setup() { + + float f = 0.00f; //Variable to store data read from EEPROM. + int eeAddress = 0; //EEPROM address to start reading from + + Serial.begin(9600); + while (!Serial) { + ; // wait for serial port to connect. Needed for native USB port only + } + Serial.print("Read float from EEPROM: "); + + //Get the float data from the EEPROM at position 'eeAddress' + EEPROM.get(eeAddress, f); + Serial.println(f, 3); //This may print 'ovf, nan' if the data inside the EEPROM is not a valid float. + + /*** + As get also returns a reference to 'f', you can use it inline. + E.g: Serial.print( EEPROM.get( eeAddress, f ) ); + ***/ + + /*** + Get can be used with custom structures too. + I have separated this into an extra function. + ***/ + + secondTest(); //Run the next test. +} + +struct MyObject { + float field1; + byte field2; + char name[10]; +}; + +void secondTest() { + int eeAddress = sizeof(float); //Move address to the next byte after float 'f'. + + MyObject customVar; //Variable to store custom object read from EEPROM. + EEPROM.get(eeAddress, customVar); + + Serial.println("Read custom object from EEPROM: "); + Serial.println(customVar.field1); + Serial.println(customVar.field2); + Serial.println(customVar.name); +} + +void loop() { + /* Empty loop */ +} diff --git a/platform.json b/platform.json index 6bfbfd2..89ce0ff 100644 --- a/platform.json +++ b/platform.json @@ -18,7 +18,7 @@ "type": "git", "url": "https://github.com/platformio/platform-atmelmegaavr.git" }, - "version": "1.3.0", + "version": "1.4.0", "frameworks": { "arduino": { "package": "framework-arduino-megaavr", @@ -29,25 +29,33 @@ "toolchain-atmelavr": { "type": "toolchain", "owner": "platformio", - "version": "~1.70300.0" + "version": "~1.70300.0", + "optionalVersions": ["~2.70300.0"] }, "framework-arduino-megaavr": { "type": "framework", "optional": true, "owner": "platformio", - "version": "~1.8.6" + "version": "~1.8.7" }, "framework-arduino-megaavr-megacorex": { "type": "framework", "optional": true, "owner": "platformio", - "version": "~1.0.5" + "version": "~1.0.7" + }, + "framework-arduino-megaavr-megatinycore": { + "type": "framework", + "optional": true, + "owner": "platformio", + "version": "~2.1.5" }, "tool-avrdude-megaavr": { "type": "uploader", "optional": true, "owner": "platformio", - "version": "~1.60300.0" + "version": "~1.60300.0", + "optionalVersions": ["~2.60300.0"] } } } diff --git a/platform.py b/platform.py index 88da715..f0daa52 100644 --- a/platform.py +++ b/platform.py @@ -32,7 +32,7 @@ def configure_default_packages(self, variables, targets): self.packages[framework_package]["optional"] = False self.packages["framework-arduino-megaavr"]["optional"] = True - if build_core == "MegaCoreX": + if build_core in ("MegaCoreX", "megatinycore"): self.packages["toolchain-atmelavr"]["version"] = "~2.70300.0" self.packages["tool-avrdude-megaavr"]["version"] = "~2.60300.0"