PlatformIO Community

Is there anyway to configure platformio to run the native AVR program?

Hi, I want to use platformio to run native AVR(atmega8) program, the test program is:

#include "avr/io.h"
int main(void)
{
        DDRB |= 0x01;
        PORTB &= 0xfe;
        while(1);
}

But the Project Wizard forces the Framework to Arduino when creating new project of AVR:
Snipaste_2020-09-09_10-37-43

Is there anyway to configure platformio to run the native AVR program? Not use the arduino framework.

Best regards.

This was already answered multiple times: AVR programming without arduino framework

Just remove the framework = .. line do program without a framework, natively.

1 Like

You might not notice, but even though the Arduino framework files get compiled and linked into a static library, they don’t subsequently get linked to your own code - as far as I remember from my own experiments.

Cheers,
Norm.

Thanks a lot @maxgerhardt
As the picture shows, when selecting “ATmega8/A (Microchip)” in Board section, then the “Arduino” appears in Framework section, and it can not be changed.
My board is a custom board, and the chip is atmega8a, for the native avr program, is there anyway to change something that I can select my custom board in Board section and don’t let the “Arduino” appeared in Framework section when using Project Wizard?
Best regards.

Thats because when you select the ATMega8 its board JSON definition file tells it what framework it supports, and displays it accordingly.

You can just ignore the VSCode setup screen and input whatever board and whatever framework at random. It just generates the platformio.ini which you can later change to fit your needs. Just make sure you have the right platform, board and no framework = .. line. Even if you choose ATmega8 + Arduino, just remove the line afterwards.

You can create a custom embedded board as the documentation tells you if you want. You could basically copy the above referenced ATmega8.json in the boards/ folder of the platform-atmelavr folder (home folder + .platformio\platforms\atmelavr) under a new name, e.g. myboard.json, and set frameworks to an empty array and give it a new name value. The project wizard should then pick it up… I’m however not sure if it handles an empty framework array correctly.

Also I would not go through the work of a local platform modification just to have the “New project” wizard display the board with no framework option for an already known chip where you can just delete a line in the platformio.ini.

Thanks @NormanDunbar

No worries @wgt, but I think you meant @maxgerhardt as he was way more helpful than I was. :wink:.

Cheers,
Norm.

Thanks @maxgerhardt
I read the documentation “Custom Platform & Board”, being lack of some necessory knowledge, I find that the document is hard to understand & follow the steps for creating a custom plateform & board.
For the native avr-gcc, I think the framework should be avr-libc.
Best regards.