Arduino core for ESP32 Wiki content

Change partition size

OUTDATED! ARDUINO IDE HAS NOW MANY PARTITIONS TO SELECT FROM!

[EDIT 1]

If using Arduino IDE go to my post ‘Change partition size (Arduino IDE)‘ which is focused on Arduino IDE and might be less confusing than this here (which is mixing ArduinoIDE and PlatformIO).

[EDIT 2]

If using PlatformIO (on Atom or Visual Code) there is now as well another postChange partition size (PlatformIO)that is focused on changes required for PlatformIO .

 

To change the partition sizes, e.g. because the program doesn’t fit anymore into the default partition size, there are 3 possibilities:

  1. change the default partition table, this affects all ESP32 boards
    this method is the easiest if the new partition sizes will be used for all projects and all boards
  2. create a new partition table only for a specific ESP32 board
    this method can be used if the new partition sizes will be used for all projects but only for a specific board
  3. clone an existing device and create a partition table only for this device
    this method can be used if the new partition sizes will be used only for a specific project and a specific board

If the partition sizes are changed there is 1 main rule: The start addresses of the partitions must be a multiple of 0x1000!

Remark 1: At least in PlatformIO the partition sizes change only if you flash the board over USB/Serial. If the board is flashed over ArduinoOTA, the partition sizes do not change!

Remark 2: This change will be lost if the ESP32 package is updated !

The default partition table default.csv is located at

for PlatformIO: .platformio\packages\framework-arduinoespressif32\tools\partitions\default.csv
for Arduino IDE: Arduino\hardware\espressif\esp32\tools\partitions\default.csv

The default partition table looks like:

# Name,   Type, SubType, Offset,  Size, Flags
nvs,      data, nvs,     0x9000,  0x5000,
otadata,  data, ota,     0xe000,  0x2000,
app0,     app,  ota_0,   0x10000, 0x140000,
app1,     app,  ota_1,   0x150000,0x140000,
eeprom,   data, 0x99,    0x290000,0x1000,
spiffs,   data, spiffs,  0x291000,0x16F000,

A partition table with maximum size for the application and no EEPROM and SPIFFS partition could look like:

# Name,   Type, SubType, Offset,  Size, Flags
nvs,      data, nvs,     0x9000,  0x5000,
otadata,  data, ota,     0xe000,  0x2000,
app0,     app,  ota_0,   0x10000, 0x1F0000,
app1,     app,  ota_1,   0x200000,0x200000,

Another example with a small EEPROM and SPIFFS partition:

# Name,   Type, SubType, Offset,  Size, Flags
nvs,      data, nvs,     0x9000,  0x5000,
otadata,  data, ota,     0xe000,  0x2000,
app0,     app,  ota_0,   0x10000, 0x1E0000,
app1,     app,  ota_1,   0x1F0000,0x1E0000,
eeprom,   data, 0x99,    0x3F0000,0x1000,
spiffs,   data, spiffs,  0x3F1000,0xF000,

Method 1

  1. Change the entries of default.csv to your desired partition sizes. (See paths above)
  2. In .platformio\platforms\espressif32\boards find the .json file matching with your board. In this example edit .platformio\platforms\espressif32\boards\esp32dev.json (or whatever board you use). Change “maximum_size”: 1310720 to “maximum_size”: 1966080 (or whatever partition size you defined for the app0 and app1 partitions)
  3. Open .platformio\packages\framework-arduinoespressif32\boards.txt. Find your matching board in the file. In this example it is esp32.name=ESP32 Dev Module. For your board change the entry xxx.upload.maximum_size=1310720 to xxx.upload.maximum_size=1966080  (or whatever partition size you defined for the app0 and app1 partitions)
  4. Reflash your board over USB/Serial

Method 2

[Reference issue 703] from @delcomp

  1. Make a copy of esp32/tools/partitions/default.csv and rename it (my example partitions.csv) (See paths above)
  2. Make the required changes
  3. Open esp32/boards.txt and find the board (<YOUR_BOARD_NAME>)you are using
  4. Make the following changes (size depends on your configuration)

#<YOUR_BOARD_NAME>.upload.maximum_size=1310720 
<YOUR_BOARD_NAME>.upload.maximum_size=1835008 # Here goes your new app partition size !!! 
#<YOUR_BOARD_NAME>.build.partitions=default 
<YOUR_BOARD_NAME>.build.partitions=partitions # Here goes your new app partition size file name!!!

  1. In .platformio\platforms\espressif32\boards edit esp32dev.json (or whatever board you are using) and add “partitions”: “partitions.csv” into the build object. It should look like

