Repository navigation
Description
What happened?
WLED frequently resets upon network requests (e.g. to /json while loading main UI, applying presets...) while (SK6812) LEDs are on.
To Reproduce Bug
Compile WLED with the custom IDF 4.4 + arduino 2.0.2 platform courtesy of Tasmota (this branch).
The LITTLEFS library by lorol is replaced by the built-in LittleFS in the 2.x.x arduino core.
The reset reason is the low level RMT interrupts failing during a network request, although I don't yet understand the exact cause. Exception decoder trace below.
This has been reproduced on ESP32 and ESP32-S2 and the platforms:
https://github.com/tasmota/platform-espressif32/releases/download/v2.0.2/platform-tasmota-espressif32-2.0.2.zip
https://github.com/tasmota/platform-espressif32/releases/download/v2.0.2.1/platform-tasmota-espressif32-2.0.2.1.zip
https://github.com/tasmota/platform-espressif32/releases/download/v2.0.2.2/platform-tasmota-espressif32-2.0.2.zip
Expected Behavior
No resets
Install Method
Self-Compiled
What version of WLED?
Which microcontroller/board are you seeing the problem on?
ESP32
Relevant log/trace output
Guru Meditation Error: Core 1 panic'ed (Cache disabled but cached memory region accessed).
Core 1 register dump:
PC : 0x4018be44 PS : 0x00060035 A0 : 0x40086098 A1 : 0x3ffbf52c
A2 : 0x3ffbe048 A3 : 0x00000000 A4 : 0x00000080 A5 : 0x00000001
A6 : 0x00000001 A7 : 0x00000000 A8 : 0x80081aff A9 : 0x00000020
A10 : 0x3ff56000 A11 : 0x3ffb34f0 A12 : 0xffffffff A13 : 0x00000020
A14 : 0x3ffbe054 A15 : 0x3ffb3358 SAR : 0x00000008 EXCCAUSE: 0x00000007
EXCVADDR: 0x00000000 LBEG : 0x400813e0 LEND : 0x400813f4 LCOUNT : 0x00000000
Backtrace:0x4018be41:0x3ffbf52c |<-CORRUPTED
#0 0x4018be41:0x3ffbf52c in rmt_ll_enable_tx_err_interrupt at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/hal/esp32/include/hal/rmt_ll.h:253Anything else?
@Jason2866 I suspect that this issue is due to a programming error on my end surfacing with the newer IDF/Arduino releases or possibly with the exchanged LittleFS library. Still, if you know what could be a likely cause, I'd be super happy to know as I see you did quite a few changes to sdkconfig (which I really like, as it drastically reduces binary size!)
My first guess was that the issue was due to CONFIG_DISABLE_HAL_LOCKS being set in 2.0.2.1, however the issue is also present in https://github.com/tasmota/platform-espressif32/releases/download/v2.0.2/platform-tasmota-espressif32-2.0.2.zip, where that option was unset as far as I can tell.
Code of Conduct
- I agree to follow this project's Code of Conduct
Activity
blazoncek commentedon Jan 30, 2022
@Aircoookie I am not seeing any resets no matter how fast I hit WLED with
/jsonrequests on my fork.I have tried as fast as 10 reloads/s while simultaneously running a playlist with 600 LEDs attached and playlist switching presets every few seconds.
I did rewrite preset loading logic and optimized JSON buffer usage so that hardly anything serious happen in network callbacks (apart from ArduinoJson handling).
My build environment is:
Aircoookie commentedon Jan 30, 2022
@blazoncek does not happen with
[email protected]on my end either.This issue is exclusive to arduino core 2.0.2, or IDF 4.4, or the custom Tasmota library configuration
Jason2866 commentedon Jan 30, 2022
@Aircoookie Looks like a bug in the Arduino core 2.0.x. Core 2.0.x is heavily refactored.
I doubt that the problem is related to wled code.
You can check if the issues are related to our customization with this setup.
Using this setup uses latest orig. Arduino ESP32 from espressif repo
EDIT: Just asked our dev for the "Lights" part in Tasmota. We do not have issues in Tasmota when using RMT
Aircoookie commentedon Jan 30, 2022
@Jason2866 Thank you for the info!
I've tried that setup and the issue persists, so we can rule out your customizations as a possible cause. I agree that the RMT refactorings seems to be the likely cause, I'll try if I can come up with a MVCE for the core team.
blazoncek commentedon Jan 30, 2022
I had opened an issue with @Makuna a while ago and it turns out the latest RMT code (also) has problems feeding data to RMT buffers. Especially when ISRs take more time than needed.
I don't recall issue # but he had it open with ESP32 core regarding that.
s-hadinger commentedon Jan 30, 2022
FYI I can't reproduce this on Tasmota using RMT and latest Core/idf, however hard I hammer it on the network side. Tested on Atom Matrix (Esp32 Pico D4) with an animation over 25 leds every 50ms. This does not confirm a bug in Arduino or IDF
blazoncek commentedon Jan 31, 2022
Found the thread...
Makuna/NeoPixelBus#524 (comment)
Makuna commentedon Jan 31, 2022
@Aircoookie Do a symbol dump on that method "rmt_ll_enable_tx_err_interrupt", if you actually find it listed what is the address? It shouldn't be listed (it is marked inline) but sometimes the compiler will ignore the suggestion of inline. There is a known GNU C++ bug that static inline functions may not honor attributes (inherited or specifically marked) and thus not be placed into IRAM memory location. Thus when run will require it to be loaded from cache (note your error). I ran into this myself and had to do some shenanigans to get the methods marked with IRAM (no longer inline, no longer listed in a header).
Aircoookie commentedon Feb 1, 2022
@Makuna thank you for the helpful pointer! Not entirely positive this is what you are referring to, but as expected,
nm /.pio/build/esp32dev/libFrameworkArduino.adoes not list this function, and does not list any otherrmt_llfunctions either, however it does list various other RMT functions from fileesp32-hal-rmt.c.o:nm_framework.txt
I am also confused about this line in the error:
Backtrace:0x4018be41:0x3ffbf52c |<-CORRUPTED, other instances of the errorCache disabled but cached memory region accessedI researched never had a corrupted backtrace.@s-hadinger thank you for testing! The difference might very well be that WLED uses ESPAsyncWebserver, which in itself operates on interrupts upon network requests while Tasmota uses (as far as I can tell) the synchronous ESP8266Webserver.
Aircoookie commentedon Feb 1, 2022
Perhaps whatever function is inlining
rmt_ll_enable_tx_err_interruptis not placed in IRAM...Aircoookie commentedon Feb 1, 2022
Not have conclusive evidence, but it seems like this only happens if the network request accesses flash data in any way (filesystem operation, or progmem strings)
Aircoookie commentedon Feb 1, 2022
Also strange that core 1 (handling network interrupts) panics. I would have assumed RMT interrupts to use core 0.
[-]Resets with IDF 4.4 platform on network request[/-][+]Resets with IDF 4.4/Arduino Core 2.x platform on network request[/+]kroimon commentedon Apr 24, 2022
I have the issue with 0.13.1 where it frequently crashes and reboots when being controlled via Home Assistant, but I am not sure if it is due to the same reason.
It definitely has to do with API calls though.
The Environment string on the info pages says "esp32 V3.3.6-16-gcc5440f6a2".
Is there anything I can do to help debug the issue?
19 remaining items
softhack007 commentedon Sep 27, 2022
As you only talk about Tasmota, I think what it means is "related to a scenario we don't have in Tasmota". This could be many things, I guess. Some aspects that we should think about:
Of course, it could still be any other functions that WLED uses a lot, but Tasmota will typically not need.
Just a few ideas that might help us dig down to the root cause of crashes.
blazoncek commentedon Sep 27, 2022
I am guessing that the most probable suspects for issues are LittleFS and Async* library (could also be AsyncTCP as it is used by AsyncWebServer).
If I have S2 unit run a single effect it will run happily until rebooted or powered off. But as soon as I run playlist which loads presets from LittleFS every so often it will soon lock up/reboot (without any UI/web interaction). Similar thing happens if I start playing with UI (trying not to trigger any LittleFS use) some page loads will stall and/or never complete loading (files from PROGMEM strings).
Unfortunately I am no good at JTAG debugging nor have proper equipment so can't use that.
BTW, yesterday I added a few DEBUG_PRINT commands to web server callbacks and a single call to
captivePortal()takes a ms or two on S2 while it completes in the same ms on regular ESP32. Funny thing is that some of those DEBUG_PRINTs never output anything which baffles me.Jason2866 commentedon Sep 27, 2022
It is NOT LittleFS. That is sure. We use it in every Tasmota32 version as default file system and it is used heavily.
both
both
yes, v2.6.7
Of course, it could still be any other functions that WLED uses a lot, but Tasmota will typically not need.
What we do not use is async tcp, webserver. Probably the are to blame
blazoncek commentedon Sep 27, 2022
I have ruled out NeoPixelBus (2.6.9) as LEDs are updated correctly without issues. Lockups/reboots occur with or without LEDs being updated.
I am not sold out on LittleFS, though. It may be accessed from within network callback which is interrupt driven (correct? I am not sure about that).
Below is partial debug output (trimmed for clarity and comments added).
From this point on WiFi can no longer reconnect (credentials hardcoded into binary) but WLED still reacts to buttons and I2S interface.
Apart form one web POST request to select effect and turn LED display on (using Packet sender), there were no clients connected to the unit.
Jason2866 commentedon Sep 27, 2022
If i see mDNS in espressif arduino code, i have the No1 candidate for issues. We removed in all builds (esp8266 and esp32x). Since this day all strange issues we had in the past are gone. mDNS is a mess. It will never work reliable.
Edit: Only use the LittleFS version which is included with the framework. The Lorol version is not fully compatible anymore with core 2.0.x
blazoncek commentedon Sep 27, 2022
Commented out mDNS and look what happens. USB serial no longer works, WLED is running effect as normal, web UI is no longer accessible after a few minutes.
https://youtu.be/u47B5J08EAg
Jason2866 commentedon Sep 29, 2022
Strange problem when using ESPAsyncWebServer with a S3 espressif/arduino-esp32#7268
Imho ESPAsyncWebServer is just working with ESP8266 / ESP32
blazoncek commentedon Sep 30, 2022
Using S2 with very selective HTTP JSON API calls (and keeping it at minimum) I can operate it stable for hours.
So the problem is definitely network related (not necessarily in network stack).
blazoncek commentedon Oct 3, 2022
Looks like ESP32-C3 works flawlessly with:
Kyry11 commentedon Oct 5, 2022
OMG! This is amazing! I have been waiting to get my C3 M5 Stamp to drive my WLED installation for months.. and now it's all working with no restarts!
Thank you so much for the config - it indeed works flawlessly! 🎉
blazoncek commentedon Oct 5, 2022
There is an issue with classic ESP32 and writing to LittleFS while there are interrupts involved (e.g. driving LEDS).
Whenever you try to save preset core 1 panics (cache access).
Using platform [email protected] (core 2.0.4, IDF 4.4).
13bporter commentedon Oct 10, 2022
Only able to get 2 pins to actually work. I can rearrange them to different pins and they'll work but when I add a 3rd one it freezes up when saving and reverts back to what I had before. I've tried driving 30leds on each channel but that doesn't seem to make a difference.
blazoncek commentedon Oct 10, 2022
What has this to do with OP?
softhack007 commentedon Dec 30, 2023
WLED is working well on many -S3/-S2/-C3 with platform 5.3.0. I assume that bugs in the core libraries were causing problems when network requests and RMT interrupts collided.
Closing.