if(!SPIFFS.begin()){
Serial.println("An Error has occurred while mounting SPIFFS. Possibly you need to format the FS. See https://github.com/espressif/arduino-esp32/issues/638");
//SPIFFS.format()
return;
}
String str = "";
Serial.println("SPIFFS begin successful. Listing Directories");
Dir dir = SPIFFS.openDir("/");
while (dir.next()) {
str += dir.fileName();
str += " / ";
str += dir.fileSize();
str += "\r\n";
}
Serial.print(str);
Serial.println("SPIFFS begin successful. Listing Directories END.");
in my /data/ dir, I have four files (css and html).
I run Build and then Upload under General and then Build Filesystem and Upload Filesystem Image under Platform.
The building of the FS looks good:
Building file system image from 'data' directory to .pio\build\esp8622\spiffs.bin
/bootstrap.min.css
/index.html
/settings.html
/wificonfig.html
Now, I would expect this output:
SPIFFS begin successful. Listing Directories
/bootstrap.min.css
/index.html
/settings.html
/wificonfig.html
SPIFFS begin successful. Listing Directories END.
but I only get
SPIFFS begin successful. Listing Directories
SPIFFS begin successful. Listing Directories END.
thanks for your hint. With that, I do not even get that far:
src\SettingsManager.cpp: In member function 'bool SettingsManager::loadWifiSettings()':
src\SettingsManager.cpp:5:17: error: control reaches end of non-void function [-Werror=return-type]
5 | Preferences preferences;
| ^~~~~~~~~~~
src\SettingsManager.cpp: In member function 'bool SettingsManager::loadAppSettings()':
src\SettingsManager.cpp:17:17: error: control reaches end of non-void function [-Werror=return-type]
17 | Preferences preferences;
| ^~~~~~~~~~~
cc1plus.exe: some warnings being treated as errors
*** [.pio\build\esp8622\src\SettingsManager.cpp.o] Error 1
In file included from src\main.cpp:10:
and later
src\main.cpp:293:30: error: no matching function for call to 'fs::FS::open(const char [2])'
293 | File root = SPIFFS.open("/");
#include <FS.h>
void setup()
{
Serial.begin(115200);
while (!Serial); // For Yun/Leo/Micro/Zero/...
delay(100);
if(!SPIFFS.begin()){
Serial.println("An Error has occurred while mounting SPIFFS. Possibly you need to format the FS. See https://github.com/espressif/arduino-esp32/issues/638");
//SPIFFS.format()
return;
}
String str = "";
Serial.println("SPIFFS begin successful. Listing Directories");
Dir dir = SPIFFS.openDir("/");
while (dir.next()) {
str += dir.fileName();
str += " / ";
str += dir.fileSize();
str += "\r\n";
}
Serial.print(str);
Serial.println("SPIFFS begin successful. Listing Directories END.");
}
The result on the serial port:
SPIFFS begin successful. Listing Directories
SPIFFS begin successful. Listing Directories END.
Just to make sure: Does it make a difference, in what order the code is flashed (first Filesystem image or first code)?
In recent versions, the board_build.ldscript = .. should be used to set the linker script, maybe that’s the key here. I’d recommend that instead of the build_flags with -T.
Can you post the affected sections of code here? Should be a quick fix, compiler says there’s a function that has to return something (not void) but there are code paths at whose end there is no return <some value>;.
thanks, that helped.
It is a bit mis-leading that the compiler pointed at the line Preferences preferences;.
I will have to get used to that. In the python world, I found it easier to find the cause of an error.
I will check, if the SPFFS is working tomorrow (no access to the hardware now).