Atmel megaAVR

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

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

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)
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

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
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