FFats will not mount in Arduino-M5Stack

Banging my head against the wall on this one for days and hoping a guru will point me in the right direction. I have tried various different partition tables, and build options but nothing seems to work.

Build steps are:

  1. Erase flash

  2. Upload File System Image

  3. calculate partition size as per below, run mk_espfat.py to build filesystem.img
    Hex value:
    390000 – 290000 = 100000

    Decimal value:
    3735552 – 2686976 = 1048576 input to mk_espfat tool
    3.1) filesystem.img is now built.

Note that I have tried 3 variations:
a) do not execute 4)
b) execute 4) after building filesystem.img
c) execute 4) after building img, mounting on my PC, formating to FAT, and adding several files to the image. No option worked…

  1. execute: esptool.py -p /dev/ttyUSB0 -b 115200 write_flash 0x390000 filesystem.img
  2. Upload and Monitor

Supporting information

IDE: VSCode with PlatformIO


platform = espressif32@1.12.0
;platform = espressif32  (tried several options here including latest master)
board = m5stack-grey

framework = arduino
monitor_speed = 115200

lib_deps =

board_build.partitions = default_16MB.csv

board_build.flash_mode = dio

and my partitions table

Note that I have tried many variations of this, and lastly figured I would try to put the FFat ahead of my SPIFFS, as spiffs works fine, just in case I had my memory mapped out wrong.

# Name,   Type, SubType, Offset,  Size, Flags
nvs,      data, nvs,     0x9000,  0x5000,
otadata,  data, ota,     0xe000,  0x2000,
app0,     app,  ota_0,   0x10000, 0x140000,
app1,     app,  ota_1,   0x150000,0x140000,
ffat,     data, fat,     0x290000,0x390000,
spiffs,   data, spiffs,  0x680000,0x980000,

main.cpp includes

#include <Arduino.h>
#include <M5Stack.h>
#include <EEPROM.h>
#include <FS.h>
// #include <FFat>
#include "FFat.h"

//**excerpt from my setup()**

      // *****  print out partition information

      Serial.println("Partition list:");

      // ***** SPIFFS and FAT system initialize *****
      Serial.println("Initializing FFat file system");

      writeFFatFile(FFat, "/hello.txt", "Hello ");
      writeFFatFile(FFat, "/second.txt", "second\n");
      readFFatFile(FFat, "/second.txt");

    void writeFFatFile(fs::FS &fs, const char *path, const char *message)
      Serial.printf("Writing file: %s\r\n", path);
      File file = fs.open(path, FILE_WRITE);
      if (!file)
        Serial.println("- failed to open file for writing");
      if (file.print(message))
        Serial.println("- file written");
        Serial.println("- write failed");

Output from serial port during startup

partition addr: 0x010000; size: 0x140000; label: app0
partition addr: 0x150000; size: 0x140000; label: app1
partition addr: 0x009000; size: 0x005000; label: nvs
partition addr: 0x00e000; size: 0x002000; label: otadata
partition addr: 0x290000; size: 0x390000; label: ffat
partition addr: 0x680000; size: 0x980000; label: spiffs

Initializing FFat file system
Writing file: /hello.txt

  • failed to open file for writing
    Writing file: /second.txt
  • failed to open file for writing
    Reading file: /second.txt
  • failed to open file for reading
    Listing all files in SPIFFS partition

What exactly is the invocation here?

Can you upload the full project with reproduction steps to Github so that it’s reproducable?