Atmel megaAVR

Registry:

https://registry.platformio.org/platforms/platformio/atmelmegaavr

Configuration:

platform = atmelmegaavr

8-bit MCUs Built for Real-time Control with Core Independent Peripherals combining intelligent hardware peripherals along with the low-power capability of an AVR core, megaAVR microcontrollers (MCUs) broaden the effectiveness of your real-time control systems.

For more detailed information please visit vendor site.

Configuration

Upload using Programmer

In the case of external programmers, it’s easy to brick a board simply by specifying incorrect upload flags. It’s highly recommended to use the upload_command option that gives the full control over flags used for uploading. Please read Upload using Programmer for more information.

Upload using pyupdi

pyupdi is a Python-based tool for programming tinyAVR and megaAVR devices with UPDI interface via a standard serial port. It can be installed directly in the PlatformIO virtual environment using the following command:

pip install https://github.com/mraardvark/pyupdi/archive/master.zip

Once pyupdi is installed it can be used as the uploader via a custom upload_command option, for example:

[env:ATmega3209_pyupdi_upload]
platform = atmelmegaavr
framework = arduino
board = ATmega3209
upload_speed = 115200
upload_flags =
    -d
    mega3209
    -c
    $UPLOAD_PORT
    -b
    $UPLOAD_SPEED
upload_command = pyupdi $UPLOAD_FLAGS -f $SOURCE

Warning

Device names used in in pyupdi differ from MCU names used in the atmelmegaavr platform. Run pyupdi --help to see the list of supported devices.

More information and a typical circuit diagram can be found in the official pyupdi repository repository.

Fuses programming

PlatformIO has a built-in target called fuses for setting fuse bits. The default fuse bits are predefined in the board manifest file in the fuses section. For example, fuses section for Arduino Nano Every board. To set fuse bits you need to use target fuses with pio run --target command.

Custom fuses

Custom fuse values and upload flags (based on upload protocol) should be specified in “platformio.ini” (Project Configuration File). An example of setting custom fuses for ATmega3209 board:

[env:custom_fuses]
platform = atmelmegaavr
framework = arduino
board = ATmega3209
upload_protocol = xplainedmini_updi
board_fuses.bootend = 0xAA
board_fuses.syscfg0 = 0xBB
board_fuses.osccfg = 0xCC

Overriding default fuses command

For more detailed information read Overriding default fuses command.

Bootloader programming

PlatformIO has a built-in target called bootloader for flashing bootloaders. The default bootloader image and corresponding fuse bits are predefined in the board manifest file in the bootloader section, for example, Arduino Uno WiFi Rev2. To upload a bootloader image you need to use target bootloader with pio run --target command.

Custom bootloader

Custom bootloader and accompanying fuses should be specified in “platformio.ini” (Project Configuration File). An example of setting custom bootloader for ATmega4808 board:

[env:ATmega4808]
platform = atmelmegaavr
framework = arduino
board = ATmega4808

board_bootloader.file = /path/to/custom/bootloader.hex
board_bootloader.bootend = 0xFF
board_bootloader.syscfg0 = 0xDE
board_bootloader.osccfg = 0xFD
board_bootloader.lock_bits = 0x0F

Overriding default bootloader command

For more detailed information read Overriding default bootloader command.

Examples

Examples are listed from Atmel megaAVR development platform repository:

Stable and upstream versions

You can switch between stable releases of Atmel megaAVR development platform and the latest upstream version using platform option in “platformio.ini” (Project Configuration File) as described below.

Stable

; Latest stable version
[env:latest_stable]
platform = atmelmegaavr
board = ...

; Custom stable version
[env:custom_stable]
platform = atmelmegaavr@x.y.z
board = ...

Upstream

[env:upstream_develop]
platform = https://github.com/platformio/platform-atmelmegaavr.git
board = ...

Packages

Name

Description

framework-arduino-megaavr

Arduino Wiring-based Framework for Microchip megaAVR microcontrollers

framework-arduino-megaavr-megacorex

Arduino Wiring-based Framework for Microchip megaAVR microcontrollers (MegaCoreX)

framework-arduino-megaavr-megatinycore

Arduino Wiring-based Framework for Microchip tinyAVR 0-series and 1-series chips (megaTinyCore)

tool-avrdude-megaavr

AVRDUDE is a utility to download/upload/manipulate the ROM and EEPROM contents of megaAVR microcontrollers

toolchain-atmelavr

GCC Toolchain for Microchip AVR microcontrollers

Warning

Linux Users:

Windows Users:

Please check that you have a correctly installed USB driver from board manufacturer

Frameworks

Name

Description

Arduino

Arduino Wiring-based Framework allows writing cross-platform software to control devices attached to a wide range of Arduino boards to create all kinds of creative coding, interactive objects, spaces or physical experiences

Boards

Note

  • You can list pre-configured boards by pio boards command

  • For more detailed board information please scroll the tables below by horizontally.

Arduino

Name

Debug

MCU

Frequency

Flash

RAM

Arduino Nano Every

No

ATMEGA4809

16MHz

47.50KB

6KB

Arduino Uno WiFi Rev2

No

ATMEGA4809

16MHz

47.50KB

6KB

Microchip

Name

Debug

MCU

Frequency

Flash

RAM

ATmega1608

No

ATMEGA1608

16MHz

16KB

2KB

ATmega1609

No

ATMEGA1609

16MHz

16KB

2KB

ATmega3208

No

ATMEGA3208

16MHz

32KB

4KB

ATmega3209

No

ATMEGA3209

16MHz

32KB

4KB

ATmega4808

No

ATMEGA4808

16MHz

48KB

6KB

ATmega4809

No

ATMEGA4809

16MHz

48KB

6KB

ATmega808

No

ATMEGA808

16MHz

8KB

1KB

ATmega809

No

ATMEGA809

16MHz

8KB

1KB

ATtiny1604

No

ATTINY1604

16MHz

16KB

1KB

ATtiny1606

No

ATTINY1606

16MHz

16KB

1KB

ATtiny1607

No

ATTINY1607

16MHz

16KB

1KB

ATtiny1614

No

ATTINY1614

16MHz

16KB

2KB

ATtiny1616

No

ATTINY1616

16MHz

16KB

2KB

ATtiny1617

No

ATTINY1617

16MHz

16KB

2KB

ATtiny202

No

ATTINY202

16MHz

2KB

128B

ATtiny204

No

ATTINY204

16MHz

2KB

128B

ATtiny212

No

ATTINY212

16MHz

2KB

128B

ATtiny214

No

ATTINY214

16MHz

2KB

128B

ATtiny3216

No

ATTINY3216

16MHz

32KB

2KB

ATtiny3217

No

ATTINY3217

16MHz

32KB

2KB

ATtiny402

No

ATTINY402

16MHz

4KB

256B

ATtiny404

No

ATTINY404

16MHz

4KB

256B

ATtiny406

No

ATTINY406

16MHz

4KB

256B

ATtiny412

No

ATTINY412

16MHz

4KB

256B

ATtiny414

No

ATTINY414

16MHz

4KB

256B

ATtiny416

No

ATTINY416

16MHz

4KB

256B

ATtiny417

No

ATTINY417

16MHz

4KB

256B

ATtiny804

No

ATTINY804

16MHz

8KB

512B

ATtiny806

No

ATTINY806

16MHz

8KB

512B

ATtiny807

No

ATTINY807

16MHz

8KB

512B

ATtiny814

No

ATTINY814

16MHz

8KB

512B

ATtiny816

No

ATTINY816

16MHz

8KB

512B

ATtiny817

No

ATTINY817

16MHz

8KB

512B

AVR-IoT WG Development Board

No

ATMEGA4808

16MHz

48KB

6KB

Curiosity Nano ATmega4809

No

ATMEGA4809

16MHz

48KB

6KB

Xplained Pro ATmega4809

No

ATMEGA4809

16MHz

48KB

6KB