Skip to content

Resets with IDF 4.4/Arduino Core 2.x platform on network request #2518

Closed

Description

@Aircoookie

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?

arduinocore2 branch

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:253

Anything 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

  1. blazoncek commented on Jan 30, 2022

    @blazoncek
    Contributor

    @Aircoookie I am not seeing any resets no matter how fast I hit WLED with /json requests 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:

    [env:wemos_d1_mini32]
    board = esp32dev
    platform = [email protected]
    board_build.partitions = tools/WLED_ESP32_4MB_1MB_FS.csv
    board_build.filesystem = littlefs
    build_unflags = ${common.build_unflags}
    build_flags = ${common.build_flags_esp32} -D WLED_RELEASE_NAME=ESP32
      -D WLED_DISABLE_BLYNK
      -D WLED_DISABLE_CRONIXIE
      -D WLED_DISABLE_HUESYNC
      -D WLED_DISABLE_LOXONE
      -D USERMOD_DALLASTEMPERATURE
      -D TEMPERATURE_PIN=23
      -D LEDPIN=16
      -D RLYPIN=19
      -D BTNPIN=17
      -D IRPIN=18
      -D USERMOD_FOUR_LINE_DISPLAY
      -D USE_ALT_DISPlAY
      -D USERMOD_AUTO_SAVE
      ;-D USERMOD_ANIMATED_STAIRCASE
      -D USERMOD_PIRSWITCH
      -D PIR_SENSOR_PIN=26
      -D USERMOD_MULTI_RELAY  # 14, 15, 32
      -D MULTI_RELAY_MAX_RELAYS=3
      -UWLED_USE_MY_CONFIG
    lib_deps = ${esp32.lib_deps}
      U8g2@~2.28.8
      paulstoffregen/OneWire@~2.3.6
      Wire
    
    [env:wemos_d1_mini32_debug]
    extends = env:wemos_d1_mini32
    build_flags = ${common.build_flags_esp32} -D WLED_RELEASE_NAME=ESP32
      -D WLED_DEBUG
      -D LEDPIN=16
      -D RLYPIN=19
      -D BTNPIN=17
      -D IRPIN=18
      -D USERMOD_DALLASTEMPERATURE
      -D TEMPERATURE_PIN=23
      -D USERMOD_FOUR_LINE_DISPLAY
      -D USERMOD_ROTARY_ENCODER_UI
      -D USE_ALT_DISPlAY
      -D USERMOD_AUTO_SAVE
      -D USERMOD_PIRSWITCH
      -D PIR_SENSOR_PIN=36
      -D USERMOD_MULTI_RELAY  # 14, 15, 32
      -D MULTI_RELAY_MAX_RELAYS=3
      -D STATUSLED=-1
      -D WLED_DISABLE_BROWNOUT_DET
      -UWLED_USE_MY_CONFIG
    
  2. Aircoookie commented on Jan 30, 2022

    @Aircoookie
    MemberAuthor

    @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

  3. Jason2866 commented on Jan 30, 2022

    @Jason2866
    Contributor

    @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.

    platform = https://github.com/tasmota/platform-espressif32/releases/download/v2.0.2.2/platform-tasmota-espressif32-2.0.2.zip
    platform_packages = framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git
    

    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

  4. Aircoookie commented on Jan 30, 2022

    @Aircoookie
    MemberAuthor

    @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.

  5. blazoncek commented on Jan 30, 2022

    @blazoncek
    Contributor

    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.

  6. s-hadinger commented on Jan 30, 2022

    @s-hadinger

    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

  7. blazoncek commented on Jan 31, 2022

    @blazoncek
    Contributor
  8. Makuna commented on Jan 31, 2022

    @Makuna

    @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).

  9. Aircoookie commented on Feb 1, 2022

    @Aircoookie
    MemberAuthor

    @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.a does not list this function, and does not list any other rmt_ll functions either, however it does list various other RMT functions from file esp32-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 error Cache disabled but cached memory region accessed I 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.

  10. Aircoookie commented on Feb 1, 2022

    @Aircoookie
    MemberAuthor

    Perhaps whatever function is inlining rmt_ll_enable_tx_err_interrupt is not placed in IRAM...

  11. Aircoookie commented on Feb 1, 2022

    @Aircoookie
    MemberAuthor

    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)

  12. Aircoookie commented on Feb 1, 2022

    @Aircoookie
    MemberAuthor

    Also strange that core 1 (handling network interrupts) panics. I would have assumed RMT interrupts to use core 0.

  13. changed the title [-]Resets with IDF 4.4 platform on network request[/-] [+]Resets with IDF 4.4/Arduino Core 2.x platform on network request[/+] on Apr 22, 2022
  14. kroimon commented on Apr 24, 2022

    @kroimon

    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?

  15. 19 remaining items

  16. softhack007 commented on Sep 27, 2022

    @softhack007
    Member

    Yes, and this is related to WLED.

    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:

    • is Tasmota running ESP32-S2 at full 240Mhz, or is it operated at 80Mhz?
    • is Tasmota using 80Mhz flash speed, or 40Mhz which seems to be the PIO default?
    • is Tasmota using NeoPixelBus? If yes, which version?
      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.

  17. blazoncek commented on Sep 27, 2022

    @blazoncek
    Contributor

    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.

  18. Jason2866 commented on Sep 27, 2022

    @Jason2866
    Contributor

    It is NOT LittleFS. That is sure. We use it in every Tasmota32 version as default file system and it is used heavily.

    think about:

    • is Tasmota running ESP32-S2 at full 240Mhz, or is it operated at 80Mhz?
      both
    • is Tasmota using 80Mhz flash speed, or 40Mhz which seems to be the PIO default?
      both
    • is Tasmota using NeoPixelBus? If yes, which version?
      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
  19. blazoncek commented on Sep 27, 2022

    @blazoncek
    Contributor

    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).

    ---WLED 0.14.0-bl0 2209261 INIT---
    esp32 v4.4.1-472-gc9140caf8c
    arduino-esp32 v2.0.4
    CPU:   ESP32-S2 rev.0, 1 core(s), 240MHz.
    FLASH: 4MB, Mode 2 (DIO), speed 80MHz.
    heap 132376
    Total PSRAM: 2045kB
    Free PSRAM : 2045kB
    PIN ALLOC: Pin 39 successfully allocated by 0x89 (137)
    Registering usermods ...
    Reading config
    Reading settings from /wsec.json...
    JSON buffer locked. (3)
    JSON buffer released. (3)
    JSON buffer locked. (1)
    Reading settings from /cfg.json...
    Removing all.
    PIN ALLOC: Pin 16 successfully allocated by 0x82 (130)
    Successfully inited strip 0 (len 150) with type 22 and pins 16,255 (itype 17)
    PIN ALLOC: Pin 40 successfully allocated by 0x82 (130)
    Successfully inited strip 1 (len 150) with type 22 and pins 40,255 (itype 17)
    PIN ALLOC: Pin 0 successfully allocated by 0x85 (133)
    PIN ALLOC: Pin 18 successfully allocated by 0x85 (133)
    PIN ALLOC: Pin 7 successfully allocated by 0x86 (134)
    PIN ALLOC: Pin 9 successfully allocated by 0x87 (135)
    Starting usermod config.
    Temperature config loaded.
    PIRsensorSwitch config loaded.
    4LineDisplay config loaded.
    Autosave config (re)loaded.
    JSON buffer released. (1)
    Initializing strip
    -- Copy segment constructor --
    Destroying segment:
    -- Copy segment constructor --
    -- Move segment constructor --
    Destroying segment:
    Destroying segment:
    -- Copy segment constructor --
    Destroying segment:
    Usermods setup
    Allocating temperature pin...
    PIN ALLOC: Pin 11 successfully allocated by 0x03 (3)
    PIN ALLOC: Pin 5 successfully allocated by 0x05 (5)
    PIN ALLOC: Pin 4 successfully allocated by 0x1f (31)
    PIN ALLOC: Pin 2 successfully allocated by 0x1f (31)
    PIN ALLOC: Pin 6 successfully allocated by 0x1f (31)
    lastReconnectAttempt == 0
    Access point disabled (init).
    Connecting to kristan...
    Not connected AP.
    Opening access point WLED-AP
    Init AP interfaces
    Last reconnect too old.
    Connecting to kristan...
    ---DEBUG INFO---
    Runtime: 30000
    Unix time: 30,000
    Free heap: 55492
    Total PSRAM: 2045kB
    Free PSRAM: 2038kB
    Wifi state: 0
    State time: 30002
    NTP last sync: 999000000
    Client IP: 0.0.0.0
    Loops/sec: 1518
    UM time[ms]: 0/2
    Strip time[ms]: 0/1
    Segments: 2 -> 288B
    Modes: 4*175=700B
    Data: 4*175=700B
    Map: 2*0=0B
    
    Connected! IP address: 192.168.70.58
    Init STA interfaces
    mDNS started
    Access point disabled (handle).
    send NTP
    NTP recv, l=48
    Sunrise: 06:51
    Sunset: 18:49
    Local time: 15:42
    Trigger time: 06:51
    Trigger time: 18:49
    ...
    (above is boot sequence)
    ...
    Local time: 15:49
    Trigger time: 06:51
    Trigger time: 18:49
    JSON buffer locked. (14)
    -- Copy segment constructor --
    Destroying segment:
    JSON buffer released. (14)
    ---DEBUG INFO---
    Runtime: 480092
    Unix time: 1664286569,700
    Free heap: 41088
    Total PSRAM: 2045kB
    Free PSRAM: 2039kB
    Wifi state: 3
    State time: 60008
    NTP last sync: 33629
    Client IP: 192.168.70.58
    Loops/sec: 1433
    UM time[ms]: 0/2
    Strip time[ms]: 0/8
    Segments: 2 -> 152B
    Modes: 4*175=700B
    Data: 4*175=700B
    Map: 2*0=0B
    JSON buffer locked. (14)
    -- Copy segment constructor --
    Destroying segment: 8 (0x3fd81f88)      <----- this is odd, should be empty
    JSON buffer released. (14)
    ---DEBUG INFO---
    Runtime: 510098
    Unix time: 1664286599,705
    Free heap: 41088
    Total PSRAM: 2045kB
    Free PSRAM: 2039kB
    Wifi state: 3
    ...
    (web request to turn WLED on and start playing effect Gravcenter, which needs Audioreactive usermod)
    ...
    Client IP: 192.168.70.58
    Loops/sec: 1025
    UM time[ms]: 0/2
    Strip time[ms]: 0/5
    Segments: 2 -> 152B
    Modes: 4*175=700B
    Data: 4*175=700B
    Map: 2*0=0B
    [AR userLoop] hickup detected -> was inactive for last 26 millis!
    ---DEBUG INFO---
    Runtime: 570127
    Unix time: 1664286659,735
    Free heap: 41088
    ...
    (a hiccup detected in usermod)
    ...
    ---DEBUG INFO---
    Runtime: 750177
    Unix time: 1664286839,785
    Free heap: 41084
    Total PSRAM: 2045kB
    Free PSRAM: 2039kB
    Wifi state: 3
    State time: 60008
    NTP last sync: 33629
    Client IP: 192.168.70.58
    Loops/sec: 1087
    UM time[ms]: 0/2
    Strip time[ms]: 0/4
    Segments: 2 -> 152B
    Modes: 4*175=700B
    Data: 4*175=700B
    Map: 2*0=0B
    Local time: 15:54
    Trigger time: 06:51
    Trigger time: 18:49
    Disconnected!
    Access point disabled (init).
    Connecting to kristan...
    Last reconnect too old.
    Access point disabled (init).
    Connecting to kristan...
    [AR userLoop] hickup detected -> was inactive for last 59 millis!
    [AR userLoop] hickup detected -> was inactive for last 618 millis!
    Last reconnect too old.
    Access point disabled (init).
    Connecting to kristan...
    [AR userLoop] hickup detected -> was inactive for last 614 millis!
    ...
    (a disconnect from WiFi but LEDs are still updated, AR usermod still samples and processes audio)
    

    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.

  20. Jason2866 commented on Sep 27, 2022

    @Jason2866
    Contributor

    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

  21. blazoncek commented on Sep 27, 2022

    @blazoncek
    Contributor

    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

  22. Jason2866 commented on Sep 29, 2022

    @Jason2866
    Contributor

    Strange problem when using ESPAsyncWebServer with a S3 espressif/arduino-esp32#7268
    Imho ESPAsyncWebServer is just working with ESP8266 / ESP32

  23. blazoncek commented on Sep 30, 2022

    @blazoncek
    Contributor

    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).

  24. blazoncek commented on Oct 3, 2022

    @blazoncek
    Contributor

    Looks like ESP32-C3 works flawlessly with:

    platform = [email protected]
    framework = arduino
    board = esp32-c3-devkitm-1
    board_build.partitions = tools/WLED_ESP32_4MB_1MB_FS.csv
    build_flags = ${common.build_flags} ${esp32c3.build_flags} #-D WLED_RELEASE_NAME=ESP32-C3
      -D WLED_WATCHDOG_TIMEOUT=0
    
  25. Kyry11 commented on Oct 5, 2022

    @Kyry11

    Looks like ESP32-C3 works flawlessly with:

    platform = [email protected]
    framework = arduino
    board = esp32-c3-devkitm-1
    board_build.partitions = tools/WLED_ESP32_4MB_1MB_FS.csv
    build_flags = ${common.build_flags} ${esp32c3.build_flags} #-D WLED_RELEASE_NAME=ESP32-C3
      -D WLED_WATCHDOG_TIMEOUT=0
    

    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! 🎉

  26. blazoncek commented on Oct 5, 2022

    @blazoncek
    Contributor

    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).

  27. 13bporter commented on Oct 10, 2022

    @13bporter

    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.

  28. blazoncek commented on Oct 10, 2022

    @blazoncek
    Contributor

    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.

    What has this to do with OP?

  29. softhack007 commented on Dec 30, 2023

    @softhack007
    Member

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugkeep

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions