MM experimental - build flag to move ALL json into PSRAM

-DALL_JSON_TO_PSRAM -DBOARD_HAS_PSRAM -D WLED_USE_PSRAM_JSON

on -S2, this *doubles* the PSRAM utilization!

before: heap used 85%, PSRAM used 13kb / 21kb
after:   heap used 60%, PSRAM used 41kb / 65kb !!
This commit is contained in:
Frank
2023-12-18 20:41:11 +01:00
parent ca9644f04e
commit cde3298c54
3 changed files with 22 additions and 3 deletions

View File

@@ -1591,6 +1591,7 @@ build_flags = ${esp32_4MB_V4_S_base.esp32_build_flags}
-D ARDUINO_USB_CDC_ON_BOOT=0 ; needed for arduino-esp32 >=2.0.4; avoids errors on startup
-D WLEDMM_FASTPATH ; WLEDMM experimental option. Reduces audio lag (latency), and allows for faster LED framerates. May break compatibility with previous versions.
-DBOARD_HAS_PSRAM -D WLED_USE_PSRAM_JSON ;; -D WLED_USE_PSRAM ;; WLED_USE_PSRAM causes major slow-down (slow LEDs) on some ESP32 boards
;; -DALL_JSON_TO_PSRAM ;; WLEDMM experimental --> try to force all JSON stuff into PSRAM; gives more free heap.
-D WLED_DISABLE_LOXONE ; FLASH 1272 bytes
-D WLED_DISABLE_HUESYNC ; RAM 122 bytes; FLASH 6308 bytes
-D WLED_DISABLE_ALEXA ; RAM 116 bytes; FLASH 13524 bytes
@@ -1625,6 +1626,7 @@ build_flags = ${esp32_4MB_V4_S_base.esp32_build_flags}
;;${Speed_Flags.build_flags} ;; optimize for speed instead of size --> over 100% flash, but works with 256KB filesystem (alternative partitions file)
-D WLEDMM_FASTPATH ; WLEDMM experimental option. Reduces audio lag (latency), and allows for faster LED framerates. May break compatibility with previous versions.
-DBOARD_HAS_PSRAM -D WLED_USE_PSRAM_JSON ;; -D WLED_USE_PSRAM ;; WLED_USE_PSRAM causes major slow-down (slow LEDs) on some ESP32 boards
;; -DALL_JSON_TO_PSRAM ;; WLEDMM experimental --> try to force all JSON stuff into PSRAM; gives more free heap.
;;-D CONFIG_ESP32_REV_MIN=3 ;; disables PSRAM bug workarounds in the core, reducing the code size and improving overall performance.
-D WLED_RELEASE_NAME=esp32_4MB_PSRAM_REV3_S
-D WLED_WATCHDOG_TIMEOUT=0 #-D WLED_DISABLE_BROWNOUT_DET
@@ -1826,12 +1828,14 @@ build_flags = ${common.build_flags} ${esp32s2.build_flags}
-D WLED_WATCHDOG_TIMEOUT=0 -D CONFIG_ASYNC_TCP_USE_WDT=0
${common_mm.build_flags_S}
-Wno-misleading-indentation -Wno-format-truncation
-DCONFIG_MBEDTLS_DYNAMIC_BUFFER=1 ;; optional - allows some buffers to use PSRAM
-D WLED_RELEASE_NAME=esp32S2_4MB_UF2_S
-DARDUINO_USB_CDC_ON_BOOT=1 ;; mandatory, otherwise USB does not work!!
-D WLED_DISABLE_ADALIGHT ;; disables serial protocols when using CDC USB (Serial RX will receive junk commands, unless its pulled down by resistor)
-DARDUINO_USB_MSC_ON_BOOT=0 -DARDUINO_USB_DFU_ON_BOOT=0
-D SERVERNAME='"WLED-S2"'
-DBOARD_HAS_PSRAM -D WLED_USE_PSRAM_JSON ;; -D WLED_USE_PSRAM
-DALL_JSON_TO_PSRAM ;; WLEDMM experimental --> try to force all JSON stuff into PSRAM; gives more free heap.
-D WLED_DISABLE_LOXONE ;; FLASH 1272 bytes
-D WLED_DISABLE_HUESYNC ;; RAM 122 bytes; FLASH 6308 bytes
-D WLED_DISABLE_ALEXA ;; RAM 116 bytes; FLASH 13524 bytes
@@ -1882,6 +1886,7 @@ build_flags = ${common.build_flags} ${esp32s2.build_flags}
-Wno-misleading-indentation -Wno-format-truncation
-D WLED_RELEASE_NAME=esp32s2_4MB_M
-DBOARD_HAS_PSRAM -D WLED_USE_PSRAM_JSON ;; -D WLED_USE_PSRAM
;; -DALL_JSON_TO_PSRAM ;; WLEDMM experimental --> try to force all JSON stuff into PSRAM; gives more free heap.
-DLOLIN_WIFI_FIX -DWLEDMM_WIFI_POWERON_HACK ;; seems to work much better with this
-DARDUINO_USB_CDC_ON_BOOT=0 -DARDUINO_USB_MSC_ON_BOOT=0 -DARDUINO_USB_DFU_ON_BOOT=1
-D WLED_DISABLE_ADALIGHT ;; disables serial protocols, as the board only has CDC USB

