From 95c41bf501874f222bff0212f37cf54a5f06c74e Mon Sep 17 00:00:00 2001 From: Lago Date: Fri, 3 Apr 2026 22:46:03 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20FTP=20crash=20on=20download=20=E2=80=94?= =?UTF-8?q?=20increase=20task=20stack,=20guard=20concurrent=20SD=20access?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - FTP task stack 8KB → 32KB (SimpleFTPServer file I/O needs deep stack) - Skip calcDirSize when FTP client connected (prevents concurrent SD_MMC access from core 0 + core 1 causing null pointer crash) --- src/main.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 829630f..78cfe1e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -131,12 +131,11 @@ static void updateSdInfo() { if (!sd_ok) return; uint64_t total = SD_MMC.totalBytes() / (1024ULL * 1024ULL); uint64_t used = SD_MMC.usedBytes() / (1024ULL * 1024ULL); - Serial.printf("[SD] API: used=%llu MB, total=%llu MB\n", used, total); - /* SD_MMC.usedBytes() returns 0 on exFAT / large cards — walk filesystem */ - if (used == 0 && total > 0) { + /* Skip heavy filesystem walk while FTP is active (concurrent SD_MMC + access from core 0 + core 1 causes null pointer crashes) */ + if (used == 0 && total > 0 && !ftp_client_on) { uint64_t walked = calcDirSize(SD_MMC, "/"); used = walked / (1024ULL * 1024ULL); - Serial.printf("[SD] Walk: %llu bytes = %llu MB\n", walked, used); } ui_set_sd(used, total); } @@ -469,7 +468,7 @@ static void initFtp() { ftpSrv.begin("kode", "kode"); /* Run FTP in its own task on core 0 so it never blocks LVGL on core 1 */ - xTaskCreatePinnedToCore(ftpTask, "ftp", 8192, NULL, 2, NULL, 0); + xTaskCreatePinnedToCore(ftpTask, "ftp", 32768, NULL, 2, NULL, 0); Serial.printf("[FTP] FTP server ready on core 0 (PASV IP: %s, data port: 50009)\n", WiFi.localIP().toString().c_str());