esp-idf: v4.4.x - Intermittent crashes with BLE + Classic + Light Sleep (RTCWDT_RTC_RESET) (IDFGH-10038)

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

IDF version.

v4.4.4, v4.4.6, v5.1.2

Operating System used.

macOS

How did you build your project?

Command line with idf.py

If you are using Windows, please specify command line type.

None

Development Kit.

LyraT v4.3 | Custom Board

Power Supply used.

External 5V

What is the expected behavior?

Hello,

We’re running on ESP32 here on the development board, LyraT v4.3 along with a custom board developed around the pico-v3-02. With light sleep enabled, neither board is able to maintain both a BLE & Bluetooth Classic A2DP connection without crashing with RTCWDT_RTC_RESET.

Disabling the interrupt watchdog timer via sdkconfig CONFIG_ESP_INT_WDT=n had no effect , clearly the CPU is in fact locked up when exiting light sleep, as disabling any wdt protect via commenting out portions of components/esp_hw_support/sleep_modes.c just cause the group timer (TG1WDT) to timeout instead moments later.

Something definitely feels wrong exiting from light sleep, as without light sleep the problem does not occur, even after hours of extended testing (8+ hours). The only close ticket I could find is this one, where the op was trying attempt to disable to watchdog to solve issues related to BLE & WiFi at the same time and noted their project still crashes with RTCWDT_RTC_RESET when its disabled via sdkconfig / menuconfig -> bootloader.

Downgrading to v4.3.5 seems to make the problem go away (> 120 minutes no crashes) but I would like to be off a branch that will not receive any updates starting in December 2023, but cannot do so without it being rock solid. v.4.4.3 also exhibits the same issue, other v4.4 versions might.

What is the actual behavior?

Crashes with RTCWDT_RTC_RESET anywhere from 5 to 120 minutes later.

Steps to reproduce.

Untested these exact steps, since I’m too busy to share a large portion of source code right now this might work:

  1. Download the coex example
  2. Adjust settings to match MCLK / WS / DSOUT, etc.
  3. Enable light sleep through menuconfig
  4. Flash to a compatible board with a 32.768 kHz crystal attached
  5. Connect to the device using nRF connect for BLE
  6. Connect to the device using your normal process from iOS / Android (only tested with my S22+)
  7. Crash eventually

Debug Logs.

No response

More Information.

  • Tried a fresh sdkconfig
  • Tried multiple LytraT v4.3 boards
  • Tried custom board
  • Tried v4.4.3, v4.4.4, v5.2.1

About this issue

Most upvoted comments

thanks for the info, I went for the automatic light-sleep, and it works fine so far.

@AhmedSalem636 Thank you for the information! I reproduced your problem, but I don’t think the problem you’re experiencing is the same thing as what this thread reports.

The Arduino SDK only provides the basic lightsleep interface, once it is called, the Bluetooth hardware state will be corrupted, and it is also not recommended to go to sleep without deinit Bluetooth, which may be the cause of the problem, refer Wi-Fi/Bluetooth and Sleep Modes.

So, if you want to implement lightsleep when using Bluetooth, you probably have to use esp-idf, which provides a power management component that allows bluetooth services and system sleep to co-exist, you can refer the nimble powersave example