Uploadfs always fails

I have created a basic Hello World project in platformio to upload to an ESP32 Wrover Kit. I’m also using a custom partitions.csv with a SPIFFS partition. Building the app and flashing/monitoring the board works fine, and I’ve verified that the SPIFFS partition is created on the board, but uploadfs always fails. Even when I run it in verbose mode with pio run -v -t uploadfs there is no useful output other than “FAILED.”

Flashing the SPIFFS partition with the ESP-IDF tools works fine.

Does anyone have any ideas that might help me get uploadfs working?

Here’s my configuration:

SPIFFS directory in project:

<project_root>/data/hello_world.txt // echo "hello world" > hello_world.txt

platformio.ini:

[env:esp-wrover-kit]
platform = espressif32
board = esp-wrover-kit
board_build.partitions = partitions.csv
framework = espidf
monitor_port = /dev/cu.usbserial-14301
monitor_speed = 115200
upload_port = /dev/cu.usbserial-14301

partitions.csv:

# Name,   Type, SubType, Offset,   Size, Flags
# Note: if you change the phy_init or app partition offset, make sure to change the offset in Kconfig.projbuild
nvs,      data, nvs,     ,        0x4000,
otadata,  data, ota,     ,        0x2000,
phy_init, data, phy,     ,        0x1000,
ota_0,    app,  ota_0,   ,        0x100000,
ota_1,    app,  ota_1,   ,        0x100000,
storage,  data, 0x82,	 ,	      0x1f0000

Output of uploadfs command:

$ pio run -v -t uploadfs

Processing esp-wrover-kit (platform: espressif32; board: esp-wrover-kit; board_build.partitions: partitions.csv; framework: espidf; monitor_port: /dev/cu.usbserial-14301; monitor_speed: 115200; upload_port: /dev/cu.usbserial-14301)
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp-wrover-kit.html
PLATFORM: Espressif 32 1.12.2 > Espressif ESP-WROVER-KIT
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (ftdi) On-board (ftdi) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES: 
 - framework-espidf 3.40001.200521 (4.0.1) 
 - tool-cmake 3.16.4 
 - tool-esptoolpy 1.20600.0 (2.6.0) 
 - tool-mkspiffs 2.230.0 (2.30) 
 - tool-ninja 1.9.0 
 - toolchain-esp32ulp 1.22851.190618 (2.28.51) 
 - toolchain-xtensa32 2.80200.200226 (8.2.0)
Reading CMake configuration...
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
==  [FAILED] Took 1.42 seconds ==

Thank you!

Don’t you want the Type to be storage there and the sub-type to be spiffs? Like in the docs and the Arduino ref?

What reference do you have for your partitions.csv?

Hi Max,

First of all, thank you very much for taking the time to reply to this post and the one I posted last week. I appreciate it.

Second, yes! You fixed it. The problem is that the subtype field needed the word “spiffs”.

Subtype 0x82 is the spiffs partition subtype:

from esp_partition.h:

ESP_PARTITION_SUBTYPE_DATA_SPIFFS = 0x82, //!< SPIFFS partition

but apparently PlatformIO just needed to see “spiffs”.

I’ve changed the relevant partitions.csv line to:

storage, data, spiffs, , 0x1f0000

(“storage” is just the name of the partition - it could be anything)

and everything works.

Thank you again!!

Brian

I’m going to leave another comment here in case anyone comes across this in the future. If someone from PlatformIO team thinks I should file a bug please let me know where to do it.

I have been trying to get spiffs up and running all day and I finally figured out the problem. Using the partitions.csv file I published above:

# Name,   Type, SubType, Offset,   Size, Flags
# Note: if you change the phy_init or app partition offset, make sure to change the offset in Kconfig.projbuild
nvs,      data, nvs,     ,        0x4000,
otadata,  data, ota,     ,        0x2000,
phy_init, data, phy,     ,        0x1000,
ota_0,    app,  ota_0,   ,        0x100000,
ota_1,    app,  ota_1,   ,        0x100000,
storage,  data, spiffs,	 ,	      0x1f0000

Causes the platformio run -t uploadfs command to upload a filesystem image, but for some reason it is calculating the partition offsets incorrectly. I finally noticed this in the uploadfs output:

Uploading .pio/build/wrover/spiffs.bin
...
Writing at 0x00207000... (100 %)

However, the correct offset for the start of my SPIFFS partition is 0x00210000, not 0x00207000. So the esp partition loader was getting garbage data and failing to initialize.

If I manually enter the partition offsets like so:

# Name,   Type, SubType, Offset,   Size, Flags
# Note: if you change the phy_init or app partition offset, make sure to change the offset in Kconfig.projbuild
nvs,      data, nvs,     0x9000,        0x4000,
otadata,  data, ota,     0xd000,        0x2000,
phy_init, data, phy,     0xf000,        0x1000,
ota_0,    app,  ota_0,   0x010000,      0x100000,
ota_1,    app,  ota_1,   0x110000,      0x100000,
spiffs,  data, spiffs,   0x210000,      0x1f0000

Then uploadfs flashes the spiffs.bin file to the correct offset, 0x210000 and everything works as it should.