* Fix slop from 5168

Remove the redundant field from the info structure and report what we
actually want to know.

* Fix psram size estimate

Shorten the name, and round up --  getPsramSize() is the usable size,
not the total size (the difference is allocator overhead).

* Let psram builds work without it

* Remove impossible cases in psram reports
This commit is contained in:
Will Miles
2026-01-31 19:54:03 -05:00
committed by GitHub
parent 3d33bae2b8
commit 6b953d96eb
3 changed files with 14 additions and 14 deletions

View File

@@ -3396,8 +3396,8 @@ function reportUpgradeEvent(info, oldVersion) {
}; };
// Add optional fields if available // Add optional fields if available
if (infoData.psramPresent !== undefined) upgradeData.psramPresent = infoData.psramPresent; // Whether device has PSRAM if (infoData.psrSz !== undefined) upgradeData.psramSize = infoData.psrSz; // Total PSRAM size in MB; can be 0
if (infoData.psramSize !== undefined) upgradeData.psramSize = infoData.psramSize; // Total PSRAM size in MB
// Note: partitionSizes not currently available in /json/info endpoint // Note: partitionSizes not currently available in /json/info endpoint
// Make AJAX call to postUpgradeEvent API // Make AJAX call to postUpgradeEvent API

View File

@@ -840,16 +840,12 @@ void serializeInfo(JsonObject root)
#endif #endif
root[F("freeheap")] = getFreeHeapSize(); root[F("freeheap")] = getFreeHeapSize();
#ifdef ARDUINO_ARCH_ESP32 #if defined(ARDUINO_ARCH_ESP32) && defined(BOARD_HAS_PSRAM)
// Report PSRAM information // Report PSRAM information
bool hasPsram = psramFound(); // Free PSRAM in bytes (backward compatibility)
root[F("psramPresent")] = hasPsram; root[F("psram")] = ESP.getFreePsram();
if (hasPsram) { // Total PSRAM size in MB, round up to correct for allocator overhead
#if defined(BOARD_HAS_PSRAM) root[F("psrSz")] = (ESP.getPsramSize() + (1024U * 1024U - 1)) / (1024U * 1024U);
root[F("psram")] = ESP.getFreePsram(); // Free PSRAM in bytes (backward compatibility)
#endif
root[F("psramSize")] = ESP.getPsramSize() / (1024UL * 1024UL); // Total PSRAM size in MB
}
#endif #endif
root[F("uptime")] = millis()/1000 + rolloverMillis*4294967; root[F("uptime")] = millis()/1000 + rolloverMillis*4294967;

View File

@@ -423,9 +423,13 @@ void WLED::setup()
#if defined(BOARD_HAS_PSRAM) #if defined(BOARD_HAS_PSRAM)
// if JSON buffer allocation fails requestJsonBufferLock() will always return false preventing crashes // if JSON buffer allocation fails requestJsonBufferLock() will always return false preventing crashes
pDoc = new PSRAMDynamicJsonDocument(2 * JSON_BUFFER_SIZE); if (psramFound() && ESP.getPsramSize()) {
DEBUG_PRINTF_P(PSTR("JSON buffer size: %ubytes\n"), (2 * JSON_BUFFER_SIZE)); pDoc = new PSRAMDynamicJsonDocument(2 * JSON_BUFFER_SIZE);
DEBUG_PRINTF_P(PSTR("PSRAM: %dkB/%dkB\n"), ESP.getFreePsram()/1024, ESP.getPsramSize()/1024); DEBUG_PRINTF_P(PSTR("JSON buffer size: %ubytes\n"), (2 * JSON_BUFFER_SIZE));
DEBUG_PRINTF_P(PSTR("PSRAM: %dkB/%dkB\n"), ESP.getFreePsram()/1024, ESP.getPsramSize()/1024);
} else {
pDoc = new DynamicJsonDocument(JSON_BUFFER_SIZE); // Use onboard RAM instead as a fallback
}
#endif #endif
#if defined(ARDUINO_ARCH_ESP32) #if defined(ARDUINO_ARCH_ESP32)