← index #17521Issue #5199
Related · high · value 4.137
QUERY · ISSUE

docs: ESP32 RTC.memory and poweron_reset

openby davefesopened 2025-06-18updated 2025-09-27
docs

Documentation URL

https://docs.micropython.org/en/latest/library/machine.RTC.html

Description

The docs say it will survive "restarts", but it does not survive a poweron_reset. IE, pressing the EN button on the dev board.

Code of Conduct

Yes, I agree

CANDIDATE · ISSUE

machine.RTC.memory undocumented and does not survive watchdog reset

closedby goatchurchprimeopened 2019-10-09updated 2024-03-27

The documentation for machine.RTC contains 7 methods, yet yet MicroPython v1.11-406-g4a6974bea on 2019-10-06; ESP32 module with ESP32 has only 3 methods: init(), datetime(), and memory().

I assume the memory() function is supposed to access some non-volatile storage.

>>> import machine; 
>>> r = machine.RTC(); 
>>> r.memory("hi there")

Cntl-D soft reboot
[reset ensues]

>>> import machine; 
>>> r = machine.RTC(); 
>>> print(machine.reset_cause(), r.memory())
5, b'hi there'
>>> machine.deepsleep(1000)

[reset ensues]
 
>>> import machine; 
>>> r = machine.RTC(); 
>>> print(machine.reset_cause(), r.memory())
4, b'hi there'
>>> machine.WDT(0, 1000)

[reset ensues]

>>> import machine; 
>>> r = machine.RTC(); 
>>> print(machine.reset_cause(), r.memory())
5, b''

Calling machine.reset() also wipes this RTK.memory storage.

I guess we've found a way to tell the difference between the Ctrl-D soft reboot and a watchdog reset, outlined in issue #5134 (since the latter disappears the memory), but it's not quite what I want.

The use of this storage is to enable some form of debugging wherein the code keeps updating where it is in the various suspect loops and functions, so that when the watchdog resets it you have a hope of finding out where it hung.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied