Skip to content

arch/sim: register RTC after clock initialization#19514

Draft
Zepp-Hanzj wants to merge 1 commit into
apache:masterfrom
Zepp-Hanzj:fix/sim-rtc-inode-timestamp
Draft

arch/sim: register RTC after clock initialization#19514
Zepp-Hanzj wants to merge 1 commit into
apache:masterfrom
Zepp-Hanzj:fix/sim-rtc-inode-timestamp

Conversation

@Zepp-Hanzj

Copy link
Copy Markdown
Contributor

Summary

Registering /dev/rtc0 from up_rtc_initialize() creates its
PseudoFS inode before clock_inittime() synchronizes
CLOCK_REALTIME. As a result, the inode timestamp is zero and
ls -l /dev omits the date for rtc0.

Keep the RTC lower-half setup in the early initialization path so it
can still provide the system time. Defer registration of the RTC
character device to up_initialize(), after clock initialization has
completed.

Fixes #19504.

Impact

This change only affects the SIM RTC initialization order. The
/dev/rtc0 inode now receives a valid creation timestamp. RTC time
synchronization and the RTC driver interface are unchanged.

Testing

Host:

  • Ubuntu 20.04.6 LTS under WSL2, x86_64
  • Board configuration: sim:nsh

The baseline and fixed builds used identical .config files, verified
with cmp.

Before this change on master:

nsh> ls -l /dev
 crw-------           0 rtc0
nsh> date
Fri, Jul 24 02:24:43 2026

After this change:

nsh> ls -l /dev
 crw-------           0 2026-07-24 02:16 rtc0
nsh> date
Fri, Jul 24 02:16:59 2026

Additional checks:

  • ./tools/checkpatch.sh -f passes for all modified files.
  • sim:nsh builds successfully.
  • sim:ostest, which does not enable RTC support, builds successfully.

Registering /dev/rtc0 from up_rtc_initialize() creates the pseudofs inode before clock_inittime() synchronizes CLOCK_REALTIME. Its timestamp is consequently zero and omitted by ls -l.

Keep lower-half setup in early RTC initialization, but defer character-device registration to up_initialize(), which runs after clock initialization.

Fixes apache#19504

Signed-off-by: hanzhijian <hanzhijian@zepp.com>
@github-actions github-actions Bot added Arch: simulator Issues related to the SIMulator Size: S The size of the change in this PR is small labels Jul 24, 2026
@github-actions

Copy link
Copy Markdown

MemBrowse Memory Report

No memory changes detected for:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Arch: simulator Issues related to the SIMulator Size: S The size of the change in this PR is small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] NuttX on SIM is not list date info to /dev/rtc0

1 participant