ESP8266 Developer Zone The Official ESP8266 Forum 2018-10-28T09:17:36+08:00 https://bbs.espressif.com:443/feed.php?f=7&t=22912 2018-10-28T09:17:36+08:00 2018-10-28T09:17:36+08:00 https://bbs.espressif.com:443/viewtopic.php?t=22912&p=34605#p34605 <![CDATA[Re: Problems reading and writing RTC memory]]>
The units used in the function calls are not consistent - the first parameter,

Code:

uint32 des_addr
is in 32 bit blocks, but the third parameter

Code:

uint32 save_size
is in bytes.

I had been assuming both parameters were in 32 bit blocks and so I was writing only 1/4 of the data

Statistics: Posted by davydnorris — Sun Oct 28, 2018 9:17 am


]]>
2018-10-24T14:30:21+08:00 2018-10-24T14:30:21+08:00 https://bbs.espressif.com:443/viewtopic.php?t=22912&p=34401#p34401 <![CDATA[Re: Problems reading and writing RTC memory]]> https://www.espressif.com/sites/default/files/documentation/2C-ESP8266_Non_OS_SDK_API_Reference__EN.pdf

Statistics: Posted by Her Mary — Wed Oct 24, 2018 2:30 pm


]]>
2018-10-15T08:28:35+08:00 2018-10-15T08:28:35+08:00 https://bbs.espressif.com:443/viewtopic.php?t=22912&p=33706#p33706 <![CDATA[Problems reading and writing RTC memory]]>
I am trying to use the user area of the RTC memory to store values and I am finding that certain areas are getting corrupted, or are not writable.

I am using NonOS SDK 2.2.1 and have written a small program to write random sized chunks of data to the RTC user memory area, then read them back. I use a data structure like this:

Code:

#define RTC_SIZE (512 - 2*sizeof(uint32_t))

struct {
    uint32_t crc;
    uint32_t len;
    uint8_t data[RTC_SIZE];
} rtcData;

//fill rtcData.data with random length of random data
//store length of data in rtcData.len
//calculate CRC32 by crc32((uint8_t*)&rtcData.len, sizeof(rtcData)-4)
//store crc in rcData.crc


then I write the data with:

Code:

system_rtc_mem_write(64, (void *)&rtc_mem, sizeof(rtcData)/4);

and then read it back with:

Code:

system_rtc_mem_read(64, (void *)&rtc_mem, sizeof(rtcData)/4);


When I checked the checksum, it didn't match. I then printed out the data before and after and I found that most of the data matched but that there were several locations where the values were different. This seemed to be the case each time I tried writing random amounts of data, and it seems like the regions are scattered through the user area of the RTC memory, which makes it very difficult to write larger blocks of information.

My next test is to read and write a 32 bit value at a time to try and map out the problem slots, but this is happening on several different ESP8266 modules (Lolin v3, Wemos, AI Thinker ESP-12F - I haven't tried on WROOM-02 yet)

Do you know of any SDK functions that are using the RTC user memory area, or any reason why the RTC memory would be corrupted?

Statistics: Posted by davydnorris — Mon Oct 15, 2018 8:28 am


]]>