ESP-01 uploading to SPIFFS error

I am using an ESP-01 and i get the following error when i tried to upload a blank test sketch to SPIFFS. I have a data folder inside the sketch folder which contains a txt file with some random words just to test. I followed the same method as to upload a sketch to the ESP-01, that is, connect GPIO 2 to ground and pulse Reset pin to ground, then i clicked on Tools > ESP8266 Sketch Data Upload.

I am using Arduino IDE 1.8.11 and i verified if my Flash Size setting was correct for my ESP-01, by uploading this sketch: Arduino/CheckFlashConfig.ino at master · esp8266/Arduino · GitHub and the Serial Monitor showed that it is OK. So, my generic ESP-01 module has a Flash chip size of 1MB and a file system size of 64KB.

This is the error shown in Arduino IDE compilation window:

[SPIFFS] data    : /home/user/Arduino/Introducing_SPIFFS/data
[SPIFFS] size    : 64
[SPIFFS] page    : 256
[SPIFFS] block   : 4096
/test_example
[SPIFFS] upload  : /tmp/arduino_build_672275/Introducing_SPIFFS.spiffs.bin
[SPIFFS] address  : 0xEB000
[SPIFFS] reset    : --before default_reset --after hard_reset
[SPIFFS] port     : /dev/ttyUSB0
[SPIFFS] speed    : 115200
[SPIFFS] python   : python
[SPIFFS] uploader : /home/user/.arduino15/packages/esp8266/hardware/esp8266/2.6.2/tools/upload.py

usage: esptool [-h] [--chip {auto,esp8266,esp32}] [--port PORT] [--baud BAUD]
               [--before {default_reset,no_reset,no_reset_no_sync}]
               [--after {hard_reset,soft_reset,no_reset}] [--no-stub]
               [--trace] [--override-vddsdio [{1.8V,1.9V,OFF}]]
               {load_ram,dump_mem,read_mem,write_mem,write_flash,run,image_info,make_image,elf2image,read_mac,chip_id,flash_id,read_flash_status,write_flash_status,read_flash,verify_flash,erase_flash,erase_region,version}
               ...
esptool: error: unrecognized arguments: --end
SPIFFS Upload failed!

I am using an ESP-01 and i get the following error when i tried to upload a blank test sketch to SPIFFS.

Does it make sense to upload a sketch to SPIFFS ?

What are you going to do with it if you manage to upload it ?

I am using this guide: Install ESP8266 Filesystem Uploader in Arduino IDE | Random Nerd Tutorials and in the first step:

  1. Create an Arduino sketch and save it. For demonstration purposes, you can save an empty sketch.

This is my first time experimenting with SPIFFS on ESP-01, so i just want to confirm if it works before moving on to the actual project: ESP8266 Web Server using SPIFFS with Arduino IDE (NodeMCU) | Random Nerd Tutorials

Make sure you're using the latest version of the Arduino ESP8266 filesystem uploader plugin:

The sketch is not what is uploaded to SPIFFS by the ESP8266 Sketch Data Upload, rather it is the contents of a folder named data in the same folder as the sketch. Is that what you are trying to do ?

pert:
Make sure you're using the latest version of the Arduino ESP8266 filesystem uploader plugin:
esptool: error: unrecognized arguments: --end · Issue #6864 · esp8266/Arduino · GitHub

I previously downloaded ESP8266FS-0.4.0.zip from: Releases · esp8266/arduino-esp8266fs-plugin · GitHub but i will try with the latest one: ESP8266FS-0.5.0.zip

UKHeliBob:
The sketch is not what is uploaded to SPIFFS by the ESP8266 Sketch Data Upload, rather it is the contents of a folder named data in the same folder as the sketch. Is that what you are trying to do ?

Yes.

After updating to the latest version, it seemed to work.

esptool.py v2.8
Serial port /dev/ttyUSB0
Connecting........_____....._
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: 5c:cf:7f:c2:d5:6d
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Auto-detected Flash size: 1MB
Compressed 65536 bytes to 226...

Writing at 0x000eb000... (100 %)
Wrote 65536 bytes (226 compressed) at 0x000eb000 in 0.0 seconds (effective 16272.7 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

But then i uploaded this sketch to check if the file was actually saved into the ESP8266 filesystem:

#include "FS.h"
 
void setup() {
  Serial.begin(115200);
  
  if(!SPIFFS.begin()){
    Serial.println("An Error has occurred while mounting SPIFFS");
    return;
  }
  
  File file = SPIFFS.open("/test_example.txt", "r");
  if(!file){
    Serial.println("Failed to open file for reading");
    return;
  }
  
  Serial.println();
  Serial.println("File Content:");
  while(file.available()){
    Serial.write(file.read());
  }
  file.close();
}
 
void loop() {

}

And in the Serial Monitor, i got this:

Failed to open file for reading

My guess is that the text file found in the data folder somehow did not upload correctly or maybe the sketch did not read the text file??

I just gave it a try and it works as expected for me. I am using an ESP8266 board with 4 MB flash, so it's not an exact reproduction of your setup.

Make sure /home/user/Arduino/Introducing_SPIFFS/data/test_example.txt is really named test_example.txt. I don't remember if this is ever a problem on Linux, but on Windows, the file manager hides file extensions by default, so it's easy to accidentally name the file test_example.txt.txt.

Make sure you have Tools > Erase Flash set to "Only Sketch".

pert:
I just gave it a try and it works as expected for me. I am using an ESP8266 board with 4 MB flash, so it's not an exact reproduction of your setup.

Make sure /home/user/Arduino/Introducing_SPIFFS/data/test_example.txt is really named test_example.txt. I don't remember if this is ever a problem on Linux, but on Windows, the file manager hides file extensions by default, so it's easy to accidentally name the file test_example.txt.txt.

Make sure you have Tools > Erase Flash set to "Only Sketch".

I am a new user of Linux and i'm using Ubuntu 19.04. To create a new text file, i opened the Text Editor program and typed in some text and saved it into the data folder. I assumed that the .txt extension would be there and i thought it was hidden by default. I was wrong. I logged into a Windows PC and created a new text file there and then transferred it over to my Linux machine into the data folder. The text file created in Linux was called test_example and the one created in Windows has the filename test_example.txt

From Serial Monitor:

20:28:15.198 -> File Content:
20:28:15.198 -> This is sample text to test ESP8266 filesystem

It finally works! :slight_smile:

I'm glad to hear it's working now. Enjoy!
Per