Description
The variable offset
in ESP.rtcUserMemoryRead and ESP.rtcUserMemoryWrite is used inconsistently. Either it should be in bytes or block of 4 bytes. (Probably the latter)
The corresponding functions in (system_rtc_mem_read and system_rtc_mem_write) "user_interface.h" uses a multiple of 4 bytes for src_addr
and dst_addr
. The total rtc memory amount is 768 bytes, the first 256 bytes reserved for system use and 512 bytes available to the user!
In the "Esp.cpp" offset
is used as a multiple of 4 bytes in these lines:
return system_rtc_mem_read(64 + offset, data, size);
return system_rtc_mem_write(64 + offset, data, size);
(64 blocks being the reserved memory, 256 bytes / 4)
A few lines above these, a test uses offset
as a single byte:
if (size + offset > 512)
return false;
If offset
represents blocks of 4 bytes, it should read
if (size + offset*4 > 512)
or else
return system_rtc_mem_read(64 + offset/4, data, size);
return system_rtc_mem_write(64 + offset/4, data, size);
(The latter being rather stupid)
By the way, does offset
need to be uint32_t
when it is converted to uint8
in the system calls?