Can not make it work.
Run this Arduino code (it will format your SPIFFS) and you will see it get slower and slower......
WHY??
//******************************************************************************
// SPIFFS TEST
//******************************************************************************
#include <FS.h>
void setup() {
Serial.begin(115200);
SPIFFS.begin();
}
void removeAll() {
#if 0
SPIFFS.remove("/1");
SPIFFS.remove("/2");
SPIFFS.remove("/3");
SPIFFS.remove("/4");
SPIFFS.remove("/5");
#endif
SPIFFS.remove("/5");
SPIFFS.remove("/4");
SPIFFS.remove("/3");
SPIFFS.remove("/2");
SPIFFS.remove("/1");
}
#define SECTOR 256
char buf[SECTOR];
void make(String f, int n) {
int time;
int packet = 0;
Serial.printf("making %s length = %d\n", f.c_str(), n);
// SPIFFS.remove(f);
File pESP = SPIFFS.open(f, "w");
time = millis();
while (n > 0) {
if((packet++ % 20) == 0) {
Serial.println(millis()-time);
time = millis();
}
int bytes = (n > SECTOR) ? SECTOR : n;
n -= SECTOR;
//memset(buf, n, sizeof(buf));
pESP.write((uint8_t*)buf, bytes);
yield();
}
pESP.close();
}
void loop() {
uint32_t first, second, third, fourth;
Serial.printf("\nFormatting...\n");
SPIFFS.format();
if(0) {
// was used to read and write at same time for tests...
//make("/temp", 1234 + 12112 + 200220 + 454030 + 20220 + 100100);
//fp = SPIFFS.open("temp", "r");
//fp.seek(0, SeekEnd);
//fp.position();
//fp.seek(0, SeekSet);
}
Serial.println("first run");
uint32_t startTime = millis();
make("/1", 1234);
make("/2", 12112);
make("/3", 200220);
make("/4", 454030);
make("/5", 20220);
make("/6", 100100);
first = millis() - startTime;
removeAll();
Serial.println("second run");
startTime = millis();
make("/1", 1234);
make("/2", 12112);
make("/3", 200220);
make("/4", 454030);
make("/5", 20220);
make("/6", 100100);
second = millis() - startTime;
removeAll();
Serial.println("third run");
startTime = millis();
make("/1", 1234);
make("/2", 12112);
make("/3", 200220);
make("/4", 454030);
make("/5", 20220);
make("/6", 100100);
third = millis() - startTime;
removeAll();
Serial.println("fourth run");
startTime = millis();
make("/1", 1234);
make("/2", 12112);
make("/3", 200220);
make("/4", 454030);
make("/5", 20220);
make("/6", 100100);
fourth = millis() - startTime;
Serial.printf("Time first = %dms\n", first);
Serial.printf("Time second = %dms\n", second);
Serial.printf("Time third = %dms\n", third);
Serial.printf("Time fourth = %dms\n", fourth);
for(;;) yield();
}
https://epartsconnect.com
Live realtime stock market prediction website. https://www.stocksignalslive.com my latest creation. Uses AI and machine learning.
New site featuring ESP8266 and ESP32 projects. tutorials, and news.
http://EverythingESP.com
ESP8266.com Founder and Administrator
The Mind Factory (get more from your 3D printer)
Home of the ESP8266, ESP8285, and ESP32 microcontrollers....