SD card as source for files : very slow and crashes ESP32 most of the time (watchdog got triggered ...) #1123
Description
Hello Everyone,
I've tried to run the AsyncWebServer on an ESP32 to serve files from the SD card (connected as SPI // not 1bit or 4bit connections).
So I'm basically using SD and FS libraries and I've tried these initiators :
server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){ request->send(SPIFFS, "/index.htm", "text/html"); });
< Working 100% and relatively fast
server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){ request->send(SD, "/webui/index.htm", "text/html"); });
< Do not work at all on small files, large files goes the same (starts to appear on browser very slowly and at some point, ESP32 crashes with the following :
task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
task_wdt: - async_tcp (CPU 0/1)
task_wdt: Tasks currently running:
task_wdt: CPU 0: IDLE
task_wdt: CPU 1: loopTask
server.serveStatic("/", SD, "/");
< crashes exactly the same as request->send(SD, "/webui/index.htm", "text/html");
Is there any way to get this library to work with SD card files and folders ?
In my scenario, I have those files loading :
- 1 HTML page (~20KB)
- 3 JS scripts (~100KB all)
- 1 CSS file (~100KB)
- 1 image file (~40KB)
TOTAL : ~260KB
When using SPIFFS storage, everything goes fine and fast, but when I try to use SD, not even any single file loads correctly.
Does someone have any idea of what could be the culprit ?
Things to know : I'm actually just testing on a very small and up to date environment :
- ESP32 WROOM-32D
- SD card slot connected on SPI (pins : 5, 18, 19, 23)
- Arduino IDE 1.8.16
- Espressif SDK 2.0.2