I am an electronics engineer that does software. I am new to PlatformIO, but not new to MCUs.
I have a custom board design that will run an ATmega32U4 and code someone else has written in C++ from here: https://github.com/xyphro/UsbGpib. I have forked the hardware and I want to modify the software also.
The path of least resistance is to just use a Ubuntu CLI tool chain (gcc, avrdude). They aren’t much different to what I was using 40 years ago, old school style.
The Linux command line looks like this:
You can still have a baremetal project (which is platformio.ini without a framework = .. setting, exactly as your current one) and just put .cpp in the src/ folder. They will be compiled using avr-g++. Nothing too different.
And no, AVR libC only examples are available. The program should compile the same when you rename main.c → main.cpp, making that a C++ project.
whereas I want bare metal C++
and no flags for fuses.
So it appears that a custom board definition would be appropriate and I think I could write one for a generic custom ATmega32U4 board. If I wrote a custom definition, it would only exist on my pc. I would prefer to add this back into the repository for others, like me, to use but the process for raising a “new board” issue : Adding a Custom Board
doesn’t seem to be working.
Also the ATmega board definitions include variants of the line:
A search of “platformio” and “extra_flags” does not yield any results.
The values of these extra flags includes:
“-DARDUINO_AVR_ATmega…” which again includes the ARDUINO word that I don’t want for a bare metal system.
What this means is that I don’t know why the extra-flags value is there, and the consequences of removing it for a custom generic board that does not use Arduino.
Doesn’t matter because again “bare metal C++” is a project without a framework = .. line, and no framework is always valid. This just lists all the available framework = .. values, where as no framework settings is always also available, which is baremetal.
Doesn’t matter because it can be configured through the platformio.ini as per documentation above.
Doesn’t matter because in your baremetal project, there will be no code to listen to this definition of the macro. You control the entire source code.
If you have a ATmega32, your already posted platformio.ini will work just fine as a base, just add in fuse and upload settings per docs above, no custom board definition needed.