I'm developing an application that must save some buffers in the RTC Fast Memory in order to persist data between deep sleeps.
My code is something like
Code: Select all
RTC_DATA_ATTR static uint8_t * buffer;
RTC_DATA_ATTR static int flag = 0;
void app_main(void)
{
/*compute the dimension of the buffer if and only if this cycle is not a wake up from deep sleep*/
if(flag == 0){
buffer = (uint8_t *)malloc(computed_dimension);
}
else {
/*read the content of the buffer for the application logic*/
/*main application logic*/
}
/*reads and writes on the buffer*/
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_OFF);
esp_sleep_pd_config(ESP_PD_DOMAIN_VDDSDIO, ESP_PD_OPTION_OFF);
esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);
flag = 1;
esp_deep_sleep_start();
}
Details of the working environment:
Ubuntu 20.04.4 LTS
Platformio 6.0.2
Framework ESP-IDF 4.3.2
Board az-delivery-devkit-v4 ESP32