Custom Compiler Binary For Arduino atmelavr Platform

I want to modify the atmelavr with as little effort and core manipulation as possible so that it uses a different avr-g++ binary than the default. I really don’t know where to start here and I just need it done fast. I already wrote a python script to download the correct binary and sdk into the root directory of the platformio project. Now I just need some simple way to forward a path to the compiler to the atmelavr platform. Maybe even just modifying the atmelavr platform files? Although I don’t know where I would look for that and I don’t really have the time to learn a whole new config format. Regardless I hope this explains my issue.

Also I’m having issues getting a python script to run before build-time to be executed by platformio.ino. If there’s a really simple way to do this please let me know.

In general, you should first make your compiler toolchain into a PlatformIO package by adding a package.json in its root directory. Its content can be copied from the current <user directory>/.platformio/packages/toolchain-atmelavr, but with at least modified version field.

You can then make PlatformIO use that package by setting it as the sourec for the toolchain-atmelavr package. As is documented.

platform_packages =

This is a project-level change, but if you want all projects to use it automatically, you need to make a change in the platform, that is <user directory>/.platformio/platforms/atmelavr (or atmelmegaavr), where you can modify the source for the package in the platform.json, by modifying the version field for the toolchain-atmelavr package. (See current)

You can also read more details here.