From 72851b5725798da5357f9db9bba521e679763496 Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Mon, 17 Oct 2022 15:40:56 +0200 Subject: [PATCH] small changes to info page - added "max used PSRAM" info - moved all mem infos into one part - only check PSRAM if BOARD_HAS_PSRAM - oappend: debug message in case that stack buffer is too small. --- tools/ESP32-Chip_info.hpp | 2 ++ wled00/data/index.js | 13 ++++++++----- wled00/json.cpp | 15 ++++++++++++--- wled00/util.cpp | 4 +++- wled00/wled.cpp | 9 +++++++++ 5 files changed, 34 insertions(+), 9 deletions(-) diff --git a/tools/ESP32-Chip_info.hpp b/tools/ESP32-Chip_info.hpp index e1a1cf25..f8563ab8 100644 --- a/tools/ESP32-Chip_info.hpp +++ b/tools/ESP32-Chip_info.hpp @@ -502,6 +502,7 @@ void show_psram_info_part2(void) } #endif + #if 0 // this test makes the "max used PSRAM" info unusable // try to allocate PSRAM (one 640KB chunk so we can be sure it will not fit into DRAM) void * buff2 = ps_malloc(640 * 1024); uint8_t * buf = (uint8_t*)malloc(620 * 1024); @@ -518,6 +519,7 @@ void show_psram_info_part2(void) free(buf); Serial.println("* Can allocate big memory with malloc()"); } + #endif #endif } diff --git a/wled00/data/index.js b/wled00/data/index.js index c88581bc..de330f70 100644 --- a/wled00/data/index.js +++ b/wled00/data/index.js @@ -667,16 +667,19 @@ ${urows===""?'':'
0?inforow("Total heap",theap," kB"):""} -${inforow("Free heap",heap," kB")} -${i.tpram?inforow("Total PSRAM",(i.tpram/1024).toFixed(1)," kB"):""} -${i.psram?inforow("Used PSRAM",(i.tpram-i.psram)," B"):""} ${inforow("Estimated current",pwru)} ${inforow("Average FPS",i.leds.fps)} + +
${inforow("MAC address",i.mac)} ${inforow("Filesystem",i.fs.u + "/" + i.fs.t + " kB (" +Math.round(i.fs.u*100/i.fs.t) + "%)")} ${inforow("Environment",i.arch + " " + i.core + " (" + i.lwip + ")")} - +${theap>0?inforow("Total heap",theap," kB"):""} +${theap>0?inforow("used heap",((i.totalheap-i.freeheap)/1000).toFixed(1)," kB"):inforow("Free heap",heap," kB")} +${i.minfreeheap?inforow("Max used heap",((i.totalheap-i.minfreeheap)/1000).toFixed(1)," kB"):""} +${i.tpram?inforow("Total PSRAM",(i.tpram/1024).toFixed(1)," kB"):""} +${i.psram?((i.tpram-i.psram)>16383?inforow("Used PSRAM",((i.tpram-i.psram)/1024).toFixed(1)," kB"):inforow("Used PSRAM",(i.tpram-i.psram)," B")):""} +${i.psusedram?((i.tpram-i.psusedram)>16383?inforow("Max Used PSRAM",((i.tpram-i.psusedram)/1024).toFixed(1)," kB"):inforow("Max Used PSRAM",(i.tpram-i.psusedram)," B")):""}
${i.e32model?inforow(i.e32model,i.e32cores +" core(s)"," "+i.e32speed+" Mhz"):""} ${i.e32flash?inforow("Flash "+i.e32flash+" MB"+", mode "+i.e32flashmode+i.e32flashtext,i.e32flashspeed," Mhz"):""} diff --git a/wled00/json.cpp b/wled00/json.cpp index b6a8106e..3b509d75 100644 --- a/wled00/json.cpp +++ b/wled00/json.cpp @@ -767,9 +767,18 @@ void serializeInfo(JsonObject root) #endif root[F("freeheap")] = ESP.getFreeHeap(); - #if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_PSRAM) - if (psramFound()) root[F("tpram")] = ESP.getPsramSize(); //WLEDSR - if (psramFound()) root[F("psram")] = ESP.getFreePsram(); + root[F("minfreeheap")] = ESP.getMinFreeHeap(); + #if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_PSRAM) && defined(BOARD_HAS_PSRAM) + if (psramFound()) { + root[F("tpram")] = ESP.getPsramSize(); //WLEDSR + root[F("psram")] = ESP.getFreePsram(); + root[F("psusedram")] = ESP.getMinFreePsram(); + } + #else + // for testing + // root[F("tpram")] = 4194304; //WLEDSR + // root[F("psram")] = 4193000; + // root[F("psusedram")] = 3083000; #endif // begin WLEDSR diff --git a/wled00/util.cpp b/wled00/util.cpp index 16d31884..3cd369f1 100644 --- a/wled00/util.cpp +++ b/wled00/util.cpp @@ -148,8 +148,10 @@ bool oappendi(int i) bool oappend(const char* txt) { uint16_t len = strlen(txt); - if (olen + len >= SETTINGS_STACK_BUF_SIZE) + if (olen + len >= SETTINGS_STACK_BUF_SIZE) { + DEBUG_PRINTLN(F("oappend() error: buffer full. Increase SETTINGS_STACK_BUF_SIZE.")); return false; // buffer full + } strcpy(obuf + olen, txt); olen += len; return true; diff --git a/wled00/wled.cpp b/wled00/wled.cpp index 2de8a6d4..bec2af6f 100644 --- a/wled00/wled.cpp +++ b/wled00/wled.cpp @@ -457,6 +457,15 @@ void WLED::setup() #if defined(ARDUINO_ARCH_ESP32) && defined(WLED_DISABLE_BROWNOUT_DET) WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 1); //enable brownout detector #endif + + #ifdef ARDUINO_ARCH_ESP32 + #ifdef ARDUINO_RUNNING_CORE + DEBUG_PRINTF("Arduino core=%d (loop is now on core #%d)\n", int(ARDUINO_RUNNING_CORE), int(xPortGetCoreID())); + #endif + #ifdef ARDUINO_EVENT_RUNNING_CORE + DEBUG_PRINTF("Arduino Event core=%d\n", int(ARDUINO_EVENT_RUNNING_CORE)); + #endif + #endif } void WLED::beginStrip()