Chat freely about anything...

User avatar
By LeonardoAlves
#63022 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!
User avatar
By gdsports
#63077 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.