-->
Page 1 of 1

Incovenient delay time when writing data using SPIFFS

PostPosted: Sat Feb 25, 2017 2:11 pm
by LeonardoAlves
Hello everyone,

I've been studying about writing time in flash memory of ESP8266, and I found this strange results:

When I write 1KB of data 100 times in the same file, I got 93 writing time equal to 3ms and 7 writing time equal to something greater than 100ms. Could anyone explain to me why this happens?

That's the code I write for this test:

Code: Select allfor(i = 0; i < 100; i++) {     
 
      file = SPIFFS.open("text", "w");
      initial_time = millis();
      file.write(buff, len);
      file.close();
      final_time = millis();   
         
      Serial.println(final_time - initial_time);
    }


Thank you!

Re: Incovenient delay time when writing data using SPIFFS

PostPosted: Sun Feb 26, 2017 6:48 pm
by gdsports
Could be Flash erase time. At some point SPIFFS need to write to another Flash sector. If the sector is not blank, it must be erased before it can be used. When the erased sector is full, SPIFFS must erase another sector and so on. SPIFFS may group sectors into clusters so perhaps the 100 ms is the erase time for a cluster.