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;

But the Project Wizard forces the Framework to Arduino when creating new project of AVR:

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.


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.


1 Like

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


1 Like

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.

1 Like

I’m with wgt on this. As someone who has used their own make system since college on Linux machines and is trying to migrate into PlatformIO for easier use by my target audience I’m finding it anything but easy and intuitive. I shouldn’t be forced to choose a framework in the project wizard and then manually edit the file. I only knew to do this because so many forum and stack posts exist about this. There’s nothing in the docs explicitly saying this you have to just notice the difference yourself when pointed at the native blink example.

Also I’ve got the platform set and it can’t find avr-libc headers like stdio.h and I have no idea where to dive into to fix it because so much of it is just automated. I have no idea what step of the process is supposed to be providing the access to avr-libc. Documentation specifies all the config options you can manually add but 95% of them are optional and there’s no clear description of when you’d want to start using them. Pointing at examples from documentation that don’t include any descriptive comments isn’t helpful.

1 Like

Perhaps a None option should be added? The alternative being Custom, but then you’d want an input box as well… better to at least allow a framework not be set, and then configured manually afterwards if wanted?

is it possible to have a native avr-gcc framework in project wizard? Im looking for a way not to have to remove the “framework = arduino” every time. and also I have to remove to main.cpp file and add a new main.c , or rename the main.cpp to main.c and replace the void setup and void loop to the int main and while(1).
I’m looking for a way to simply create native avr projects like clicking on Gcc C Application in Atmel Studio which makes a standard gcc c project and a main.c file which you can see the int main and the while(1) inside the main.c file.

No, was not resolved.