[SOLVED] RTC Memory Corruption after Deep Sleep
Posted: Mon Feb 25, 2019 9:46 pm
We've observed a strange behavior on 2 units of ESP32 dev kits where the RTC memory becomes corrupted after deep sleep.
We are still working to isolate the problem, and hope to provide an example project that shows the issue, but for now I just want to share what we are seeing:
We get 0x1badbabe printed "before", as expected. But "after" is sometimes corrupted as 0x1bad3abe or similar.
The 4x "after" prints all print the same value. So it seems that the memory is getting corrupted through the reset, rather than being unreliably read. -- But there may be some caching involved?
We use RTC memory to signal a change in bootloader behavior to jump to the OTA image rather than the factory image --- so the corruption causes a bootloop!
We are still working to isolate the problem, and hope to provide an example project that shows the issue, but for now I just want to share what we are seeing:
Code: Select all
/* application writes to RTC memory */
*((uint32_t*)(0x50001FF0))=0x1badbabe
ESP_LOGI(TAG, "before: 0x%" PRIx32, *((uint32_t*)(0x50001FF0)));
ESP_LOGI(TAG, "before: 0x%" PRIx32, *((uint32_t*)(0x50001FF0)));
ESP_LOGI(TAG, "before: 0x%" PRIx32, *((uint32_t*)(0x50001FF0)));
ESP_LOGI(TAG, "before: 0x%" PRIx32, *((uint32_t*)(0x50001FF0)));
/* deep sleep reset */
esp_deep_sleep(1000 /* 1 ms */);
/* now, from the bootloader */
ESP_LOGI(TAG, "after: 0x%" PRIx32, *((uint32_t*)(0x50001FF0)));
ESP_LOGI(TAG, "after: 0x%" PRIx32, *((uint32_t*)(0x50001FF0)));
ESP_LOGI(TAG, "after: 0x%" PRIx32, *((uint32_t*)(0x50001FF0)));
ESP_LOGI(TAG, "after: 0x%" PRIx32, *((uint32_t*)(0x50001FF0)));
The 4x "after" prints all print the same value. So it seems that the memory is getting corrupted through the reset, rather than being unreliably read. -- But there may be some caching involved?
We use RTC memory to signal a change in bootloader behavior to jump to the OTA image rather than the factory image --- so the corruption causes a bootloop!