PlatformIO Community

ESP32 SPIFFS .... hard hard hard times

Please, help me figuring out what happens with my SPIFFS. I’ve been reading a lot, but despite all theoretical knowledge I’ve ben acquiring, I can’t make things happen.

I’ve been trying to run the example program within:

just to check how do my SPIFFS partitions look like, but I’m far away of getting some reasonable result.

I really can’t go straight with this VSCode+PlatformIO. I’ve been trying hard everyday, but no result so far. What am I doing wrong?


This tutorial conviently does not mention that if you create a custom partition table CSV you need to reference it in the menuconfig.

To enter menuconfig in PlatformIO, see docs.

For ESP-IDF, you also have to mention your partition table in the platformio.ini.

Only then you have a chance of a partition being found.

Of course you should also create a data/ folder and put a test file on it so that gets uploaded when execute the “Upload Filesystem Image” task.

A PlatformIO reference project that does all that is also available at platform-espressif32/examples/espidf-storage-spiffs at develop · platformio/platform-espressif32 · G.

If all you want to do is see the partition, this is easily done with 2 ESP tools run from the terminal: read_flash 0x8000 0xc00 ptable.img ptable.img

This gives an output like (for LittleFS; would be exactly the same for SPIFFS):

    Parsing binary partition input...
    Verifying table...
    # Espressif ESP32 Partition Table
    # Name, Type, SubType, Offset, Size, Flags

However, I would think hard before using SPIFFS - prefer FFat or LittleFS (ESP32 mit SPIFFS - eine Speicher Katastrophe - Deutsch - Arduino Forum )

Hello Ullix

This command finds 3 serial ports, but it tries to open only my iPhone via WirelessiAP!
How to make it target the ESP32 specifically?
Here you are:

MacBook-Pro-de-Ciro:~ cirobruno$ python /Particular/Projetos/espressif/esp32/tools/ read_flash 0x8000 0xc00 ptable.img v3.2-dev
Found 3 serial ports
Serial port /dev/cu.iPhoneCiro-WirelessiAP
Traceback (most recent call last):
  File "/Particular/Projetos/espressif/esp32/tools/", line 4830, in <module>
  File "/Particular/Projetos/espressif/esp32/tools/", line 4823, in _main
  File "/Particular/Projetos/espressif/esp32/tools/", line 4283, in main
  File "/Particular/Projetos/espressif/esp32/tools/", line 118, in get_default_connected_device
  File "/Particular/Projetos/espressif/esp32/tools/", line 364, in detect_chip
    detect_port = ESPLoader(port, baud, trace_enabled=trace_enabled)
  File "/Particular/Projetos/espressif/esp32/tools/", line 323, in __init__
    self._port = serial.serial_for_url(port)
  File "/Users/cirobruno/Library/Python/2.7/lib/python/site-packages/serial/", line 88, in serial_for_url
  File "/Users/cirobruno/Library/Python/2.7/lib/python/site-packages/serial/", line 268, in open
    raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg))
serial.serialutil.SerialException: [Errno 16] could not open port /dev/cu.iPhoneCiro-WirelessiAP: [Errno 16] Resource busy: '/dev/cu.iPhoneCiro-WirelessiAP'

I’ve read your post. And I’m really getting worried about the reliability of all that I’ve been trying to do lately.

I felt forced to switch from Arduino IDE to VSCode, BECAUSE OF SPIFFS. But now I fell like walking over mud. Nothing seems to work properly. Everything in this environment depends on a lot of terminal line commands. I just can’t focus on the application I must write itself.

I’ve installed VSCode about two years ago, but I’ve never been able to make something work, not exactly because of the code. I’ve tried to migrate working codes from Arduino, but because of this or that, they wouldn’t run in VSCode.

It’s like driving an old clunker that stops from time to time and you must open the Motorabdeckung and try to fix something. When it’s ready, you’ve already forgotten that you was supposed to catch your children at school in your way home. Too messy. They must think it over. I don’t think I should deviate my attention from the application my customer is waiting for to dedicate on improving my terminal skills.

And now, I can see consistency in your report. Maybe I shouldn’t have abandoned Arduino because of SPIFFS, but abandone VSCode and keep using Arduino IDE without SPIFFS.

By the way, I’ve been using Arduino very successfully up to Arduino Pro IDE. Then they’ve moved to Arduino IDE 2.0, writing it from scratch. Obviously it’s showing some instability. I’m seriously thinking about going back to Arduino Pro IDE or Arduino IDE 1.8.15. I’ve written several very reliable projects with these.

Thank you.

Thank you.

The problem is that I’ve got no idea of how the flash is currently partitioned. Maybe I should try it using each standard partition option at once. But it’s gonna take too long.

I guess I won’t choose the way of learning how to use menuconfig. I’ve already been for too long far away from my way to continue my project. During the last week, I’ve been exclusively trying to learn about VSCode and PlatformIO. Now I’ve got the feeling that I’ve been wasting time. I must think about some other way to continue.

