Description
I can read and write to my SD card during setup, but once I’m in the main loop and lv_timer_handler() is called, any interaction with the SD card results in failed reads or writes. My read/write code passes units tests, but fails when integrated into LVGL.
What MCU/Processor/Board and compiler are you using?
Arduino Nano RP2040 Connect, Arduino IDE 2.2.1, latest Arduino board definition.
What LVGL version are you using?
8.3.6 (I’m generating my interfaces from SquareLine Studio, and this is the latest LVGL it supports.
What do you want to achieve?
I’d like to be able to read and write the SD card
What have you tried so far?
- writing in ‘loop’ rather than in my code (called from LVGL events) in case it’s a weird timing issue - fails
- localising all SD interactions in my code and executing sd.begin() to create a new instance to the SD card in case (somehow) LVGL is stopping the SD card. fails.
- changing SPI frequencies. Nothing words once lv_timer_handler() is being called.
- Moving from SD to littleFS (to access the flash on the RP2040 instead). Same issue - once running in the main loop, we can’t read or write to the storage.
Plea for Help
This is driving me mad, and as you can imagine our product is going to struggle if we can’t data-log.
Code to reproduce
bool persistentTuple::persist() {
if (fsPtr == nullptr) {
Serial.println("Filesystem not initialized.");
return false;
}
File file = fsPtr->open(path.c_str(), O_WRITE | O_CREAT);
Serial.print("Write error code: ");
Serial.println(file.getWriteError());
file.clearWriteError();
if (file) {
file.println(element1);
file.println(element2);
file.close();
return true;
} else {
file.clearWriteError();
file.close();
return false;
}
}```