ESP32 changes placed in RTC memory variables after returning from deep sleep

Paul_Rodopi
Posts: 1
Joined: Wed Oct 02, 2024 3:01 am

ESP32 changes placed in RTC memory variables after returning from deep sleep

Postby Paul_Rodopi » Wed Oct 02, 2024 3:27 am

Dear colleagues,

I will appreciate you help in solving the following problem I encounter when programming my ESP32 Lolin32 board.

I have defined a structure in RTC memory for keeping calculated up to six time offsets between SNTP and RTC time:

typedef struct
{
struct timeval offset_t[ESP_MAX_TIMESYNCS]; // array of time offsetts
int index_t; // current time offsett index
} time_offsets;

RTC_DATA_ATTR static time_offsetts all_offsets;

The structure is filled correctly up to the last time offset with index 5, when, by some reason ESP 32 changes
the value of timeval structure seconds part in the record with index 0 to one and the same value of 1073507920.

Index is 4:
Time offsett 0 has 1 sec, 757791 usec
Time offsett 1 has 3 sec, 369129 usec
Time offsett 2 has 4 sec, 308570 usec
Time offsett 3 has 4 sec, 45207 usec
Time offsett 4 has 3 sec, 521489 usec
Time offsett 5 has 0 sec, 0 usec

Index is 5:
Time offsett 0 has 1073507920 sec, 757791 usec
Time offsett 1 has 3 sec, 369129 usec
Time offsett 2 has 4 sec, 308570 usec
Time offsett 3 has 4 sec, 45207 usec
Time offsett 4 has 3 sec, 521489 usec
Time offsett 5 has 0 sec, 535202 usec

I carefully reviewed and debugged my code many times. The RTC memory for this variable seems correctly initialized
like:

memset(all_offsets, 0, sizeof(all_offsets));

and verified that it was.

But still cannot find a solution to this problem. Please advise me, how to solve this problem.

Thanks,

Paul

ESP_Sprite
Posts: 9607
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP32 changes placed in RTC memory variables after returning from deep sleep

Postby ESP_Sprite » Wed Oct 02, 2024 7:23 am

1073507920 in hex is 3FFC6E50, which looks like a pointer. Are you sure you're not overflowing something else somewhere?

Who is online

Users browsing this forum: No registered users and 4 guests