mirror of
https://github.com/apache/nuttx.git
synced 2026-09-29 18:45:22 +00:00
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 <marcio.ribeiro@espressif.com>
This commit is contained in:
parent
a73bea0653
commit
ccf67497c7
1 changed files with 9 additions and 1 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue