ESP32 Spiffs upload - application can't recognize uploaded SPIFFS image

Hi. I am trying to follow this example but after running an application I get “Mounting error”, after which the app formats the spiffs partition and reads an empty file.

# Name,   Type, SubType, Offset,  Size, Flags
# Note: if you have increased the bootloader size, make sure to update the offsets to avoid overlap
nvs,      data, nvs,     ,        0x6000,
phy_init, data, phy,     ,        0x1000,
factory,  app,  factory, ,        2M,
spiffs, data, spiffs, , 1M, 

I also tried storage, data, spiffs, , 1M, as last line.

my .ini file is like this

[env]
platform = espressif32
framework = arduino, espidf
build_flags = 
	-D CONFIG_BLINK_GPIO=2
  -D ESP32
monitor_speed = 115200
platform_packages = 
	framework-arduinoespressif32 @ https://github.com/marcovannoord/arduino-esp32.git#idf-release/v4.0

[env:esp32dev]
board = esp32dev
board_build.filesystem = spiffs

upload_port = COM10
board_build.partitions = partitions.csv

lib_deps = 
	ESP Async WebServer
  ESPAsyncTCP
	me-no-dev/ESPAsyncTCP@^1.2.2

There is a bug that the 0x10000 alignment for the app partition is not respected when using PlatformIO (Partition table parsing wrong · Issue #627 · platformio/platform-espressif32 · GitHub).

Change the partition table to

# Name,   Type, SubType, Offset,  Size, Flags
# Note: if you have increased the bootloader size, make sure to update the offsets to avoid overlap
nvs,      data, nvs,     ,        0x6000,
phy_init, data, phy,     ,        0x1000,
factory,  app,  factory, 0x10000, 2M,
spiffs, data, spiffs, , 1M, 

and retry.

1 Like

Oh… That explains a question I had when I saw an option for standard partition table offset 0x8000 - meaning the partition table is actually stuck between phy_init and factory in my case. Right?

The partition table describes your partitions, like phy_init. I’m not sure what you mean that the table is stuck between two partitions?

What happens is that ESP-IDF (and Arduino-ESP32) interpret the starting address of factory at 0x10000 because they add 0x6000 + 0x1000 and then align it to the next multiple of 0x10000. PlatformIO doesn’t do that last step and thinks factory is at 0x7000, and consequently the partition beyond it (SPIFFS) is shifted as well by 0x3000, causing the SPIFFS partition to be flashed at the wrong address in flash where the code can’t find it.


I meant this part

Oh I see. Yeah no idea about that – only know that the above fixes it.

I believe that 0x8000 is the space automatically added for the bootloader, which will not appear in the partition table - it’s added before the table’s 0x00 if I understand it correctly