I have an ESP32 Huzzah32 dev board that I am experimenting with deep sleep functionality. The module can be put to sleep and successfully wakes on button press, but the variables stored as RTC_DATA_ATTR get reset every time the device wakes from sleep. In particular, I am implementing a counter to track how many times a button is clicked to detect whether the user single-clicked or double-clicked to wake the device from sleep (so different actions can be performed for each case), but the counter always gets reset to 0 even though the docs state that it should remember its state.
Also, the wake_reason is always returned as ESP_DEEP_SLEEP_WAKEUP_UNDEFINED, so somehow the fact that it is being woken by a button press (which should return ESP_DEEP_SLEEP_WAKEUP_EXT0 or ESP_DEEP_SLEEP_WAKEUP_EXT1) is being ignored. I suspect this is related to the problem I have of the RTC_DATA_ATTR being reset too.