espressif / esp-idf

Espressif IoT Development Framework. Official development framework for Espressif SoCs.
Apache License 2.0
13.33k stars 7.2k forks source link

ESP32- SPIFFS issue (IDFGH-1030) #3355

Open SampathBlaze opened 5 years ago

SampathBlaze commented 5 years ago

Hi

I have developed an application in which I have to store data in file for that I used Spiffs file system. Development Environment: Development Kit: ESP32-DEVKITV1 Module: ESP32-WROOM-32D IDF version: v3.3-beta1-432-g5ec58c316 Operation System: Windows Power Supply: USB

I have worked on basic spiffs example for testing, Here I observed one case i.e, while I try to write 30kb data continuously to a file (ex:"/spiffs/hello.txt") for 30-40 times I am getting fwrite error or fwrite() function return 0. Here every-time I am overwriting the file /spiffs/hello.txt. I also tried with the different mode options like "w","wb" and "wb+". But in all cases I am getting same issue. In which scenario the fwrite() function will return 0 please explain?

Here is the Sketch: FILE f = fopen("/spiffs/hello.txt", "wb"); if (f == NULL) { ESP_LOGE(TAG, "Failed to open file for writing"); return; } char buf = "0123-----abc"; ### ->30kb in size unsigned int wc = fwrite((char *)buf,1,strlen(buf),f); fclose(f); ESP_LOGI(TAG, "File written-%d",wc); ### ->Here wc is 0 in some cases

The major problem i am facing here is If I write data in chucks, For example I have 30kb file but each time I will write 3kb data to it. If in middle of data if fwrite() function return 0 means my entire file is getting corrupted. So please suggest some solution related to this issue.

And also I have to store 60kb data to a file in my application so please suggest whether spiffs file system is better option or not if not suggest any other options?

I am attaching debug log. Please find attachment below.

testfile.txt

Regards, Sampath

MatthiasJentsch commented 4 years ago

I've the same problem with this environment:

Development Kit: none Kit version: none Module or chip used: ESP32-WROVER-B IDF version: v4.1-dev-369-g4dac7c7df Build System: CMake Compiler version: xtensa-esp32-elf-gcc (crosstool-NG esp32-2019r1) 8.2.0 Operating System: Windows Power Supply: external 3.3V

Has somebody an explanation for this behavior?

Jorge-Crespo-Celdran commented 2 years ago

@SampathReddyP and @MatthiasJentsch

I'm having the same issue. Did you manage to solve it?