From e074d19593d9e22533c2eb3e80ee2876542f7d56 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 8 Dec 2025 18:46:12 +0000 Subject: [PATCH 1/5] Initial plan From 2a53f415eaad48e2529bf53ffe0e2cb4aa91b21d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 8 Dec 2025 18:55:26 +0000 Subject: [PATCH 2/5] Add hasPSRAM and psramSize fields to /info endpoint - Added hasPSRAM boolean field indicating if hardware has PSRAM - Added psramSize field with total PSRAM size in MB - Kept existing psram field for backward compatibility (free PSRAM in bytes) - All fields only included for ESP32 architecture - Tests passed and firmware builds successfully Co-authored-by: netmindz <442066+netmindz@users.noreply.github.com> --- wled00/json.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/wled00/json.cpp b/wled00/json.cpp index 08468df5..bbb8c0c7 100644 --- a/wled00/json.cpp +++ b/wled00/json.cpp @@ -839,8 +839,16 @@ void serializeInfo(JsonObject root) #endif root[F("freeheap")] = getFreeHeapSize(); - #if defined(BOARD_HAS_PSRAM) - root[F("psram")] = ESP.getFreePsram(); + #ifdef ARDUINO_ARCH_ESP32 + // Report PSRAM information + bool hasPsram = psramFound(); + root[F("hasPSRAM")] = hasPsram; + if (hasPsram) { + #if defined(BOARD_HAS_PSRAM) + root[F("psram")] = ESP.getFreePsram(); // Free PSRAM in bytes (backward compatibility) + #endif + root[F("psramSize")] = ESP.getPsramSize() / (1024 * 1024); // Total PSRAM size in MB + } #endif root[F("uptime")] = millis()/1000 + rolloverMillis*4294967; From 4684e092a87b73f812cad192df88f8de33a2e183 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 8 Dec 2025 19:01:17 +0000 Subject: [PATCH 3/5] Update usage report to send hasPSRAM and psramSize fields - Modified reportUpgradeEvent in index.js to use new hasPSRAM and psramSize fields - Changed from calculating psramSize from free PSRAM to using total PSRAM size from /info endpoint - Both fields now correctly sent in upgrade usage reports to usage.wled.me Co-authored-by: netmindz <442066+netmindz@users.noreply.github.com> --- wled00/data/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wled00/data/index.js b/wled00/data/index.js index 84b25618..76372859 100644 --- a/wled00/data/index.js +++ b/wled00/data/index.js @@ -3443,7 +3443,8 @@ function reportUpgradeEvent(info, oldVersion) { }; // Add optional fields if available - if (infoData.psram !== undefined) upgradeData.psramSize = Math.round(infoData.psram / (1024 * 1024)); // convert bytes to MB + if (infoData.hasPSRAM !== undefined) upgradeData.hasPSRAM = infoData.hasPSRAM; // Whether device has PSRAM + if (infoData.psramSize !== undefined) upgradeData.psramSize = infoData.psramSize; // Total PSRAM size in MB // Note: partitionSizes not currently available in /json/info endpoint // Make AJAX call to postUpgradeEvent API From b4d3a279e3198257cc40c0338dcf1bae216790c8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 8 Dec 2025 19:05:32 +0000 Subject: [PATCH 4/5] Fix potential overflow in PSRAM size calculation - Changed division from (1024 * 1024) to (1024UL * 1024UL) - Ensures proper unsigned long type to prevent overflow issues - All tests pass and firmware builds successfully Co-authored-by: netmindz <442066+netmindz@users.noreply.github.com> --- _codeql_detected_source_root | 1 + wled00/json.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 120000 _codeql_detected_source_root diff --git a/_codeql_detected_source_root b/_codeql_detected_source_root new file mode 120000 index 00000000..945c9b46 --- /dev/null +++ b/_codeql_detected_source_root @@ -0,0 +1 @@ +. \ No newline at end of file diff --git a/wled00/json.cpp b/wled00/json.cpp index bbb8c0c7..7404a202 100644 --- a/wled00/json.cpp +++ b/wled00/json.cpp @@ -847,7 +847,7 @@ void serializeInfo(JsonObject root) #if defined(BOARD_HAS_PSRAM) root[F("psram")] = ESP.getFreePsram(); // Free PSRAM in bytes (backward compatibility) #endif - root[F("psramSize")] = ESP.getPsramSize() / (1024 * 1024); // Total PSRAM size in MB + root[F("psramSize")] = ESP.getPsramSize() / (1024UL * 1024UL); // Total PSRAM size in MB } #endif root[F("uptime")] = millis()/1000 + rolloverMillis*4294967; From 1fee9d4c29e1239772b9f168dc60b8f364b08c7a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 8 Dec 2025 19:24:15 +0000 Subject: [PATCH 5/5] Rename hasPSRAM to psramPresent - Renamed hasPSRAM field to psramPresent in /info endpoint (json.cpp) - Updated usage report to use psramPresent field (index.js) - Removed problematic _codeql_detected_source_root symlink Co-authored-by: netmindz <442066+netmindz@users.noreply.github.com> --- _codeql_detected_source_root | 1 - wled00/data/index.js | 2 +- wled00/json.cpp | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) delete mode 120000 _codeql_detected_source_root diff --git a/_codeql_detected_source_root b/_codeql_detected_source_root deleted file mode 120000 index 945c9b46..00000000 --- a/_codeql_detected_source_root +++ /dev/null @@ -1 +0,0 @@ -. \ No newline at end of file diff --git a/wled00/data/index.js b/wled00/data/index.js index 76372859..168a5e2a 100644 --- a/wled00/data/index.js +++ b/wled00/data/index.js @@ -3443,7 +3443,7 @@ function reportUpgradeEvent(info, oldVersion) { }; // Add optional fields if available - if (infoData.hasPSRAM !== undefined) upgradeData.hasPSRAM = infoData.hasPSRAM; // Whether device has PSRAM + if (infoData.psramPresent !== undefined) upgradeData.psramPresent = infoData.psramPresent; // Whether device has PSRAM if (infoData.psramSize !== undefined) upgradeData.psramSize = infoData.psramSize; // Total PSRAM size in MB // Note: partitionSizes not currently available in /json/info endpoint diff --git a/wled00/json.cpp b/wled00/json.cpp index 7404a202..f2308013 100644 --- a/wled00/json.cpp +++ b/wled00/json.cpp @@ -842,7 +842,7 @@ void serializeInfo(JsonObject root) #ifdef ARDUINO_ARCH_ESP32 // Report PSRAM information bool hasPsram = psramFound(); - root[F("hasPSRAM")] = hasPsram; + root[F("psramPresent")] = hasPsram; if (hasPsram) { #if defined(BOARD_HAS_PSRAM) root[F("psram")] = ESP.getFreePsram(); // Free PSRAM in bytes (backward compatibility)