LITTLEFS reads slower on one core than the other? How to fix?

rr30052
Posts: 1
Joined: Fri Jul 16, 2021 10:25 am

LITTLEFS reads slower on one core than the other? How to fix?

Postby rr30052 » Fri Jul 16, 2021 10:47 am

I am confused using an ESP32 WROVER module, attempting to retrieve files I've saved to Flash using LITTLEFS during code execution.

I'm finding that the function "readFile" below takes about 240ms to retrieve a 12k file when it's called from code executing on core 0. When called from loop() (running on core 1), it takes about 1900ms to retrieve a 12k file, which is unacceptably slow.

Questions:
1. Does it make sense that the time to retrieve would differ depending on which core the function is called from? If so, could someone explain why that's the case?
2. If so....can someone help me set up the method to pin this function to core 0? I'm struggling with my attempts to do that, particularly in the 4th field of xTaskCreatePinnedToCore() where I need to pass the "parameter of the task". I've tried " (void*) (fs::FS &fs, const char * path, char* bufPtr)" but that isn't compiling for me. I'm mighty confused regarding what's supposed to be passed here, and would likely understand it better if I could see a working example.

Here's the function I'd like to pin to core 0. The main area of interest is really just the parameter list in the first line.

Code: Select all

void readFile(fs::FS &fs, const char * path, char* bufPtr) {                   
  unsigned int i = 0;
  File file = fs.open(path);
  if (!file || file.isDirectory()) {
    Serial.println("- failed to open file for reading");
    bufPtr[0] = 0xFF;
  }
  while (file.available()) {
    bufPtr[i++] = file.read();
  }
  file.close();
}
Here's my attempt to pin readFile to core 0, which fails to compile.

Code: Select all

  xTaskCreatePinnedToCore(
    readFile,    /* Task function. */
    "Task1",     /* name of task. */
    10000,       /* Stack size of task */
    (void*) (fs::FS &fs, const char * path, char* bufPtr),    /* parameter of the task */
    1,           /* priority of the task */
    &Task1,      /* Task handle to keep track of created task */
    0);          /* pin task to core 0 */
Thanks for any help anyone can provide! :)

Rick

Who is online

Users browsing this forum: No registered users and 54 guests