diff --git a/tools/ESP32-Chip_info.hpp b/tools/ESP32-Chip_info.hpp index 04fd3f68..e1a1cf25 100644 --- a/tools/ESP32-Chip_info.hpp +++ b/tools/ESP32-Chip_info.hpp @@ -11,6 +11,9 @@ * detailed license conditions: https://github.com/Jason2866/ESP32_Show_Info/blob/main/LICENSE */ #include + +#ifdef ARDUINO_ARCH_ESP32 + #include "soc/spi_reg.h" #include @@ -370,16 +373,38 @@ static void my_show_chip_info(void) { #include #endif +#if 0 +// ESP8266 does this a bit differently +// +// include +// +// struct rst_info * rst_info; +// system_rtc_mem_read(0, &rst_info, sizeof(rst_info)); +// reason = rst_info->reason; +// or +// reason = ESP.getResetInfoPtr()->reason; +// +// REASON_DEFAULT_RST = 0, /* normal startup by power on */ +// REASON_WDT_RST = 1, /* hardware watch dog reset */ +// REASON_EXCEPTION_RST = 2, /* exception reset, GPIO status won’t change */ +// REASON_SOFT_WDT_RST = 3, /* software watch dog reset, GPIO status won’t change */ +// REASON_SOFT_RESTART = 4, /* software restart ,system_restart , GPIO status won’t change */ +// REASON_DEEP_SLEEP_AWAKE = 5, /* wake up from deep-sleep */ +// REASON_EXT_SYS_RST = 6 /* external system reset */ +// reason > 6 = user-defined reason codes +#endif + void my_print_reset_reason(int reason) { Serial.print(reason); switch (reason) { - case 0 : Serial.print (" NA"); break; + case 0 : Serial.print (" NO_MEAN"); break; case 1 : Serial.print (" POWERON_RESET");break; /**<1, Vbat power on reset*/ + case 2 : Serial.print (" unknown exception"); break; /**<2, this code is not defined on ESP32 */ case 3 : Serial.print (" SW_RESET");break; /**<3, Software reset digital core*/ case 4 : Serial.print (" OWDT_RESET");break; /**<4, Legacy watch dog reset digital core*/ - case 5 : Serial.print (" DEEPSLEEP_RESET");break; /**<5, Deep Sleep reset digital core*/ + case 5 : Serial.print (" DEEPSLEEP_RESET");break; /**<5, Deep Sleep wakeup reset digital core*/ case 6 : Serial.print (" SDIO_RESET");break; /**<6, Reset by SLC module, reset digital core*/ case 7 : Serial.print (" TG0WDT_SYS_RESET");break; /**<7, Timer Group0 Watch dog reset digital core*/ case 8 : Serial.print (" TG1WDT_SYS_RESET");break; /**<8, Timer Group1 Watch dog reset digital core*/ @@ -391,13 +416,13 @@ void my_print_reset_reason(int reason) case 14 : Serial.print(" EXT_CPU_RESET");break; /**<14, for APP CPU, reseted by PRO CPU*/ case 15 : Serial.print(" RTCWDT_BROWN_OUT_RESET");break; /**<15, Reset when the vdd voltage is not stable*/ case 16 : Serial.print(" RTCWDT_RTC_RESET");break; /**<16, RTC Watch dog reset digital core and rtc module*/ - case 17 : Serial.print (" TG1WDT_CPU_RESET");break; /**<17, Time Group1 reset CPU*/ - case 18 : Serial.print (" SUPER_WDT_RESET");break; /**<18, super watchdog reset digital core and rtc module*/ - case 19 : Serial.print (" GLITCH_RTC_RESET");break; /**<19, glitch reset digital core and rtc module*/ - case 20 : Serial.print (" EFUSE_RESET");break; /**<20, efuse reset digital core*/ - case 21 : Serial.print (" USB_UART_CHIP_RESET");break; /**<21, usb uart reset digital core */ - case 22 : Serial.print (" USB_JTAG_CHIP_RESET");break; /**<22, usb jtag reset digital core */ - case 23 : Serial.print (" POWER_GLITCH_RESET");break; /**<23, power glitch reset digital core and rtc module*/ + case 17 : Serial.print(" TG1WDT_CPU_RESET");break; /**<17, Time Group1 reset CPU*/ + case 18 : Serial.print(" SUPER_WDT_RESET");break; /**<18, super watchdog reset digital core and rtc module*/ + case 19 : Serial.print(" GLITCH_RTC_RESET");break; /**<19, glitch reset digital core and rtc module*/ + case 20 : Serial.print(" EFUSE_RESET");break; /**<20, efuse reset digital core*/ + case 21 : Serial.print(" USB_UART_CHIP_RESET");break; /**<21, usb uart reset digital core */ + case 22 : Serial.print(" USB_JTAG_CHIP_RESET");break; /**<22, usb jtag reset digital core */ + case 23 : Serial.print(" POWER_GLITCH_RESET");break; /**<23, power glitch reset digital core and rtc module*/ default : Serial.print (" NO_MEAN"); } } @@ -556,3 +581,8 @@ void showRealSpeed() { Serial.println(F("====================================\n")); Serial.flush(); } + + +#else + #error this tool only supports ESP32 chips +#endif \ No newline at end of file diff --git a/tools/SoundReactive_ESP32_16MB.csv b/tools/SoundReactive_ESP32_16MB.csv new file mode 100644 index 00000000..e547a824 --- /dev/null +++ b/tools/SoundReactive_ESP32_16MB.csv @@ -0,0 +1,6 @@ +# Name, Type, SubType, Offsaet, Size, Flags +nvs, data, nvs, 0x9000, 0x5000, +otadata, data, ota, 0xe000, 0x2000, +app0, app, ota_0, 0x10000, 0x200000, +app1, app, ota_1, 0x210000, 0x200000, +spiffs, data, spiffs, 0x410000, 0x7f0000, diff --git a/wled00/FX.cpp b/wled00/FX.cpp index 1ff4d0d2..260ad6ec 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -1083,7 +1083,7 @@ uint16_t mode_running_random(void) { uint8_t z = it % zoneSize; bool nzone = (!z && it != SEGENV.aux1); - for (int i=SEGLEN-1; i > 0; i--) { + for (int i=SEGLEN-1; i >= 0; i--) { // WLEDSR bugfix if (nzone || z >= zoneSize) { uint8_t lastrand = PRNG16 >> 8; int16_t diff = 0; @@ -1724,7 +1724,7 @@ uint16_t mode_random_chase(void) uint32_t color = SEGENV.step; random16_set_seed(SEGENV.aux0); - for (int i = SEGLEN -1; i > 0; i--) { + for (int i = SEGLEN -1; i >= 0; i--) { // WLEDSR bugfix uint8_t r = random8(6) != 0 ? (color >> 16 & 0xFF) : random8(); uint8_t g = random8(6) != 0 ? (color >> 8 & 0xFF) : random8(); uint8_t b = random8(6) != 0 ? (color & 0xFF) : random8(); @@ -2831,7 +2831,7 @@ uint16_t mode_bouncing_balls(void) { balls[i].lastBounceTime = time; if (balls[i].impactVelocity < 0.015f) { - float impactVelocityStart = sqrt(-2 * gravity) * random8(5,11)/10.0f; // randomize impact velocity + float impactVelocityStart = sqrtf(-2 * gravity) * random8(5,11)/10.0f; // randomize impact velocity balls[i].impactVelocity = impactVelocityStart; } } else if (balls[i].height > 1.0f) { @@ -2973,7 +2973,7 @@ uint16_t mode_popcorn(void) { uint16_t peakHeight = 128 + random8(128); //0-255 peakHeight = (peakHeight * (SEGLEN -1)) >> 8; - popcorn[i].vel = sqrt(-2.0 * gravity * peakHeight); + popcorn[i].vel = sqrtf(-2.0 * gravity * peakHeight); if (SEGMENT.palette) { @@ -3273,7 +3273,7 @@ uint16_t mode_exploding_fireworks(void) flare->posX = strip.isMatrix ? random16(2,cols-1) : (SEGMENT.intensity > random8()); // will enable random firing side on 1D uint16_t peakHeight = 75 + random8(180); //0-255 peakHeight = (peakHeight * (rows -1)) >> 8; - flare->vel = sqrt(-2.0f * gravity * peakHeight); + flare->vel = sqrtf(-2.0f * gravity * peakHeight); flare->velX = strip.isMatrix ? (random8(8)-4)/32.f : 0; // no X velocity on 1D flare->col = 255; //brightness SEGENV.aux0 = 1; @@ -5332,7 +5332,7 @@ uint16_t mode_2DPolarLights(void) { // By: Kostyantyn Matviyevskyy https SEGMENT.setPixelColorXY(x, y, ColorFromPalette(auroraPalette, qsub8( inoise8((SEGENV.step%2) + x * _scale, y * 16 + SEGENV.step % 16, SEGENV.step / _speed), - fabs((float)rows / 2 - (float)y) * adjustHeight))); + fabsf((float)rows / 2 - (float)y) * adjustHeight))); } } @@ -5784,13 +5784,13 @@ uint16_t mode_2Dfloatingblobs(void) { // change radius if needed if (blob->grow[i]) { // enlarge radius until it is >= 4 - blob->r[i] += (fabs(blob->sX[i]) > fabs(blob->sY[i]) ? fabs(blob->sX[i]) : fabs(blob->sY[i])) * 0.05f; + blob->r[i] += (fabsf(blob->sX[i]) > fabsf(blob->sY[i]) ? fabsf(blob->sX[i]) : fabsf(blob->sY[i])) * 0.05f; if (blob->r[i] >= MIN(cols/4.f,2.f)) { blob->grow[i] = false; } } else { // reduce radius until it is < 1 - blob->r[i] -= (fabs(blob->sX[i]) > fabs(blob->sY[i]) ? fabs(blob->sX[i]) : fabs(blob->sY[i])) * 0.05f; + blob->r[i] -= (fabsf(blob->sX[i]) > fabsf(blob->sY[i]) ? fabsf(blob->sX[i]) : fabsf(blob->sY[i])) * 0.05f; if (blob->r[i] < 1.f) { blob->grow[i] = true; } @@ -7020,7 +7020,7 @@ uint16_t mode_rocktaves(void) { // Rocktaves. Same note from eac } frTemp -=132; // This should give us a base musical note of C3 - frTemp = fabs(frTemp * 2.1); // Fudge factors to compress octave range starting at 0 and going to 255; + frTemp = fabsf(frTemp * 2.1); // Fudge factors to compress octave range starting at 0 and going to 255; uint16_t i = map(beatsin8(8+octCount*4, 0, 255, 0, octCount*8), 0, 255, 0, SEGLEN-1); i = constrain(i, 0, SEGLEN-1); diff --git a/wled00/data/index.js b/wled00/data/index.js index 59cdb944..6069cd50 100644 --- a/wled00/data/index.js +++ b/wled00/data/index.js @@ -670,12 +670,19 @@ ${inforow("Uptime",getRuntimeStr(i.uptime))} ${inforow("Total heap",theap," kB")} ${inforow("Free heap",heap," kB")} ${i.tpram?inforow("Total PSRAM",(i.tpram/1024).toFixed(1)," kB"):""} -${i.psram?inforow("Free PSRAM",(i.psram/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 + ")")} + +
+${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"):""} +${i.e32core0code?inforow("Core0 bootcode", i.e32core0code, " "+i.e32core0text):""} +${i.e32core1code?inforow("Core1 bootcode",i.e32core1code, " "+i.e32core1text):""} + `; gId('kv').innerHTML = cn; // update all sliders in Info diff --git a/wled00/json.cpp b/wled00/json.cpp index 96dd80b1..08b5f57b 100644 --- a/wled00/json.cpp +++ b/wled00/json.cpp @@ -2,6 +2,29 @@ #include "palettes.h" +// begin WLEDSR +#ifdef ARDUINO_ARCH_ESP32 +#include +// get the right RTC.H for each MCU +#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 0, 0) +#if CONFIG_IDF_TARGET_ESP32S2 +#include +#elif CONFIG_IDF_TARGET_ESP32C3 +#include +#elif CONFIG_IDF_TARGET_ESP32S3 +#include +#elif CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4 +#include +#endif +#else // ESP32 Before IDF 4.0 +#include +#endif +#else // for 8266 +#include +#include +#endif +// end WLEDSR + /* * JSON API (De)serialization */ @@ -552,6 +575,63 @@ void serializeState(JsonObject root, bool forPreset, bool includeBri, bool segme } } +// begin WLEDSR +#ifdef ARDUINO_ARCH_ESP32 +static String resetCode2Info(int reason) { + switch(reason) { + + case 1 : // 1 = Vbat power on reset + return F("power-on"); break; + case 2 : // 2 = this code is not defined on ESP32 + return F("exception"); break; + case 3 : // 3 = Software reset digital core + case 12: //12 = Software reset CPU + return F("SW reboot"); break; + case 5 : // 5 = Deep Sleep wakeup reset digital core + return F("wakeup"); break; + case 14: //14 = for APP CPU, reset by PRO CPU + return F("restart"); break; + case 15: //15 = Reset when the vdd voltage is not stable (brownout) + return F("brown-out"); break; + + // watchdog resets + case 4 : // 4 = Legacy watch dog reset digital core + case 6 : // 6 = Reset by SLC module, reset digital core + case 7 : // 7 = Timer Group0 Watch dog reset digital core + case 8 : // 8 = Timer Group1 Watch dog reset digital core + case 9 : // 9 = RTC Watch dog Reset digital core + case 11: //11 = Time Group watchdog reset CPU + case 13: //13 = RTC Watch dog Reset CPU + case 16: //16 = RTC Watch dog reset digital core and rtc module + case 17: //17 = Time Group1 reset CPU + return F("watchdog"); break; + case 18: //18 = super watchdog reset digital core and rtc module + return F("super watchdog"); break; + + // misc + case 10: // 10 = Instrusion tested to reset CPU + return F("intrusion"); break; + case 19: //19 = glitch reset digital core and rtc module + return F("glitch"); break; + case 20: //20 = efuse reset digital core + return F("EFUSE reset"); break; + case 21: //21 = usb uart reset digital core + return F("USB UART reset"); break; + case 22: //22 = usb jtag reset digital core + return F("JTAG reset"); break; + case 23: //23 = power glitch reset digital core and rtc module + return F("power glitch"); break; + + // unknown reason code + case 0: + return F(""); break; + default: + return F("unknown"); break; + } +} +#endif +// end WLEDSR + void serializeInfo(JsonObject root) { root[F("ver")] = versionString; @@ -670,9 +750,11 @@ void serializeInfo(JsonObject root) //root[F("maxalloc")] = ESP.getMaxAllocHeap(); #ifdef WLED_DEBUG root[F("resetReason0")] = (int)rtc_get_reset_reason(0); - root[F("resetReason1")] = (int)rtc_get_reset_reason(1); + if(ESP.getChipCores() > 1) // WLEDSR + root[F("resetReason1")] = (int)rtc_get_reset_reason(1); #endif root[F("lwip")] = 0; //deprecated + root[F("totalheap")] = ESP.getHeapSize(); //WLEDSR #else root[F("arch")] = "esp8266"; root[F("core")] = ESP.getCoreVersion(); @@ -683,12 +765,43 @@ void serializeInfo(JsonObject root) root[F("lwip")] = LWIP_VERSION_MAJOR; #endif - root[F("totalheap")] = ESP.getHeapSize(); //WLEDSR 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(); #endif + + // begin WLEDSR + #ifdef ARDUINO_ARCH_ESP32 + root[F("e32core0code")] = (int)rtc_get_reset_reason(0); + root[F("e32core0text")] = resetCode2Info(rtc_get_reset_reason(0)); + if(ESP.getChipCores() > 1) { + root[F("e32core1code")] = (int)rtc_get_reset_reason(1); + root[F("e32core1text")] = resetCode2Info(rtc_get_reset_reason(1)); + } + static char msgbuf[32]; + snprintf(msgbuf, sizeof(msgbuf)-1, "%s rev.%d", ESP.getChipModel(), ESP.getChipRevision()); + root[F("e32model")] = msgbuf; + root[F("e32cores")] = ESP.getChipCores(); + root[F("e32speed")] = ESP.getCpuFreqMHz(); + root[F("e32flash")] = int((ESP.getFlashChipSize()/1024)/1024); + root[F("e32flashspeed")] = int(ESP.getFlashChipSpeed()/1000000); + root[F("e32flashmode")] = int(ESP.getFlashChipMode()); + switch (ESP.getFlashChipMode()) { + // missing: Octal modes + case FM_QIO: root[F("e32flashtext")] = F(" (QIO)"); break; + case FM_QOUT: root[F("e32flashtext")] = F(" (QOUT)");break; + case FM_DIO: root[F("e32flashtext")] = F(" (DIO)"); break; + case FM_DOUT: root[F("e32flashtext")] = F(" (DOUT or other)");break; + default: root[F("e32flashtext")] = F(" (other)"); break; + } + + #else // for 8266 + root[F("e32core0code")] = (int)ESP.getResetInfoPtr()->reason; + root[F("e32core0text")] = F(""); + #endif + // end WLEDSR + root[F("uptime")] = millis()/1000 + rolloverMillis*4294967; usermods.addToJsonInfo(root);