ESP32 Customizing Partition in PlatformIO

Hey me from the past, I know you have tried to develop a smart project with ESP32, both Bluetooth and WiFi enabled. However, you got an error like this

RAM:   [==        ]  18.0% (used 58860 bytes from 327680 bytes)
Error: The program size (1479570 bytes) is greater than maximum allowed (1310720 bytes)
*** [checkprogsize] Explicit exit, status 1
Flash: [==========]  112.9% (used 1479570 bytes from 1310720 bytes)

You don’t believe that a hardware that is designed for IoT application not being able to program both Bluetooth and WiFi together. After all, all you did is include 4 basic libraries.

#include <Arduino.h>
#include <BluetoothSerial.h>
#include <WiFi.h>
#include <HTTPClient.h>

So what happened there? The reason is, the default partition for ESP32 (Arduino Framework) is only 1MB in size. The last time you checked ESP32 Documentation, it says that it has a total of 4MB of Flash memory.

The Solution


  • Visual Studio Code with PlatformIO

Step 1 – Finding project’s platformio.ini

Go to Visual Studio Code > Explorer (Ctrl+Shift+E) > Workspace > {Project Folder} > platformio.ini

Step 2 – Add customized partitions

In platformio.ini, add the following line (board_build.partitions) to change the partition size

platform = espressif32
board = esp32dev
framework = arduino
monitor_speed = 115200
board_build.partitions = no_ota.csv

Step 3 – Celebrate that you solved your problem!

RAM:   [==        ]  18.0% (used 58860 bytes from 327680 bytes)
Flash: [=======   ]  70.6% (used 1479570 bytes from 2097152 bytes)

You are welcome!

That is all you need to know if you need to continue your projects quickly.

However! I know that your curious head wants to know how does the no_ota.csv works, and how you can customize it further. You can read how it works in the next blog post. In the meantime, the documentation for customizing the partition table is here.

2 thoughts on “ESP32 Customizing Partition in PlatformIO”

  1. Awesome, thankyou so much for posting this – it saved my demo! I didn’t have to switch to link script debugging.

    I had used:

    lib_deps = h2zero/NimBLE-Arduino@^1.3.1

    And a new library I just wrote (very small itself, but uses AES crypto) and that got me to 104%!! I figured there must be a link script hack for the larger ESP32’s but this is easier.

    It makes sense that removing the OTA update partition would be the safest way to solve this. But like you say – there’s even more to be had in there, if required.

  2. I like to add the information that there are other options to extend the sketch size: your option

    board_build.partitions = no_ota.csv

    results in ~2MB for the sketch, and ~2MB for SPIFFS. For those who do not need the SPIFFS, but maybe like to keep OTA,

    board_build.partitions = min_spiffs.csv

    could be more interesting, as it also offers ~2MB for the sketch(es), but instead reduces the SPIFFS to ~200kb.


Leave a Comment