Skip to content

Internal RTC has unpredictable time after UF2 load on CP8 espressif #7590

@anecdata

Description

@anecdata

CircuitPython version

Adafruit CircuitPython 8.0.0-6-g58c0c2212 on 2023-02-14; Adafruit QT Py ESP32S2 with ESP32S2

Code/REPL

# after setting the internal rtc

>>> import time
>>> time.localtime()
struct_time(tm_year=2023, tm_mon=2, tm_mday=15, tm_hour=17, tm_min=4, tm_sec=22, tm_wday=2, tm_yday=46, tm_isdst=-1)
>>> 
>>> import microcontroller
>>> microcontroller.on_next_reset(microcontroller.RunMode.SAFE_MODE)
>>> # or: microcontroller.on_next_reset(microcontroller.RunMode.NORMAL)
>>> microcontroller.reset()
[17:04:54.884] Disconnected
[17:04:55.889] Warning: Could not open tty device (No such file or directory)
[17:04:55.889] Waiting for tty device..
[17:05:08.950] Connected
# after microcontroller.reset into SAFE_MODE or NORMAL

>>> import time
>>> time.localtime()
struct_time(tm_year=2023, tm_mon=2, tm_mday=15, tm_hour=17, tm_min=6, tm_sec=1, tm_wday=2, tm_yday=46, tm_isdst=-1)
>>> 
>>> import microcontroller
>>> microcontroller.on_next_reset(microcontroller.RunMode.UF2)
>>> microcontroller.reset()
[17:07:04.932] Disconnected
[17:07:05.938] Warning: Could not open tty device (No such file or directory)
[17:07:05.938] Waiting for tty device..
# after microcontroller.reset into UF2
#
# ...drop UF2...
[17:09:11.454] Connected
>>> import time
>>> time.localtime()
struct_time(tm_year=1971, tm_mon=3, tm_mday=14, tm_hour=8, tm_min=42, tm_sec=52, tm_wday=6, tm_yday=73, tm_isdst=-1)

Behavior

espressif boards conveniently keep the internal rtc date and time across reloads and software resets (not across power cycles or reset button).

But, recently (8.0.0 beta period), the internal rtc time gets scrambled when a UF2 is loaded, and often it's outside of the range that time.localtime() can process.

CP 7.3.3 starts up after UF2 load with the CircuitPython default time of 2000-01-01 00:00:00.

Description

No response

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions