You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
extern "C" void app_main()
{
initArduino();
**Is_SpiFs_Init = SPIFFS.begin(true);**
if(!Is_SpiFs_Init) Serial.println("Failed to init SPIFFS");
//test SPIFFS
fs::FS *fs = SPIFFS;
File file = fs.open("/test.txt", FILE_WRITE);
if(!file){
Serial.println("Failed to open file for writing");
return;
}
if(file.print(message)){
Serial.println("File written");
} else {
Serial.println("Write failed");
}
//end test
.....
}
Next I use mkspiffs.exe to build an 1MB image of SPIFFS and flash to ESP32 at location 0x110000; then I make a custom partition table to add new SPIFFS to the table
# Name, Type, SubType, Offset, Size, Flags
# Note: if you change the phy_init or app partition offset, make sure to change the offset in Kconfig.projbuild
nvs, data, nvs, 0x9000, 0x6000,
phy_init, data, phy, 0xf000, 0x1000,
factory, app, factory, 0x10000, 1M,
storage, data, spiffs, 0x110000, 1048576,
And rebuild the project. Now, it could not mound SPIFFS even if I call SPIFFS.begin(true)
I look to the code and see that SPIFFS.begin() calls esp_spiffs_init() which is defined in esp-idf/components/spiffs/esp_spiffs.c and in esp_spiffs_init(), it has this code:
I doubt if it should set efs->cfg.phys_addr to the actual location address of SPIFFS (0x110000 in my case), not 0. Then I tried to change it to "efs->cfg.phys_addr = partition->address;" but the result is same which means it could not mount SPIFFS
Error message:
E (1014) SPIFFS: failed to read addr 001100fc, size 00000002, err 258
E (1014) SPIFFS: mount failed, -1
[E][SPIFFS.cpp:47] begin(): Mounting SPIFFS failed! Error: -1
Failed to init SPIFFS
Writing file: /index.htm
[E][vfs_api.cpp:22] open(): File system is not mounted
Failed to open file for writing
Reading file: /index.htm
[E][vfs_api.cpp:22] open(): File system is not mounted
Failed to open file for reading
Method 2:
I tried with different SPIFFS example from https://github.com/loboris/ESP32_spiffs_example and I was successful to test SPIFFS with custom location 0x110000.
However, many of my library code use the namespace fs::FS exported by SPIFFS Arduino library to access files. I dont want to manually change them to use POSIX C functions for file (fopen, fwrite, etc)
So my question is:
Why does it hardcode 0 to "efs->cfg.phys_addr"? What is the address of SPIFFS and how can I use a pre-loaded SPIFFS partition in Method 1 like I can do in Method 2?
Thanks,
HuyK
The text was updated successfully, but these errors were encountered:
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Hardware:
Board: ?ESP32 Dev Module?
Core Installation/update date: ?11/jul/2017?
IDE name: ?Arduino IDE? ?Platform.io? ?IDF component?
Flash Frequency: ?40Mhz?
Upload Speed: ?115200?
Description:
Hi all,
Method 1:
I use SPIFFS Arduino libraries inside my IDF project follow this example
https://github.com/espressif/arduino-esp32/blob/master/libraries/SPIFFS/examples/SPIFFS_Test/SPIFFS_Test.ino
When I use the code as is and run, it could mount SPIFFS and I can read/write files OK with fs::FS object. But I dont know what is the address of SPIFFS in flash memory.
The code of app_main():
Next I use mkspiffs.exe to build an 1MB image of SPIFFS and flash to ESP32 at location 0x110000; then I make a custom partition table to add new SPIFFS to the table
And rebuild the project. Now, it could not mound SPIFFS even if I call SPIFFS.begin(true)
I look to the code and see that SPIFFS.begin() calls esp_spiffs_init() which is defined in esp-idf/components/spiffs/esp_spiffs.c and in esp_spiffs_init(), it has this code:
I doubt if it should set efs->cfg.phys_addr to the actual location address of SPIFFS (0x110000 in my case), not 0. Then I tried to change it to "efs->cfg.phys_addr = partition->address;" but the result is same which means it could not mount SPIFFS
Method 2:
I tried with different SPIFFS example from https://github.com/loboris/ESP32_spiffs_example and I was successful to test SPIFFS with custom location 0x110000.
However, many of my library code use the namespace fs::FS exported by SPIFFS Arduino library to access files. I dont want to manually change them to use POSIX C functions for file (fopen, fwrite, etc)
So my question is:
Why does it hardcode 0 to "efs->cfg.phys_addr"? What is the address of SPIFFS and how can I use a pre-loaded SPIFFS partition in Method 1 like I can do in Method 2?
Thanks,
HuyK
The text was updated successfully, but these errors were encountered: