This is an automated email from the ASF dual-hosted git repository.
acassis pushed a commit to branch releases/13.1
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/releases/13.1 by this push:
new ceb32679a99 arch/risc-v/espressif: keep RTC backup data in DRAM
without RTC memory
ceb32679a99 is described below
commit ceb32679a99832af24008b1666ea67622b4fdd5f
Author: Marcio Ribeiro <[email protected]>
AuthorDate: Wed Sep 16 14:56:15 2026 -0300
arch/risc-v/espressif: keep RTC backup data in DRAM without RTC memory
SoCs such as the ESP32-C2 have no RTC retention memory, so RTC_DATA_ATTR
cannot be used for the persistent RTC time. Place the backup data in DRAM
on those chips, where the saved time does not survive deep sleep.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Marcio Ribeiro <[email protected]>
---
arch/risc-v/src/common/espressif/esp_rtc.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/arch/risc-v/src/common/espressif/esp_rtc.c
b/arch/risc-v/src/common/espressif/esp_rtc.c
index 16c10abe401..fdddd98c764 100644
--- a/arch/risc-v/src/common/espressif/esp_rtc.c
+++ b/arch/risc-v/src/common/espressif/esp_rtc.c
@@ -164,9 +164,15 @@ static bool g_hr_timer_enabled = false;
#endif /* CONFIG_RTC_DRIVER */
-/* Saved data for persistent RTC time */
+/* Saved data for persistent RTC time. Chips without RTC retention memory
+ * keep it in DRAM, so the saved time does not survive deep sleep.
+ */
+#ifdef SOC_RTC_MEM_SUPPORTED
static RTC_DATA_ATTR struct esp_rtc_backup_s g_rtc_saved_data;
+#else
+static struct esp_rtc_backup_s g_rtc_saved_data;
+#endif
static struct esp_rtc_backup_s *g_rtc_save;
/****************************************************************************
@@ -326,6 +332,7 @@ static int esp_rtc_rdtime(struct rtc_lowerhalf_s *lower,
if (gmtime_r(&timer, (struct tm *)rtctime) == 0)
{
int errcode = get_errno();
+
DEBUGASSERT(errcode > 0);
rtcerr("gmtime_r failed: %d\n", errcode);
@@ -949,6 +956,7 @@ int esp_rtc_driverinit(void)
struct rtc_lowerhalf_s *lower = (struct rtc_lowerhalf_s *)&g_rtc_lowerhalf;
int ret = rtc_initialize(0, lower);
+
if (ret < 0)
{
return ret;