PlatformIO Community

Getting started for non-Arduino users (avr-gcc only)


#1

Background:

I have intermediate experience in programming AVR devices using Atmel Studio and used AVRISPmkII and STK500 exclusively to program devices. I always used “native” approach and have not touched Arduino as a framework, have not worked with command line, and have no experience working with other micros. I work with custom boards most of the time, defining port and bit definitions depending on the project. In short, i am very sheltered under the Atmel/Microchip umbrella. :sweat_smile:

I am at a lost on how to start using platformio, because most examples i find in the community and documentation on AVR revolves around Arduino.

Here are my questions:

Question 1: How to define boards that will NOT use any framework?

I have read http://docs.platformio.org/en/latest/platforms/creating_board.html and checked other json board files in ~/.platformio/platforms/atmelavr/boards, and i still cannot fully understand what goes into “build”, “framework”, “connectivity”, and “upload” sections.

As i review the “build” sections of some json files, i notice differing data. I tried to reference GNU Make AVR Options (here: https://gcc.gnu.org/onlinedocs/gcc/AVR-Options.html) but cannot establish base line.

What goes into:
1.“core”
2."extra_flags”
3.“variants”?
4."hwids”
5.“usb_product”.

I have read somewhere that in order to go native, i should just omit the “framework” section altogether. Is this correct?

For the “connectivity” section, (saw this in ‘Ethernet’ board), I don’t really know what this is or where it came form.

For the “upload” section, i am also reading mostly Arduino specific examples (in ~/platformio/packages/framework-arduinoavr/programmers.txt). I am using AVRISPmkII.

What goes into:
1.”protocol”
2.”required_upload_port”
3.”speed”
Any other parameters needed?

This is my current board.json (mostly copied from: megaatmega2560)

{
"build": {
    "core": "arduino",
    "extra_flags": "-DARDUINO_AVR_MEGA2560",
    "f_cpu": "12000000L",
    "mcu": "atmega2560",
    "variant": "mega"
},
"fuses": {
    "efuse": "0xff",
    "hfuse": "0xdf",
    "lfuse": "0xff"
},
"name": "Custom m2560 Board 1",
"upload": {
    "maximum_ram_size": 8192,
    "maximum_size": 253952,
    "protocol": "stk500v2",
    "require_upload_port": true,
    "speed": 115200
}
}

Question 2: What goes into platformio.ini and what goes into board.json? It seems like most of the things are identical between the two?

Thank you for your patience with an utter noob on this. Cheers.

Edit: board.json description


#2

yes, I am also hoping to get answers on how to work with platform-io without Arduino framework. A plain native way to edit, compile and upload code using no bootloader but avrdude/usbasp.

No predefined board, just a controller on a breadboard or on my own pcb.

There are snippets here and there but no concise instructions on what goes where or where to start. It must be possible, because I pretty much like the idea of a central programming environment for me (and possibly my students) independent on what system we want to write code for…


#3

Not specifying a framework = .. will cause PIO to also not compile in a framework, so it’s perfectly possible, as we’ve e.g. shown in a thread about programming an ATTiny85 with bare assembly. As shown above, you can have your own board JSON file to define any macros or MCU you need.

For more information I’d need to to know the exact usecase.


#4

Thanks for the quick answer - and I will spend more time to understand how “boards”, “framework” and “toolchain” all work together with their separate setting files.

For a start I would like to be able to pick a bare “generic ATMega328” with either 1 MHz or 8 MHz internal oscillator. So from your answer I assume it’s enough to just create a new JSON file like the existing ATTiny ones.


#5

sadly the original posters questions were never answered, at least not here:

What goes into:
1.“core”
2."extra_flags”
3.“variants”?

What goes into:
1.”protocol”
2.”required_upload_port”
3.”speed”

Where is the documentation for these parameters (if any)?

Appendix
I got the compile part to work with this JSON-file, will have to try the upload later…

{
  "build": {
  "core": "mega",
  "extra_flags": "",
  "f_cpu": "1000000UL",
  "mcu": "atmega328",
  "variant": "standard"
},
"frameworks": [],
"name": "Generic ATmega328 1 MHz",
"upload": {
  "extra_flags": "-e",
  "maximum_ram_size": 2048,
  "maximum_size": 32768,
  "protocol": "usbasp",
  "flags": "-Pusb -s"
},
"url": "http://www.microchip.com/",
"vendor": "Atmel"
}