From 715270390f4055275357f114eeab6999efd284b3 Mon Sep 17 00:00:00 2001 From: Lago Date: Fri, 3 Apr 2026 23:02:52 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20move=20FTP=20task=20to=20core=201=20?= =?UTF-8?q?=E2=80=94=20core=200=20reserved=20for=20WiFi=20stack?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit FTP task on core 0 at priority 2 starved the WiFi networking stack, preventing the FTP welcome banner from being sent. Moved to core 1 with 2ms yield to coexist with LVGL rendering. --- src/main.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 78cfe1e..1e1c4e8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -449,12 +449,16 @@ static void initNtp() { Serial.println("[NTP] Warning: time not yet synced (will update in background)"); } -/** FTP task — runs handleFTP() in a dedicated loop on core 0 */ +/** FTP task — runs handleFTP() in a dedicated loop on core 1 + * NOTE: Must run on core 1 (not core 0) because WiFi runs on core 0 + * and handleFTP() needs WiFi sockets to work. Running on core 0 at + * higher priority starves WiFi, preventing welcome banner from sending. + */ static void ftpTask(void *param) { (void)param; for (;;) { ftpSrv.handleFTP(); - vTaskDelay(pdMS_TO_TICKS(1)); // yield ~1 ms between iterations + vTaskDelay(pdMS_TO_TICKS(2)); // yield 2ms to let LVGL run } } @@ -467,8 +471,9 @@ static void initFtp() { ftpSrv.setLocalIp(WiFi.localIP()); ftpSrv.begin("kode", "kode"); - /* Run FTP in its own task on core 0 so it never blocks LVGL on core 1 */ - xTaskCreatePinnedToCore(ftpTask, "ftp", 32768, NULL, 2, NULL, 0); + /* Run FTP in its own task on core 1 (same as Arduino) — core 0 is + reserved for WiFi/networking stack, running FTP there starves it */ + xTaskCreatePinnedToCore(ftpTask, "ftp", 32768, NULL, 2, NULL, 1); Serial.printf("[FTP] FTP server ready on core 0 (PASV IP: %s, data port: 50009)\n", WiFi.localIP().toString().c_str());