{
  "build": {
    "core": "esp32",
    "extra_flags": "-DARDUINO_ESP32_DEV",
    "f_cpu": "240000000L",
    "f_flash": "40000000L",
    "flash_mode": "dio",
    "ldscript": "esp32_out.ld",
    "mcu": "esp32",
    "variant": "esp32",
    "partitions": "partitions"
  },
  "connectivity": [
    "wifi",
    "bluetooth",
    "ethernet",
    "can"
  ],
  "frameworks":  [
    "arduino",
    "espidf"
  ],
  "name": "Espressif ESP32 Dev Module MaxAppPart",
  "upload": {
    "flash_size": "4MB",
    "maximum_ram_size": 294912,
    "maximum_size": 1966080,
    "require_upload_port": true,
    "speed": 115200,
    "wait_for_upload_port": true
  },
  "url": "https://en.wikipedia.org/wiki/ESP32",
  "vendor": "Espressif"
}

  1. Reflash your board over USB/Serial

Method 3

In this example I go for the maximum app partition size (0x1F0000) and no EEPROM and no SPIFFS partition. If you change to a different partition size you need to adapt the value 2031616 (== 0x1F0000) to the value of your partition size. E.g. a partition size of 0x1E0000 would equal to a value of 1966080 inside the different files.

  1. Make a copy of default.csv and rename it (my example partitions.csv)
  2. Make the required changes
  3. In boards.txt make a copy of the board you want to clone.
    e.g make a copy of the ESP32 Dev Module and name it as ESP32 Dev Module MaxAppPart:

##############################################################

esp32maxapp.name=ESP32 Dev Module MaxAppPart # Here goes your new board name !!!**

esp32maxapp.upload.tool=esptool
esp32maxapp.upload.maximum_size=2031616 # Here goes your new app partition size !!!**
esp32maxapp.upload.maximum_data_size=294912
esp32maxapp.upload.wait_for_upload_port=true

esp32maxapp.serial.disableDTR=true
esp32maxapp.serial.disableRTS=true

esp32maxapp.build.mcu=esp32
esp32maxapp.build.core=esp32
esp32maxapp.build.variant=esp32
esp32maxapp.build.board=ESP32_MAXAPP # Here goes your new board name !!!**

esp32maxapp.build.f_cpu=240000000L
esp32maxapp.build.flash_size=4MB
esp32maxapp.build.flash_freq=40m
esp32maxapp.build.flash_mode=dio
esp32maxapp.build.boot=dio
esp32maxapp.build.partitions=partitions # Here goes your new app partition size file name!!!**

esp32maxapp.menu.FlashMode.qio=QIO
esp32maxapp.menu.FlashMode.qio.build.flash_mode=dio
esp32maxapp.menu.FlashMode.qio.build.boot=qio
esp32maxapp.menu.FlashMode.dio=DIO
esp32maxapp.menu.FlashMode.dio.build.flash_mode=dio
esp32maxapp.menu.FlashMode.dio.build.boot=dio
esp32maxapp.menu.FlashMode.qout=QOUT
esp32maxapp.menu.FlashMode.qout.build.flash_mode=dout
esp32maxapp.menu.FlashMode.qout.build.boot=qout
esp32maxapp.menu.FlashMode.dout=DOUT
esp32maxapp.menu.FlashMode.dout.build.flash_mode=dout
esp32maxapp.menu.FlashMode.dout.build.boot=dout

esp32maxapp.menu.FlashFreq.80=80MHz
esp32maxapp.menu.FlashFreq.80.build.flash_freq=80m
esp32maxapp.menu.FlashFreq.40=40MHz
esp32maxapp.menu.FlashFreq.40.build.flash_freq=40m

esp32maxapp.menu.FlashSize.4M=4MB (32Mb)
esp32maxapp.menu.FlashSize.4M.build.flash_size=4MB
esp32maxapp.menu.FlashSize.2M=2MB (16Mb)
esp32maxapp.menu.FlashSize.2M.build.flash_size=2MB
esp32maxapp.menu.FlashSize.2M.build.partitions=minimal

