Save array of bytes in the RTC Fast Memory
Posted: Fri Jun 03, 2022 8:20 am
Hello
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
I expected that the above code worked but I get a LoadStoreError when the code tries to access the buffer, that means the content of buffer remains in the RAM losing its meaning after the deep sleep. How can I tell the ESP32 to save the content from the RAM pointed by buffer to the RTC Fast RAM?
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
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