espressif / esp-idf

Espressif IoT Development Framework. Official development framework for Espressif SoCs.
Apache License 2.0
13.89k stars 7.33k forks source link

RF coexistence prevents automatic light sleep mode from working (IDFGH-13598) #14485

Open chenlijun99 opened 3 months ago

chenlijun99 commented 3 months ago

Answers checklist.

IDF version.

v5.3

Espressif SoC revision.

ESP32-S3

Operating System used.

Linux

How did you build your project?

Command line with idf.py

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

None

Development Kit.

ESP32-S3-DevKitC-1 v1.1

Power Supply used.

USB

What is the expected behavior?

After I call the appropriate functions to disable wifi and BLE (as described in https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/system/sleep_modes.html#wi-fi-bluetooth-and-sleep-modes) and block all my tasks, the MCU should enter in light sleep mode.

What is the actual behavior?

It doesn't enter in light sleep mode.

Steps to reproduce.

  1. Configure esp_pm to enable automatic light sleep
  2. Start Wifi and BLE
  3. Stop Wifi and BLE
  4. Observe that the firmware doens't enter in sleep moe

Debug Logs.

Actual relevant part of the logs. In short, when coexistence is enabled, even if I stop wifi and BLE, there is still a esp_timer from the coexistence module that is running, preventing automatic light sleep mode from working. The log has been printed using the function esp_timer_dump.

I've used gdb to watch the address 0x3fcc1c64 and confirmed that it is a timer managed by the esp_coex module.

Timer stats:
Name                  Period      Alarm
timer@0x3fcc1c64      0           12895422

More Information.

No response

esp-lis commented 2 months ago

@chenlijun99 perhaps you can use esp_pm_dump_locks to dump the pm lock runtime info. which will help you see the lock holder information.

chenlijun99 commented 2 months ago

I already did that and I didn't see any active pm lock that forbids entering into light sleep mode.

esp-lis commented 2 months ago

I already did that and I didn't see any active pm lock that forbids entering into light sleep mode.

can you provide your example code for me?

rac146 commented 1 month ago

I found the same issue while trying to enter automatic light sleep with Wifi and BLE with an ESP32C6.. here are some more scenarios:

  1. Enable WIFI Only

  2. Disable WIFI

  3. Automatic light sleep enters successfully

  4. Enable BLE Only and start advertising

  5. Disable BLE advertising

  6. Automatic light sleep enters successfully

  7. Enable BLE and Wifi. Start advertising on BLE

  8. Disable BLE advertising

  9. Disable Wifi

  10. Automatic sleep mode is not entered. The timer referenced from above is still running..

I'm not getting great information using esp_pm_dump_locks - the fact that I'm shutting down the serial port to goto sleep is interfering with getting the info you need. Can someone point me in a direction to better debug this? Definitely an issue with the esp_coex module..

rac146 commented 1 month ago

I'm not sure if this helps, but I was able to call the esp_timer_dump with profiling enabled and can see this.. fairly certain this is the timer that is running:

image