esp32maxapp.menu.UploadSpeed.921600=921600
esp32maxapp.menu.UploadSpeed.921600.upload.speed=921600
esp32maxapp.menu.UploadSpeed.115200=115200
esp32maxapp.menu.UploadSpeed.115200.upload.speed=115200
esp32maxapp.menu.UploadSpeed.256000.windows=256000
esp32maxapp.menu.UploadSpeed.256000.upload.speed=256000
esp32maxapp.menu.UploadSpeed.230400.windows.upload.speed=256000
esp32maxapp.menu.UploadSpeed.230400=230400
esp32maxapp.menu.UploadSpeed.230400.upload.speed=230400
esp32maxapp.menu.UploadSpeed.460800.linux=460800
esp32maxapp.menu.UploadSpeed.460800.macosx=460800
esp32maxapp.menu.UploadSpeed.460800.upload.speed=460800
esp32maxapp.menu.UploadSpeed.512000.windows=512000
esp32maxapp.menu.UploadSpeed.512000.upload.speed=512000

esp32maxapp.menu.DebugLevel.none=None
esp32maxapp.menu.DebugLevel.none.build.code_debug=0
esp32maxapp.menu.DebugLevel.error=Error
esp32maxapp.menu.DebugLevel.error.build.code_debug=1
esp32maxapp.menu.DebugLevel.warn=Warn
esp32maxapp.menu.DebugLevel.warn.build.code_debug=2
esp32maxapp.menu.DebugLevel.info=Info
esp32maxapp.menu.DebugLevel.info.build.code_debug=3
esp32maxapp.menu.DebugLevel.debug=Debug
esp32maxapp.menu.DebugLevel.debug.build.code_debug=4
esp32maxapp.menu.DebugLevel.verbose=Verbose
esp32maxapp.menu.DebugLevel.verbose.build.code_debug=5

##############################################################

  1. change the .upload.maximum_size to your new app partition size, in the example esp32maxapp.upload.maximum_size=2031616
  2. change the esp32maxapp.build.partitions name to your new partition table name, in the example esp32maxapp.build.partitions=maxapp
  3. change the esp32maxapp.name name to your new board name, in the example esp32maxapp.name=ESP32 Dev Module MaxAppPart
  4. change the esp32maxapp.build.board name to your new board name, in the example esp32maxapp.build.board=ESP32_DEV_MAXAPP
  5. (FOR PLATFORMIO) make a copy of the json file describing the board you cloned, in this example .platformio\platforms\espressif32\boards\esp32dev.json and name it esp32maxapp.json. Change in esp32maxapp.json “variant”: “esp32” to “variant”: “esp32maxapp” “name”: “Espressif ESP32 Dev Module” to “name”: “Espressif ESP32 Dev Module MaxAppPart”. Change “maximum_size”: 1310720 to “maximum_size”: 2031616 and add “partitions”: “partitions” in the build block. Example:

{
  "build": {
    "core": "esp32",
    "extra_flags": "-DARDUINO_ESP32_DEV",
    "f_cpu": "240000000L",
    "f_flash": "40000000L",
    "flash_mode": "dio",
    "ldscript": "esp32_out.ld",
    "mcu": "esp32",
    "variant": "esp32maxapp",
    "partitions": "partitions"
  },
  "connectivity": [
    "wifi",
    "bluetooth",
    "ethernet",
    "can"
  ],
  "frameworks":  [
    "arduino",
    "espidf"
  ],
  "name": "Espressif ESP32 Dev Module MaxAppPart",
  "upload": {
    "flash_size": "4MB",
    "maximum_ram_size": 294912,
    "maximum_size": <strong>2031616</strong>,
    "require_upload_port": true,
    "speed": 115200,
    "wait_for_upload_port": true
  },
  "url": "https://en.wikipedia.org/wiki/ESP32",
  "vendor": "Espressif"
}

  1. (FOR PLATFORMIO) change in your projects platformio.ini the entry board = esp32dev to board = esp32maxapp
  2. (FOR PLATFORMIO) copy .platformio\packages\framework-arduinoespressif32\variants\esp32 to .platformio\packages\framework-arduinoespressif32\variants\esp32maxapp
  3. (FOR ARDUINO IDE) change in menu Tools→Board to Espressif ESP32 Dev Module MaxAppPart
  4. Reflash your board over USB/Serial