fix(esp32): define the RTC backup of ESP32RTCClock once

ESP32Board.h defined _rtc_backup_time and _rtc_backup_magic as static in the
header, so every translation unit that includes it has its own copy, and the
inline members of ESP32RTCClock read and write the copy of the unit they are
compiled in. Today one unit per image uses them; a second one could restore a
copy that setCurrentTime() never wrote. The header now declares them, and
ESP32Board.cpp defines them once.
This commit is contained in:
Marcel Verdult committed 2026-10-26 16:11:12 +01:00
1 parent 46216b2d0d
commit e197e557c3
2 files changed
+9 -2

No files matched your search

+4
View File
@@ -3,6 +3,10 @@
#include "ESP32Board.h"
#include <target.h>
// The RTC backup of ESP32RTCClock, declared in ESP32Board.h.
RTC_NOINIT_ATTR uint32_t _rtc_backup_time;
RTC_NOINIT_ATTR uint32_t _rtc_backup_magic;
#if defined(ADMIN_PASSWORD) && !defined(DISABLE_WIFI_OTA) // Repeater or Room Server only
#include <WiFi.h>
#include <AsyncTCP.h>
+5 -2
View File
@@ -200,8 +200,11 @@ public:
}
};
static RTC_NOINIT_ATTR uint32_t _rtc_backup_time;
static RTC_NOINIT_ATTR uint32_t _rtc_backup_magic;
// The time ESP32RTCClock restores after a reset, in RTC memory that a reset does
// not clear. Defined once, in ESP32Board.cpp: the inline members below run in
// every translation unit that uses them and must all see the same backup.
extern uint32_t _rtc_backup_time;
extern uint32_t _rtc_backup_magic;
#define RTC_BACKUP_MAGIC 0xAA55CC33
#define RTC_TIME_MIN 1772323200 // 1 Mar 2026