Trouble building a "littlefs" or "spiffs" filesystem in Platformio

Hi, I’m developing an application using ESP8266 and Platformio and, since it is the first time I try to create a flash filesystem, I’m a bit lost here.

I’m having trouble understanding what’s going wrong while clicking on “Build Filesystem Image” in Platformio IDE. The data dir is already populated with some text files and it is at the same level as ‘src’, like it should be expected (at least so I read). It fails with error -8 like this:

> Executing task in folder pwc_esp8266: platformio run --target buildfs --environment esp01_1m <

Processing esp01_1m (platform: espressif8266; board: esp01_1m; framework: arduino)
----------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif8266/esp01_1m.html
PLATFORM: Espressif 8266 (3.2.0) > Espressif Generic ESP8266 ESP-01 1M
HARDWARE: ESP8266 80MHz, 80KB RAM, 1MB Flash
PACKAGES: 
 - framework-arduinoespressif8266 3.30002.0 (3.0.2) 
 - tool-esptool 1.413.0 (4.13) 
 - tool-esptoolpy 1.30000.201119 (3.0.0) 
 - tool-mklittlefs 1.203.210628 (2.3) 
 - tool-mkspiffs 1.200.0 (2.0) 
 - toolchain-xtensa 2.100300.210717 (10.3.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 40 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <Blynk> 1.0.1
|   |-- <ESP8266WiFi> 1.0
|-- <Adafruit Unified Sensor> 1.1.4
|-- <DHT sensor library> 1.4.2
|   |-- <Adafruit Unified Sensor> 1.1.4
|-- <LittleFS> 0.1.0
Building in release mode
Building file system image from 'data' directory to .pio/build/esp01_1m/littlefs.bin
*** [.pio/build/esp01_1m/littlefs.bin] Error -8
=========================== [FAILED] Took 0.85 seconds ===========================

Environment    Status    Duration
-------------  --------  ------------
esp01_1m       FAILED    00:00:00.848
===================== 1 failed, 0 succeeded in 00:00:00.848 =====================
The terminal process "platformio 'run', '--target', 'buildfs', '--environment', 'esp01_1m'" terminated with exit code: 1.

Terminal will be reused by tasks, press any key to close it.

I don’t think it is a config error, since I correctly set board_build.filesystem and board_build.ldscript variables in platformio.ini:

[env:esp01_1m]
platform = espressif8266
board = esp01_1m
board_build.filesystem = littlefs
board_build.ldscript = eagle.flash.1m.ld
framework = arduino
monitor_speed = 115200
lib_deps =
blynkkk/Blynk @ ^1.0.1
adafruit/Adafruit Unified Sensor @ ^1.1.4
adafruit/DHT sensor library @ ^1.4.2

The error is exaclty the same if I choose spiffs instead of littlefs:

> Executing task in folder pwc_esp8266: platformio run --target buildfs --environment esp01_1m <

Processing esp01_1m (platform: espressif8266; board: esp01_1m; framework: arduino)
----------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif8266/esp01_1m.html
PLATFORM: Espressif 8266 (3.2.0) > Espressif Generic ESP8266 ESP-01 1M
HARDWARE: ESP8266 80MHz, 80KB RAM, 1MB Flash
PACKAGES: 
 - framework-arduinoespressif8266 3.30002.0 (3.0.2) 
 - tool-esptool 1.413.0 (4.13) 
 - tool-esptoolpy 1.30000.201119 (3.0.0) 
 - tool-mklittlefs 1.203.210628 (2.3) 
 - tool-mkspiffs 1.200.0 (2.0) 
 - toolchain-xtensa 2.100300.210717 (10.3.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 40 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <Blynk> 1.0.1
|   |-- <ESP8266WiFi> 1.0
|-- <Adafruit Unified Sensor> 1.1.4
|-- <DHT sensor library> 1.4.2
|   |-- <Adafruit Unified Sensor> 1.1.4
|-- <LittleFS> 0.1.0
Building in release mode
Building file system image from 'data' directory to .pio/build/esp01_1m/spiffs.bin
*** [.pio/build/esp01_1m/spiffs.bin] Error -8
=========================== [FAILED] Took 1.03 seconds ===========================

Environment    Status    Duration
-------------  --------  ------------
esp01_1m       FAILED    00:00:01.031
===================== 1 failed, 0 succeeded in 00:00:01.031 =====================
The terminal process "platformio 'run', '--target', 'buildfs', '--environment', 'esp01_1m'" terminated with exit code: 1.

Terminal will be reused by tasks, press any key to close it.

Can anyone help me on this? I checked and the application mklittlefs does exist in .platformio/packages/tool-mklittlefs/ so I’m suspecting there is something wrong about the “Build Filesystem Image” IDE option (?!). Really stuck here :frowning:

Just found out that by not overriding the default - by not specifying board_build.ldscript = eagle.flash.1m.ld - it just works :grimacing: . It’s sad it took the whole morning trying to figure it out, and just now I asked I finally solved it. Hope at least this question helps someone stuck as I was! hehe.

Found about I had overriden the default here: Espressif 8266 — PlatformIO latest documentation