Compiler version : xtensa-esp32-elf-gcc (crosstool-NG crosstool-ng-1.22.0-80-g6c4433a) 5.2.0
Operating System: macOS
Using an IDE?: Vs Studio Code
Power Supply: USB
Problem Description
Hello, I'm using ESP32 on Amazon FreeRtos with the loboris library library to use a tft lcd screen.
In this library, there is a specific spiffs component so in my project I'm using this spiffs functions. I must use this because with the spiffs esp idf component, it's impossible to display images on tft screen.
The problem is that when my application is running, randomly a write on a file contained on the spiffs is not working and then every write/read is failed until I reset the board.
On this example, I'm writing a structure into a file as binary. It's the same for other functions...
Thank you very much for your help.
Expected Behavior
fwrite/fread/fclose successed
Actual Behavior
Randomly Failed with error -10012
Steps to reproduce
Flash your code
Flash your images with make flashfs
Write a file and reboot until you've got the error
Code to reproduce this issue
/* Function to write Parameters_bob into a file to save it */
int writeParametersFile(char *fname, char *mode, Parameters_bob *parameters)
{
FILE *fd =NULL;
#if PRINT_DEBUG
printf("=======================\n");
printf("==== Write the parameters settings to file ====\n");
printf("=======================\n");
printf(" file: \"%s\"\n", fname);
#endif
if (fileExists(fname)==0){
fd = fopen(fname, "wb+");
}
else {
fd = fopen(fname, "wb+");
}
if (fd == NULL) {
ESP_LOGE("[write]", "fopen failed");
ESP_LOGE("[write]","errno : %d ",errno );
return -1;
}
int size = sizeof(Parameters_bob);
int res = fwrite(parameters, size, 1, fd);
if (res != 1) {
ESP_LOGE("[write]", "fwrite failed: %d ", res);
ESP_LOGE("[write]","errno : %d ",errno );
res = fclose(fd);
if (res) {
ESP_LOGE("[write]", "fclose failed: %d", res);
ESP_LOGE("[write]","errno : %d ",errno );
return -2;
}
return -3;
}
res = fclose(fd);
if (res) {
ESP_LOGE("[write]", "fclose failed: %d", res);
ESP_LOGE("[write]","errno : %d ",errno );
return -4;
}
return 0;
}
=======================
==== Write the parameters settings to file ====
file: "/spiffs/config_data.txt"
E (60734) [write]: fclose failed: -1
E (60734) [write]: errno : -10012
## Other items if possible
[sdkconfig](https://gist.github.com/elieDaan/f5e1a5d1c01836e14d7dc928e77e57fd)
Environment
Module or chip used: ESP32-WROOM-32D
IDF version : v3.3-172-ge7e0ead31
Build System: CMake
Compiler version : xtensa-esp32-elf-gcc (crosstool-NG crosstool-ng-1.22.0-80-g6c4433a) 5.2.0
Operating System: macOS
Using an IDE?: Vs Studio Code
Power Supply: USB
Problem Description
Hello, I'm using ESP32 on Amazon FreeRtos with the loboris library library to use a tft lcd screen. In this library, there is a specific spiffs component so in my project I'm using this spiffs functions. I must use this because with the spiffs esp idf component, it's impossible to display images on tft screen.
The problem is that when my application is running, randomly a write on a file contained on the spiffs is not working and then every write/read is failed until I reset the board.
On this example, I'm writing a structure into a file as binary. It's the same for other functions...
Thank you very much for your help.
Expected Behavior
fwrite/fread/fclose successed
Actual Behavior
Randomly Failed with error -10012
Steps to reproduce
Code to reproduce this issue
======================= ==== Write the parameters settings to file ====
file: "/spiffs/config_data.txt" E (60734) [write]: fclose failed: -1 E (60734) [write]: errno : -10012