ESP32 Out of Memory Error and Flash ROM Partitioning
ESP32 Out of Memory Error and Flash ROM Partitioning
A Determine how much Flash ROM and PSRAM memory the ESP32 have:
• If you are not sure or does not know the amount of memory available on your device, please run the
“ESP32_Determine_Flash_memory_patitioning.ino” sketch which will print via the serial port the memory
details and the current flash ROM partitions allocated on your device.
• If an ESP32 module is labelled N16R8, it means that 16 Mb of Flash ROM is available for partitioning and 8
Mb of RAM named PSRAM are added using SPI bus.
• You must enable the PSRAM in the tools menu in Arduino before you can use it.
• Partition table: Contains information about the layout of the flash. This table defines the names, types, and
sizes of each partition on the flash memory, allowing the ESP32 to understand where each partition starts and
ends.
o nvs (Non-Volatile Storage): Stores key-value pairs for non-volatile data. Used to store persistent
configuration data, like Wi-Fi credentials, settings, or calibration values. NVS is designed to be robust,
allowing you to save and retrieve data without worrying about flash wear and data integrity.
o phy_init: Stores PHY (Physical Layer) calibration data. This partition holds calibration data for the Wi-Fi
and Bluetooth hardware. It is set up during the initial calibration of the ESP32 and retained to avoid re-
calibration on every boot, which helps speed up connectivity initialization.
o factory app: Holds the main application firmware. This is the default application partition that runs when
the ESP32 is powered on or reset, unless an OTA (Over-The-Air) update app is set to run. If there’s no
OTA functionality, this partition typically holds the main application code.
o ota_0, ota_1 (optional): Used for OTA firmware updates. These partitions allow the ESP32 to store
multiple versions of firmware, enabling it to switch between them during an update. For example, during
an OTA update, the new firmware might be loaded into `ota_1` while the device continues running
`ota_0`. If the new firmware is successfully verified, the ESP32 will switch to the updated firmware on
reboot.
o spiffs or fat (optional): Used as a file system partition. These file system partitions allow storing files on
the ESP32, such as configuration files, images, or HTML files for a web server. SPIFFS (SPI Flash File
System) is more common in smaller ESP32 projects, while FAT is used if compatibility with external tools
is required, as it allows larger file sizes and multiple directory levels.
• The sizes and locations of each partition is configurable based on your project’s requirements.
• Ensure that you understand the function and use of each partition type by reading the reference.
C If you have out of memory or partitioning problems or want to create a custom partition table, there is an
excellent reference video and tool available to solve the problems.