How to use custom board information in platformio.ini?


I’ve a custom board.json containing a key/value “f_cpu”: 48000000. I would like to set a define in platformio.ini when this board is selected to “-DF_CPU=48000000”.

Is it possible to do so without an extra script ? If yes, how ?
Else, what’s the cleanest way to do it with an extra script ?


This already happens on some platforms and needs no extra configuration.

What’s the full platformio.ini?

I’m using Marlin’s platformio.ini. You are right, env[“BOARD_F_CPU”] is already defined, so it’s very easy to add to the build flags. Thanks!

As referenced for any environment that uses platform = atmelavr it already does the -D F_CPU=.. macro. Just for some others that may not be the default – if you can say which exactly, that can be added as an improvement in the existing cores.