SPIFFS Data to ESP8266

How to Upload Data to SPIFFS on esp8266 using platformio.

I am using this procedure:

  1. Create data folder under src folder
  2. put index.html in data folder
  3. run command upload File System image.

It results with:


PlatformManager: Installing espressif8266
Downloading [####################################] 100%
Unpacking [####################################] 100%
espressif8266 @ 2.0.4 has been successfully installed!
The platform ‘espressif8266’ has been successfully installed!
The rest of packages will be installed automatically depending on your build environment.
Verbose mode can be enabled via -v, --verbose option
CONFIGURATION: Redirecting...
PLATFORM: Espressif 8266 > NodeMCU 1.0 (ESP-12E Module)
HARDWARE: ESP8266 80MHz 80KB RAM (4MB Flash)
Library Dependency Finder → Library Dependency Finder (LDF) — PlatformIO latest documentation
LDF MODES: FINDER(chain) COMPATIBILITY(soft)
Collected 29 compatible libraries
Scanning dependencies…
Dependency Graph
|-- 1.3.4
| |-- 1.0.2
|-- 1.0.2
|-- 1.0
| |-- 1.0
|-- 2.1.3
| |-- 1.0
| |-- 1.0
| |-- <Ethernet(esp8266)> 1.0.4
| | |-- 1.0
| |-- 1.0
|-- 1.0
|-- 1.0
Building SPIFFS image from ‘data’ directory to .pioenvs\nodemcuv2\spiffs.bin
warning: can’t read source directory
*** [.pioenvs\nodemcuv2\spiffs.bin] Error 1
======================================================================================================== [ERROR] Took 1.83 seconds ========================================================================================================
The terminal process terminated with exit code: 1

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

Executing task: C:\Users\Ivan.platformio\penv\Scripts\platformio.exe run --target uploadfs <

Processing nodemcuv2 (platform: espressif8266; board: nodemcuv2; framework: arduino)

Verbose mode can be enabled via -v, --verbose option
CONFIGURATION: Redirecting...
PLATFORM: Espressif 8266 > NodeMCU 1.0 (ESP-12E Module)
HARDWARE: ESP8266 80MHz 80KB RAM (4MB Flash)
Library Dependency Finder → Library Dependency Finder (LDF) — PlatformIO latest documentation
LDF MODES: FINDER(chain) COMPATIBILITY(soft)
Collected 29 compatible libraries
Scanning dependencies…
Dependency Graph
|-- 1.3.4
| |-- 1.0.2
|-- 1.0.2
|-- 1.0
|-- 1.0
|-- 2.1.3
| |-- 1.0
| |-- 1.0
| |-- 1.0
| |-- <Ethernet(esp8266)> 1.0.4
| | |-- 1.0
|-- 1.0
| |-- 1.0
Building SPIFFS image from ‘data’ directory to .pioenvs\nodemcuv2\spiffs.bin
warning: can’t read source directory
*** [.pioenvs\nodemcuv2\spiffs.bin] Error 1

My platformio.ini:

[env:nodemcuv2]

platform = espressif8266

board = nodemcuv2

framework = arduino

Nope data/ folder must be at the same level at src/, not under it.

Refer Espressif 8266 — PlatformIO latest documentation

1 Like

As Max said, it doesn’t go under src… it goes at the same level as src. Here is an example from one of my workspaces…

image

Tnx, saw some projects that put the data inside source, so it missleaded me.
Solved! :slight_smile:

1 Like

Then they must have also reconfigured the data_dir = .. option in the platformio.ini. (refer Redirecting...)

1 Like

OK I understand I must create a folder “data” at the same level as “src”. So I click the project name, it folds and the new whatever icons vanish. Of course I can easily create the folder using Windows file explorer but…why?

You did right click on the project folder, chose “New Folder”, then entered “data” as the name and pressed enter, right?

grafik

grafik

1 Like

Clipboard02

So I clicked TX and the icons vanished,

image

TBH I don’t know a workspace from a project.

Left clicking on the arrow to the left of the workspace / folder name is going to collapse or expand it. You’ll want to right click on the name TX itself.

Left-clicking anywhere in the TX line collapses it - on the inverted caret, on “TX”, to the left of the name…anywhere. Right-clicking gets a four option list.
image

1 Like

Well I have sorted it. My problem was that .src was highlighted. If I clicked “add folder” next to TX, it added one under .src (as might be expected), attempting to solve this by selecting TX, as I would whilst using Windows file explorer, did not work. Selecting, say, platformio.ini then adding a folder added a folder under TX.

Seems slightly odd to me, but thank you for your time and help.

1 Like

As you mentioned, left clicking anywhere on any folder will in the first instance either fold or unfold it… so if it folds up, another click will unfold it. But, on the first click it is selected, so you can still right click and do ‘new folder’ at that point. And handily, it will auto unfold when need to type the name, so there is no need to click the folder again to unfold it.

Yes, it is a bit odd that clicking the line also controls the folding arrow, I’m sure there’s an option hidden somewhere in the bowels of VSCode’s settings if it bugs you too much :wink:

Thank you for your reply. In fact my setup does not behave as you describe…and so it bugs me even more. However I do tend to neglect that the basic behaviour of the system is due to VSC not platformio at all.

I tend to think of VSC/PIO as an IDE like Arduino where Arduino is in control and the editor merely a part (whether internal or external), whereas here PIO is an extension of VSC - which is not to belittle PIO.

My next step is of course to use TX/data and upload it to a SPIFFS. I have done this many times within Arduino but no doubt I will stumble over some trivial step!

1 Like