View File

@@ -382,6 +382,19 @@ void WLED::loop()
ESP.wdtFeed();
#endif
#endif
#if 0
// MM experiment - JSON garbagecollect once per minute. Warning: may crash at random
static unsigned long last_gc_time = 0;
if ((millis() - last_gc_time) > 60000) { // once in 60 seconds
if (!suspendStripService && !doInitBusses && !loadLedmap && !presetsActionPending()) { // make sure no strip or segments are being updated atm
if ((jsonBufferLock == 0) && (fileDoc == nullptr)) { // make sure JSON buffer is availeable
USER_PRINTLN(F("JSON gabage collection (regular)."));
doc.garbageCollect(); // WLEDMM experimental - trigger garbage collection on JSON doc memory pool.
last_gc_time = millis();
} } }
#endif
}
#if defined(ARDUINO_ARCH_ESP32) && defined(WLEDMM_FASTPATH)
@@ -606,7 +619,8 @@ pinManager.allocateMultiplePins(pins, sizeof(pins)/sizeof(managed_pin_type), Pin
if(dmxEnablePin > 0) pinManager.allocatePin(dmxEnablePin, true, PinOwner::DMX);
#endif
#if 0 && defined(WLED_USE_PSRAM_JSON)
#if defined(ALL_JSON_TO_PSRAM) && defined(WLED_USE_PSRAM_JSON)
USER_PRINTLN(F("JSON gabage collection (initial)."));
doc.garbageCollect(); // WLEDMM experimental - this seems to move the complete doc[] into PSRAM
#endif

View File

@@ -788,13 +788,13 @@ WLED_GLOBAL int8_t spi_sclk _INIT(HW_PIN_CLOCKSPI);
#endif
// global ArduinoJson buffer
#if 0 && defined(WLED_USE_PSRAM_JSON)
#if defined(ALL_JSON_TO_PSRAM) && defined(WLED_USE_PSRAM_JSON)
// WLEDMM experimental : always use dynamic JSON
#warning experimental - trying to always use dynamic JSON
#ifndef WLED_DEFINE_GLOBAL_VARS
WLED_GLOBAL PSRAMDynamicJsonDocument doc;
#else
WLED_GLOBAL PSRAMDynamicJsonDocument doc(JSON_BUFFER_SIZE);
#warning experimental - trying to always use dynamic JSON
#endif
#else
WLED_GLOBAL StaticJsonDocument<JSON_BUFFER_SIZE> doc;