Introduction
An ESP32 flash can contain more than one app, and various types of information (file systems, parameter storage, calibration data, etc.). Because of this reason, there is a partition table that is flashed to 0x8000 in the flash (considering the default offset). The length of the partition table is 0xC00 bytes, with a maximum of 95 entries. There is also a MD5 checksum to check the integrity of the partition table, appended after the table data. Each one of the partition table entries has a name (also called label), a type (app, data, etc.), a subtype and the offset in flash where the partition is loaded. One of the main purposes of partitioning schemes is, for example, to split a large code in multiple parts so it can be uploaded to the device. You will see how to do it in this post.Â
Requirements
The key points you should consider are as follows:Â
Industrial ESP32 based PLC (10 I/Os PLC Family or ESP32 PLC Family)
Industrial Shields Boards  Read >>
Related links
Explanation
First of all, open the Boards document located at the following path in Windows (and the equivalent on Linux, always considering that there may be some differences depending on the location of the path):Â
C:\Users\User_Name\AppData\Local\Arduino15\packages\industrialshields\hardware\esp32\1.0.8
This is the Industrial Shields ESP32 configuration file. Although it has a lot of configuration parameters, let's focus on this part:Â
################################################## ESP32 PLC #######################################################################esp32plc.name=ESP32 PLC Familyesp32plc.upload.tool=esptool_pyesp32plc.upload.maximum_size=1310720esp32plc.upload.maximum_data_size=327680esp32plc.upload.wait_for_upload_port=trueesp32plc.upload.speed=460800esp32plc.serial.disableDTR=trueesp32plc.serial.disableRTS=trueesp32plc.build.mcu=esp32esp32plc.build.core=industrialshieldsesp32plc.build.board=ESP32_DEVesp32plc.build.f_cpu=240000000Lesp32plc.build.flash_mode=dioesp32plc.build.flash_size=4MBesp32plc.build.boot=dioesp32plc.build.partitions=defaultesp32plc.build.defines=esp32plc.build.flash_freq=80mesp32plc.build.code_debug=0
The other document to consider is the one found in this path in Windows:Â
C:\Users\User_Name\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4
It is also called Boards, but this is the default configuration file for ESP32. From here, let's focus on the different Partition Scheme options:Â
esp32.menu.PartitionScheme.default=Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS) esp32.menu.PartitionScheme.default.build.partitions=default esp32.menu.PartitionScheme.defaultffat=Default 4MB with ffat (1.2MB APP/1.5MB FATFS) esp32.menu.PartitionScheme.defaultffat.build.partitions=default_ffat esp32.menu.PartitionScheme.default_8MB=8M Flash (3MB APP/1.5MB FAT) esp32.menu.PartitionScheme.default_8MB.build.partitions=default_8MB esp32.menu.PartitionScheme.default_8MB.upload.maximum_size=3342336 esp32.menu.PartitionScheme.minimal=Minimal (1.3MB APP/700KB SPIFFS) esp32.menu.PartitionScheme.minimal.build.partitions=minimal esp32.menu.PartitionScheme.no_ota=No OTA (2MB APP/2MB SPIFFS) esp32.menu.PartitionScheme.no_ota.build.partitions=no_ota esp32.menu.PartitionScheme.no_ota.upload.maximum_size=2097152 esp32.menu.PartitionScheme.noota_3g=No OTA (1MB APP/3MB SPIFFS) esp32.menu.PartitionScheme.noota_3g.build.partitions=noota_3g esp32.menu.PartitionScheme.noota_3g.upload.maximum_size=1048576 esp32.menu.PartitionScheme.noota_ffat=No OTA (2MB APP/2MB FATFS) esp32.menu.PartitionScheme.noota_ffat.build.partitions=noota_ffat esp32.menu.PartitionScheme.noota_ffat.upload.maximum_size=2097152 esp32.menu.PartitionScheme.noota_3gffat=No OTA (1MB APP/3MB FATFS) esp32.menu.PartitionScheme.noota_3gffat.build.partitions=noota_3gffat esp32.menu.PartitionScheme.noota_3gffat.upload.maximum_size=1048576 esp32.menu.PartitionScheme.huge_app=Huge APP (3MB No OTA/1MB SPIFFS) esp32.menu.PartitionScheme.huge_app.build.partitions=huge_app esp32.menu.PartitionScheme.huge_app.upload.maximum_size=3145728 esp32.menu.PartitionScheme.min_spiffs=Minimal SPIFFS (1.9MB APP with OTA/190KB SPIFFS) esp32.menu.PartitionScheme.min_spiffs.build.partitions=min_spiffs esp32.menu.PartitionScheme.min_spiffs.upload.maximum_size=1966080 esp32.menu.PartitionScheme.fatflash=16M Flash (2MB APP/12.5MB FAT) esp32.menu.PartitionScheme.fatflash.build.partitions=ffat esp32.menu.PartitionScheme.fatflash.upload.maximum_size=2097152 esp32.menu.PartitionScheme.app3M_fat9M_16MB=16M Flash (3MB APP/9MB FATFS) esp32.menu.PartitionScheme.app3M_fat9M_16MB.build.partitions=app3M_fat9M_16MB esp32.menu.PartitionScheme.app3M_fat9M_16MB.upload.maximum_size=3145728
In the second file, we can see all the available Partition Scheme options, which can also be consulted in csv format in this other path in Windows:Â
C:\Users\User_Name\AppData\Local\Arduino15\packages\industrialshields\hardware\esp32\1.0.8\tools\partitions
Once you have selected the Partition Scheme configuration that you are going to use, you have to put its name in the partitions parameter of the first file. Apart from that, you also have to open the csv document of the configuration that we have chosen to consult the app size (the bold one. In this case we are going to take huge_app as an example).Â
# Name, Type, SubType, Offset, Size, Flagsnvs, data, nvs, 0x9000, 0x5000,otadata, data, ota, 0xe000, 0x2000,app0, app, ota_0, 0x10000, 0x300000,eeprom, data, 0x99, 0x310000,0x1000,spiffs, data, spiffs, 0x311000,0xEF000,
############################################ ###### ESP32 PLC ########################### ############################################ esp32plc.name=ESP32 PLC Family esp32plc.upload.tool=esptool_py esp32plc.upload.maximum_size=3145728 esp32plc.upload.maximum_data_size=327680 esp32plc.upload.wait_for_upload_port=true esp32plc.upload.speed=460800 esp32plc.serial.disableDTR=true esp32plc.serial.disableRTS=true esp32plc.build.mcu=esp32 esp32plc.build.core=industrialshields esp32plc.build.board=ESP32_DEV esp32plc.build.f_cpu=240000000L esp32plc.build.flash_mode=dio esp32plc.build.flash_size=4MB esp32plc.build.boot=dio esp32plc.build.partitions=huge_app esp32plc.build.defines= esp32plc.build.flash_freq=80m esp32plc.build.code_debug=0
And that is all, now you only have to compile and upload the code with Arduino IDE by selecting the right device and port.Â
How to make partition scheme in ESP32 industrial PLC