Even the simplest
#include "Arduino.h"
#include "FS.h"
#include "SPIFFS.h"
void setup() {
SPIFFS.begin();
}
void loop() {
}
crashes with an error
E (588) SPIFFS: mount failed, -10025
[E][SPIFFS.cpp:47] begin(): Mounting SPIFFS failed! Error: -1
It used to work for a while on the same board when there was only an unoffical SPIFFS available, but today even the unofficial one has crashed.
Is it a problem with the board? I have the newest version from the repository.
I have saved a few files containing a few chars earlier.
Did you do a flash erase before loading your new code? I have not really looked at it, but it seems highly likely the official library has a slightly different FS structure than the pre-release.
I did make erase_flash on esp-idf, entire flash was erased yet still get the same error :/
@emilekm2142 try this tip from bbx10 of another issue:
SPIFFS.begin(true);
it works! \o/!
For anyone having the same problem: the first argument is formatOnFail. Related issue: https://github.com/espressif/arduino-esp32/issues/411
SPIFFS.begin(true);
And what about the compatibility of the code?
May be:
bool begin(bool formatOnFail=true, const char * basePath="/spiffs", uint8_t maxOpenFiles=10);
and SPIFFS.begin();?
@rel1ct having SPIFFS format by default is not a very good idea ;) if you by accident flash your board with wrong config, it will wipe your data that might be otherwise good ;) That is why it's false by default.
true and false in no way will it save on wrong config.
SPIFFS.begin(); --> E (588) SPIFFS: mount failed, -10025 --> www.google.com --> SPIFFS.begin(true);
How will this affect wrong config?
currently there is only one partition scheme implemented, but in the future there will be more for the different flash sizes, so if you select by mistake a wrong flash size in the menu and flash it, it will find that your SPIFFS partition is not OK and will format otherwise good partition.
I do not see the connection size SPIFFS and launch SPIFFS.
when you launch SPIFFS it reads the partition scheme currently loaded, get the size from there and try to mount with that size. If you flash firmware with the wrong partition scheme it will obviously try to mount with a different partition size and that will lead to error and reformat! What is so hard to understand?
I always hated it, that the old SPIFFS implementation silently formatted the partition. so i welcome the sane default to fail on mount.
on a different note, i realized that during format the watchdog complains that it did not got fed in time. and it would be very cool if we could give user feedback during the format via a progress callback. maybe those two things could be dealt with with just a progress callback?
Ok, there is a working firmware (SPIFFS size 1MB) SPIFFS.begin (true); with the files in the SPIFFS section.
You download the firmware with the modified size SPIFFS (for example 0.5MB) SPIFFS.begin (false);.
What happen to the files in SPIFFS section ???
Nothing. The mount will fail, the spiffs partition won't get touched.
On Sep 18, 2017 19:39, "rel1ct" notifications@github.com wrote:
Ok, there is a working firmware (SPIFFS size 1MB) SPIFFS.begin (true);
with the files in the SPIFFS section.
You download the firmware with the modified size SPIFFS (for example
0.5MB) SPIFFS.begin (false);.
What happen to the files in SPIFFS section ???—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/espressif/arduino-esp32/issues/638#issuecomment-330298129,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AB0jL8QVCLGzZgEELJfWSlvutd9gliGOks5sjqrsgaJpZM4PZ6li
.
Hi
I have the same issue, I do not get point from above discussion. what is the final correct solution ?
how to correct mount without burden issue ?what wrong I made?
my setting
Arduino 1.8.3
code: SPIFFS_Test.ino in the example of library
sketch data upload info:
ESP32 sketch data upload
SPIFFS] data : C:\Users\Myfamily\Downloads\arduino_esp32_learn\SPIFFS_Test\data
[SPIFFS] start : 2691072
[SPIFFS] size : 1468
[SPIFFS] page : 256
[SPIFFS] block : 4096
/hello.txt
/otmeme.txt
[SPIFFS] upload : C:\Users\Myfamily\AppData\Local\Temp\arduino_build_921005/SPIFFS_Test.spiffs.bin
[SPIFFS] address: 2691072
[SPIFFS] port : COM3
[SPIFFS] speed : 921600
[SPIFFS] mode : dio
[SPIFFS] freq : 80m
code debug information
ets Jun 8 2016 00:22:57
rst:0x1 (POWERON_RESET),boot:0x12 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:812
load:0x40078000,len:0
load:0x40078000,len:10212
entry 0x40078a00
E (23) SPIFFS: mount failed, -10025
SPIFFS Mount Failed
thanks a lot
I first call mount(false), if that fails i call mount again with true. That
way I KNOW when the filesystem was created.
I'd just like to repeat that the included SPIFFS_Test example sketch gives me this 'mount error' by default.
Changing "!SPIFFS.begin()" to "!SPIFFS.begin(true)" in line line 154 fixes the issue, and all tests run successfully.
In my case problem was wrong spiff length while building SPIFF binary with command
mkspiffs.exe -p 256 -b 4096 -s [length] -d 5 -c ./data ./spiffs.bin
Length must me same as defined in partitions.csv before partitions are built with make all command.
Contents of my partitions.csv
# 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,
eeprom, data, 0x99, 0x290000,0x1000,
spiffs, data, spiffs, ,[length],
coredump, data, coredump, ,64K,
So those [length] should be same. Maybe it helps somebody.
I'm having the same issue on this code that I found on here Can anyone help with is? Oh I am new to all this coding and arduino stuff code below its a Wifi_Manager with Alexa
`#include
void prepareIds();
boolean connectWifi();
boolean connectUDP();
void startHttpServer();
void turnOnRelay();
void turnOffRelay();
void sendRelayState();
//const char* ssid = "Fart"; // CHANGE: Wifi name
//const char* password = "12345"; // CHANGE: Wifi password
char friendlyName[20] = "smart device";
//String friendlyName = "smart device"; // CHANGE: Alexa device name
const int relayPin = 2; // D1 pin. More info: https://github.com/esp8266/Arduino/blob/master/variants/d1_mini/pins_arduino.h#L49-L61
WiFiUDP UDP;
IPAddress ipMulti(239, 255, 255, 250);
ESP8266WebServer HTTP(80);
boolean udpConnected = false;
unsigned int portMulti = 1900; // local port to listen on
unsigned int localPort = 1900; // local port to listen on
boolean wifiConnected = false;
boolean relayState = false;
char packetBuffer[UDP_TX_PACKET_MAX_SIZE]; //buffer to hold incoming packet,
String serial;
String persistent_uuid;
boolean cannotConnectToWifi = false;
//flag for saving data
bool shouldSaveConfig = false;
//callback notifying us of the need to save config
void saveConfigCallback () {
Serial.println("Should save config");
shouldSaveConfig = true;
}
void readConfigSPIFF() {
//read configuration from File system json
Serial.println("mounting FS...");
if (SPIFFS.begin()) { } else { void saveConfigSPIFF( WiFiManagerParameter customFriendlyName) { //save the custom parameters to FS } void setup() { //delay(5000); // Initialise serial port // Read SPIFF configuration // Setup WiFiManager // Add custom parameter to WiFiManager //add all your parameters here //set config save notify callback //first parameter is name of access point, second is the password strcpy(friendlyName, customFriendlyName.getValue()); prepareIds(); // Initialise wifi connection // only proceed if wifi connection successful //} void loop() { HTTP.handleClient(); // if there's data available, read a packet /} else { void prepareIds() { serial = String(uuid); void respondToSearch() { } void startHttpServer() { } /* connect to wifi – returns true if successful or false if not WiFi.mode(WIFI_STA); // Wait for connection if (state){ return state; boolean connectUDP(){ Serial.println(""); if(UDP.beginMulticast(WiFi.localIP(), ipMulti, portMulti)) { return state; void turnOnRelay() { String body = HTTP.send(200, "text/xml", body.c_str()); Serial.print("Sending :"); void turnOffRelay() { String body = HTTP.send(200, "text/xml", body.c_str()); Serial.print("Sending :"); void sendRelayState() { String body = body += (relayState ? "1" : "0"); body += "\r\n" HTTP.send(200, "text/xml", body.c_str());
Serial.println("mounted file system");
if (SPIFFS.exists("/config.json")) {
//file exists, reading and loading
Serial.println("reading config file...");
File configFile = SPIFFS.open("/config.json", "r");
if (configFile) {
Serial.println("opened config file");
size_t size = configFile.size();
// Allocate a buffer to store contents of the file.
std::unique_ptr configFile.readBytes(buf.get(), size);
DynamicJsonBuffer jsonBuffer;
JsonObject& json = jsonBuffer.parseObject(buf.get());
json.printTo(Serial);
if (json.success()) {
Serial.println("\nparsed json");
strcpy(friendlyName, json["friendlyName"]);
Serial.println("\nparsed friendlyName: ");
Serial.println(friendlyName);
} else {
Serial.println("failed to load json config");
}
} else {
Serial.println("failed to load json config");
}
} else {
Serial.println("failed to load json config");
}
Serial.println("failed to mount FS");
}
//end read
}
//read updated parameters
strcpy(friendlyName, customFriendlyName.getValue());
Serial.println("saved friendly name: ");
Serial.println(friendlyName);
if (shouldSaveConfig) {
Serial.println("saving config");
DynamicJsonBuffer jsonBuffer;
JsonObject& json = jsonBuffer.createObject();
json["friendlyName"] = friendlyName;File configFile = SPIFFS.open("/config.json", "w");
if (!configFile) {
Serial.println("failed to open config file for writing");
}
json.printTo(Serial);
json.printTo(configFile);
configFile.close();
//end save
}
// Setup Relay
pinMode(relayPin, OUTPUT);
//delay(10);
turnOnRelay();
Serial.begin(115200);
readConfigSPIFF();
WiFiManager wifiManager;
WiFiManagerParameter customFriendlyName("Device_Name", "Device_Name", friendlyName, 20);
wifiManager.addParameter(&customFriendlyName);
wifiManager.setSaveConfigCallback(saveConfigCallback);
wifiManager.autoConnect("Smart Device");
Serial.println("saving friendly name: ");
Serial.println(friendlyName);
saveConfigSPIFF(customFriendlyName);
//wifiConnected = connectWifi();
//if(wifiConnected){
Serial.println("Ask Alexa to discover devices");
udpConnected = connectUDP();if (udpConnected) {
// initialise pins if needed
startHttpServer();
}
}
delay(1);
// check if the WiFi and UDP connections were successful
//if(wifiConnected){
if(udpConnected) {
// if there’s data available, read a packet
int packetSize = UDP.parsePacket(); if(packetSize) {
//Serial.println("");
//Serial.print("Received packet of size ");
//Serial.println(packetSize);
//Serial.print("From ");
IPAddress remote = UDP.remoteIP();
/*for (int i = 0; i < 4; i++) {
Serial.print(remote[i], DEC);
if (i < 3) {
Serial.print(".");
}
}
Serial.print(", port ");
Serial.println(UDP.remotePort());
*/
int len = UDP.read(packetBuffer, 255);
if (len > 0) {
packetBuffer[len] = 0;
}
String request = packetBuffer;
//Serial.println("Request:");
//Serial.println(request);
if(request.indexOf("M-SEARCH") >= 0) {
// Issue https://github.com/kakopappa/arduino-esp8266-alexa-multiple-wemo-switch/issues/22 fix
//if(request.indexOf("urn:Belkin:device:**") > 0) {
if((request.indexOf("urn:Belkin:device:**") >= 0) || (request.indexOf("ssdp:all") >= 0) || (request.indexOf("upnp:rootdevice") >= 0)) {
Serial.println("Responding to search request ...");
respondToSearch();
}
}
}
delay(10);
}
Serial.println("Cannot connect to Wifi");
}/
}
uint32_t chipId = ESP.getChipId();
char uuid[64];
sprintf_P(uuid, PSTR("38323636-4558-4dda-9188-cda0e6%02x%02x%02x"),
(uint16_t) ((chipId >> 16) & 0xff),
(uint16_t) ((chipId >> 8) & 0xff),
(uint16_t) chipId & 0xff);
persistent_uuid = "Socket-1_0-" + serial;
}
Serial.println("");
Serial.print("Sending response to ");
Serial.println(UDP.remoteIP());
Serial.print("Port : ");
Serial.println(UDP.remotePort());IPAddress localIP = WiFi.localIP();
char s[16];
sprintf(s, "%d.%d.%d.%d", localIP[0], localIP[1], localIP[2], localIP[3]);
String response =
"HTTP/1.1 200 OK\r\n"
"CACHE-CONTROL: max-age=86400\r\n"
"DATE: Fri, 15 Apr 2016 04:56:29 GMT\r\n"
"EXT:\r\n"
"LOCATION: http://" + String(s) + ":80/setup.xml\r\n"
"OPT: \"http://schemas.upnp.org/upnp/1/0/\"; ns=01\r\n"
"01-NLS: b9200ebb-736d-4b93-bf03-835149d13983\r\n"
"SERVER: Unspecified, UPnP/1.0, Unspecified\r\n"
"ST: urn:Belkin:device:**\r\n"
"USN: uuid:" + persistent_uuid + "::urn:Belkin:device:**\r\n"
"X-User-Agent: redsonic\r\n\r\n";
UDP.beginPacket(UDP.remoteIP(), UDP.remotePort());
UDP.write(response.c_str());
UDP.endPacket();
Serial.println("Response sent !");
HTTP.on("/index.html", HTTP_GET, {
Serial.println("Got Request index.html ...\n");
HTTP.send(200, "text/plain", "Hello World!");
});HTTP.on("/upnp/control/basicevent1", HTTP_POST, []() {
Serial.println("########## Responding to /upnp/control/basicevent1 ... ##########");
//for (int x=0; x <= HTTP.args(); x++) {
// Serial.println(HTTP.arg(x));
//}
String request = HTTP.arg(0);
Serial.print("request:");
Serial.println(request);
if(request.indexOf("SetBinaryState") >= 0) {
if(request.indexOf("<BinaryState>1</BinaryState>") >= 0) {
Serial.println("Got Turn on request");
turnOnRelay();
}
if(request.indexOf("<BinaryState>0</BinaryState>") >= 0) {
Serial.println("Got Turn off request");
turnOffRelay();
}
}
if(request.indexOf("GetBinaryState") >= 0) {
Serial.println("Got binary state request");
sendRelayState();
}
HTTP.send(200, "text/plain", "");
});
HTTP.on("/eventservice.xml", HTTP_GET, [](){
Serial.println(" ########## Responding to eventservice.xml ... ########\n");
String eventservice_xml = "<scpd xmlns=\"urn:Belkin:service-1-0\">"
"<actionList>"
"<action>"
"<name>SetBinaryState</name>"
"<argumentList>"
"<argument>"
"<retval/>"
"<name>BinaryState</name>"
"<relatedStateVariable>BinaryState</relatedStateVariable>"
"<direction>in</direction>"
"</argument>"
"</argumentList>"
"</action>"
"<action>"
"<name>GetBinaryState</name>"
"<argumentList>"
"<argument>"
"<retval/>"
"<name>BinaryState</name>"
"<relatedStateVariable>BinaryState</relatedStateVariable>"
"<direction>out</direction>"
"</argument>"
"</argumentList>"
"</action>"
"</actionList>"
"<serviceStateTable>"
"<stateVariable sendEvents=\"yes\">"
"<name>BinaryState</name>"
"<dataType>Boolean</dataType>"
"<defaultValue>0</defaultValue>"
"</stateVariable>"
"<stateVariable sendEvents=\"yes\">"
"<name>level</name>"
"<dataType>string</dataType>"
"<defaultValue>0</defaultValue>"
"</stateVariable>"
"</serviceStateTable>"
"</scpd>\r\n"
"\r\n";
HTTP.send(200, "text/plain", eventservice_xml.c_str());
});
HTTP.on("/setup.xml", HTTP_GET, [](){
Serial.println(" ########## Responding to setup.xml ... ########\n");
IPAddress localIP = WiFi.localIP();
char s[16];
sprintf(s, "%d.%d.%d.%d", localIP[0], localIP[1], localIP[2], localIP[3]);
String setup_xml = "<?xml version=\"1.0\"?>"
"<root>"
"<device>"
"<deviceType>urn:Belkin:device:controllee:1</deviceType>"
"<friendlyName>"+ String(friendlyName) +"</friendlyName>"
"<manufacturer>Belkin International Inc.</manufacturer>"
"<modelName>Socket</modelName>"
"<modelNumber>3.1415</modelNumber>"
"<modelDescription>Belkin Plugin Socket 1.0</modelDescription>\r\n"
"<UDN>uuid:"+ persistent_uuid +"</UDN>"
"<serialNumber>221517K0101769</serialNumber>"
"<binaryState>0</binaryState>"
"<serviceList>"
"<service>"
"<serviceType>urn:Belkin:service:basicevent:1</serviceType>"
"<serviceId>urn:Belkin:serviceId:basicevent1</serviceId>"
"<controlURL>/upnp/control/basicevent1</controlURL>"
"<eventSubURL>/upnp/event/basicevent1</eventSubURL>"
"<SCPDURL>/eventservice.xml</SCPDURL>"
"</service>"
"</serviceList>"
"</device>"
"</root>\r\n"
"\r\n";
HTTP.send(200, "text/xml", setup_xml.c_str());
Serial.print("Sending :");
Serial.println(setup_xml);
});
// openHAB support
HTTP.on("/on.html", HTTP_GET, [](){
Serial.println("Got Turn on request");
HTTP.send(200, "text/plain", "turned on");
turnOnRelay();
});
HTTP.on("/off.html", HTTP_GET, [](){
Serial.println("Got Turn off request");
HTTP.send(200, "text/plain", "turned off");
turnOffRelay();
});
HTTP.on("/status.html", HTTP_GET, [](){
Serial.println("Got status request");
String statrespone = "0";
if (relayState) {
statrespone = "1";
}
HTTP.send(200, "text/plain", statrespone);
});
HTTP.begin();
Serial.println("HTTP Server started ..");
boolean connectWifi(){
boolean state = true;
int i = 0;
WiFi.begin(ssid, password);
Serial.println("");
Serial.println("Connecting to WiFi");
Serial.print("Connecting ...");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
if (i > 10){
state = false;
break;
}
i++;
}
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
}
else {
Serial.println("");
Serial.println("Connection failed.");
}
}
*/
boolean state = false;
Serial.println("Connecting to UDP");
Serial.println("Connection successful");
state = true;
}
else{
Serial.println("Connection failed");
}
}
digitalWrite(relayPin, LOW); // turn on relay with voltage HIGH
relayState = true;
"
"
"
"
"
Serial.println(body);
}
digitalWrite(relayPin, HIGH); // turn off relay with voltage LOW
relayState = false;
"
"
"
"
"
Serial.println(body);
}
"
"
"
"\r\n"
" \r\n";
}`
@JCMireles your code appears to be for esp8266 and not esp32. You should open an issue over on esp8266/Arduino instead.
Most helpful comment
@emilekm2142 try this tip from bbx10 of another issue:
SPIFFS.begin(true);