How to edit boards\myBoard.json for 16MB flash

After years of struggling with an external editor and Arduino IDE (to compile and upload), I upgraded to Platformio and Everything works much better and easier. I developed my application using the adafruit feather but now made my own PCB and used a 16MB flash WROOM32 module.
I understand that I have to edit the board.json but the documentation I found on which fields are important is poor.
Obviously I have to change the “build”:{ “f_flash”:“4000000L” }and “upload”:{ “flash_size”:“4MB”} to 16000000L and 16MB respectively but what is the function of the parameters: “extra_flags”, “variant” and “name”?

Thank you in advance

Are you sure you don’t just want to use a pre-existing 16MB ESP32 board definition? Such as the Sparkfun ESP32 Thing Plus? That’s already tested…

  • extra_flags are extra compiler flags given into every (gcc/g++) compiler invocation. Usually used for adding a board-specific macro or a feature-enabling macro (like PSRAM). E.g., the odroid_esp32.json board has -DARDUINO_ODROID_ESP32 -DBOARD_HAS_PSRAM -mfix-esp32-psram-cache-issue.
  • variant must be the name of the Arduino variant folder if the board is supported in the Arduino IDE (in this case Arduino-ESP32). Valid names are, since PlatformIO is still using Arduino-ESP32 version 1.0.6 and not 2.0.0 (issue), listed at arduino-esp32/variants at 1.0.6 · espressif/arduino-esp32 · GitHub. Since you’re using a custom board there will be no variant for that board – the most generic definition is just esp32.
  • name is just a meta-information that’s displayed during the compilation as the board’s name. It has no effect on compilation.

Also, be aware that you’d maybe like to adapt the partition table used during compilation to make better use of your 16MB flash. The board definition can also incorporate this default setting.

Otherwise you’ll be using the default.csv table with just 1.25MB allocated for each application, as compared to default_16MB.csv with 6.25MB.

Thank you very much,

a very informative post and I’m starting to understand how everything fits together but I did not try changing the board to Sparkfun ESP32 Thing Plus since I’m afraid this will mess up my otherwise working project.

The big question is: Can I change the board and partition table of an existing project (without being an expert in Platformio) or is it better to start a new one from scratch and copy the src/ and data/ directories in it?

A further question is what are following text files in C:\Users\Panos.platformio\packages\framework-arduinoespressif32\ used for: boards.txt, platform.txt. Are they used at all? It seems to be the same piece of info scattered around in many places.

Is there in Platformio something similar to a make file that I can view before compilation and linking (and possibly edit at a later stage) to have more control or at least some insight?


You can change the partition table at any time. PlatformIO will just recompile the project with the new partition and it will upload and function as before (given your new partition table is enough to fit the application code and doesn’t e.g. make SPIFFS partition so small that your application logic breaks ;))

PlatformIO does not use the boards.txt for board information, it uses its JSON board definitions from the platform, or local ones in the boards/ folder of the project, if it exists.

In the same way, PlatformIO does not use the platform.txt to understand how an Arduino core is compiled, it re-implements the compile logic in Python (SCons) build scripts.

PlatformIO tells you all the compilation commands if you use the project task Advanced → Verbose Build.

If you need to edit compile flags, use build_flags and build_unflags accordingly. General configuration are listed in the documentation.