First change Partition Tables in Arduino:
Folder: C:\Users\XXXXX\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.0\tools\partitions
Create a New File, as Example "Storage.csv":
# Name,Type,SubType,Offset,Size,Flags nvs,data,nvs,0x9000,0x5000, otadata,data,ota,0xe000,0x2000, app0,app,ota_0,0x10000,0x140000, eeprom,data,0x99,0x150000,0x1000, storage,data,0x99,0x151000,0x200000, spiffs,data,spiffs,0x351000,0xaf000,
0,
Change board.txt for your Board:
Folder: C:\Users\XXXXX\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.0\
lolin32.menu.PartitionScheme.default=Default
lolin32.menu.PartitionScheme.default.build.partitions=default
lolin32.menu.PartitionScheme.no_ota=No OTA (Large APP)
lolin32.menu.PartitionScheme.no_ota.build.partitions=no_ota
lolin32.menu.PartitionScheme.no_ota.upload.maximum_size=2097152
lolin32.menu.PartitionScheme.min_spiffs=Minimal SPIFFS (Large APPS with OTA)
lolin32.menu.PartitionScheme.min_spiffs.build.partitions=min_spiffs
lolin32.menu.PartitionScheme.min_spiffs.upload.maximum_size=1966080
-->lolin32.menu.PartitionScheme.custom=Custom Storage
-->lolin32.menu.PartitionScheme.custom.build.partitions=storage
-->lolin32.menu.PartitionScheme.custom.upload.maximum_size=1966080
Make a Test Sketch and Upload it to reconfigure Partitions and check storage Partitioning in Board Menu before.
Now you can upload a Image with esp32 Flash Tool from here:
https://www.espressif.com/en/support/download/other-tools
Example Sketch:
#include "EEPROM.h"
const esp_partition_t* part;
spi_flash_mmap_handle_t handle;
void* data;
esp_err_t err;
void setup() {
part = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_ANY, "storage");
esp_partition_find(ESP_PARTITION_TYPE_DATA,ESP_PARTITION_SUBTYPE_ANY, "storage");
err = esp_partition_mmap(part, 0, part->size, SPI_FLASH_MMAP_DATA, (const void**)&data, &handle);
if (err != ESP_OK)
{
printf("esp_partition_mmap failed. (%d)\n", err);
//delay(10000);
abort();
}
//Example for Display data without overhead:
vspi->beginTransaction(SPISettings(spiClk, MSBFIRST, SPI_MODE0));
digitalWrite(5, LOW); //pull SS slow to prep other end for transfer
unsigned long offset=0;
vspi->writeBytes((uint8_t*)data + offset, width*height * 3);
digitalWrite(5, HIGH); //pull ss high
}
}
void loop(){
}