I don’t like the idea of placing the web page files (HTML, CSS and JS files) on SD Card. Someone may take it away and corrupt it, or maybe some vibration causes contacting troubles. But now it looks like the best alternative I have at this moment. In my next project maybe I’m gonna choose etching another PCB with an extra flash that I can use without concerns.

Thank you.

You yourself choose how the flash is partitioned by giving it a partition table. The CSV tells you exactly how the flash is partitioned, with the type of the partition, start address and length fo the partition. That is the content of flash. I don’t get your question.

In ESP-IDF, menuconfig is also exactly the way how you would configure the partition table. It’s just a different command in PlatformIO to enter it. There is no added difficulty. You’ll have to do exactly the same procedure in ESP-IDF.

It found 3 serial ports and chose the wrong one – select the correct device with a -p <device name> argument.

For some reason, the device became irresponsive after my first try to save something in SPIFFS. Then I had to make a grounded GPIO0 to flash the main code again. So, I don’t thrust the partition table is uncorrupt. That’s why I’d like to take a look at it.

What should I use for ?

I’ve already tried
“python /Particular/Projetos/espressif/esp32/tools/ read_flash 0x8000 0xc00 ptable.img -p ttgo-lora32-v21”
“python /Particular/Projetos/espressif/esp32/tools/ read_flash 0x8000 0xc00 ptable.img -p /dev/cu.SLAB_USBtoUART”

It reports “esptool: error: unrecognized arguments”.

The -p /dev/cu.SLAB_USBtoUART argument must come after, not at the end.

python /Particular/Projetos/espressif/esp32/tools/ --help

can be used to view the help page.

Good. It has run. I’ve received:

"[MacBook-Pro-de-Ciro:~ cirobruno$ python /Particular/Projetos/espressif/esp32/tools/ -p /dev/cu.SLAB_USBtoUART read_flash 0x8000 0xc00 ptable.img v3.2-dev
Serial port /dev/cu.SLAB_USBtoUART
Detecting chip type… ESP32
Chip is ESP32-PICO-D4 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, Embedded Flash, VRef calibration in efuse, Coding Scheme None
WARNING: Detected crystal freq 41.01MHz is quite different to normalized freq 40MHz. Unsupported crystal in use?
Crystal is 40MHz
MAC: d8:a0:1d:69:be:50
Uploading stub…
Running stub…
Stub running…
3072 (100 %)
3072 (100 %)
Read 3072 bytes at 0x8000 in 0.3 seconds (85.8 kbit/s)…
Hard resetting via RTS pin…

So, please, what should I understand from that?

That it’s downloaded the contents of flash you specified into the file ptable.img. As said above

If you’ve correctly setup an application to be flashed with one particular partition table, you should get the same partition table back that you have originally set.


{MacBook-Pro-de-Ciro:210821-213148-ttgo-lora32-v21 cirobruno$ python /Particular/Projetos/espressif/esp32/tools/ /Users/cirobruno/ptable.img
Traceback (most recent call last):
File “/Particular/Projetos/espressif/esp32/tools/”, line 550, in
File “/Particular/Projetos/espressif/esp32/tools/”, line 498, in main
table, input_is_binary = PartitionTable.from_file(args.input)
File “/Particular/Projetos/espressif/esp32/tools/”, line 124, in from_file
data = data.decode()
UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xff in position 0: ordinal not in range(128)

I’d be glad if MD-DOS 3.3 was able to deal with it.

What does it mean?
The flash pertition table is corrupt?

The script I see in the PlatformIO distribution of ESP-IDF is different. Try running it instead, located in <user home path>\.platformio\packages\framework-espidf\components\partition_table\

The script does

     MAGIC_BYTES = b'\xAA\x50'

    input_is_binary = input[0:2] == PartitionDefinition.MAGIC_BYTES
    if input_is_binary:
        status('Parsing binary partition input...')

So only if the first two bytes of the input file are 0xAA 0x50 it will decode it from the binary format.

You can also check hexdump -C ptable.img if those are the first two bytes.

MacBook-Pro-de-Ciro:210821-213148-ttgo-lora32-v21 cirobruno$ python /Users/cirobruno/.platformio/packages/framework-espidf/components/partition_table/ /Users/cirobruno/ptable.img
Traceback (most recent call last):
File “/Users/cirobruno/.platformio/packages/framework-espidf/components/partition_table/”, line 534, in
File “/Users/cirobruno/.platformio/packages/framework-espidf/components/partition_table/”, line 480, in main
input = input.decode()
UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xff in position 0: ordinal not in range(128)

So the first byte of the input file is 0xff and not the required magic byte.

Did you read the partition after having erased the chip fully or something?

That’s all I’m trying to do: read the chip.

The partition table comes on the chip when programming it with an application. Reading out an erased chip will not yield a partition table.