Building for AVR64DA48 and other AVR-Dx chips

I was struggling to compile and link for the AVR64DA48 chip (and likely its variants) without the use of the Arduino framework. My test code would compile but the link would fail with complaints of “.data” and “.bss” sections being outside their target address space.

After comparing the output from Microchip Studio against PlatformIO, I discovered the issue in the “ldscripts” installed with the gcc-avr toolchain.

The specific ldscript for this series of chips is “avrxmega2” (you will see this from the linker flag “-mmcu=avrxmega2”).

The ldscript files have the address of the “.data” section hard coded. The same files, installed by Microchip Studio, allow for an override.

Copying over the Microchip scripts and adding a “build-_flags” option of “-Tdata=0x806000” solves the issue.

I know there is an option to install a difference version of gcc-avr and then direct the PlayformIO build to use it but it was not clear to me which version to install and from where (for a Linux environment).

this post is here for informational purposes to assist other who may be using this microcontroller in the near future.