Skip to content

boards/sim/sim/sim/nsh: enable CONFIG_RTC for host time sync#19048

Open
Zepp-Hanzj wants to merge 1 commit into
apache:masterfrom
Zepp-Hanzj:fix/sim-nsh-rtc
Open

boards/sim/sim/sim/nsh: enable CONFIG_RTC for host time sync#19048
Zepp-Hanzj wants to merge 1 commit into
apache:masterfrom
Zepp-Hanzj:fix/sim-nsh-rtc

Conversation

@Zepp-Hanzj
Copy link
Copy Markdown
Contributor

@Zepp-Hanzj Zepp-Hanzj commented Jun 5, 2026

Note: Please adhere to Contributing Guidelines.

Summary

The default sim:nsh configuration does not enable CONFIG_RTC. As a result, the NSH_DISABLE_DATE option defaults to y (its default is DEFAULT_SMALL || !RTC), which causes the date command to not be compiled in. Users see nsh: date: command not found and the system time defaults to a hardcoded value instead of syncing with the host.

This patch adds CONFIG_RTC=y, CONFIG_RTC_DRIVER=y, and CONFIG_RTC_ARCH=y to boards/sim/sim/sim/configs/nsh/defconfig so the date command is available and shows the correct host time out of the box.

Should fix apache/nuttx-apps#3410.

Impact

  • Is new feature?: NO (bug fix)
  • Impact on user?: YES (users can now use the date command in sim:nsh without manual config changes)
  • Impact on build?: NO (only defconfig change)
  • Impact on hardware?: NO (sim target only)
  • Impact on documentation?: NO
  • Impact on security?: NO
  • Impact on compatibility?: NO

Testing

Host: Linux x86_64

Build and run:

$ make distclean && ./tools/configure.sh sim:nsh && ./tools/refresh.sh --silent sim:nsh && make -j
$ ./nuttx
NuttShell (NSH) NuttX-3.6.1
nsh> date
Fri, Jun 05 13:58:33 2026

Before fix:

nsh> date
nsh: date: command not found

After fix:

nsh> date
Fri, Jun 05 13:58:33 2026

@github-actions github-actions Bot added Size: XS The size of the change in this PR is very small Board: simulator labels Jun 5, 2026
CONFIG_SYSTEM_NSH=y
CONFIG_TESTING_OSTEST=y

CONFIG_RTC=y
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need normalize by ./tools/refresh.sh --silent sim:nsh

Copy link
Copy Markdown
Contributor

@linguini1 linguini1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please follow the PR template? It makes PRs consistent so they are much easier to search through.

Are you AI-generating the test logs? Why does it say NuttX 3.6.1?

@linguini1
Copy link
Copy Markdown
Contributor

Also, this doesn't verify that it actually closes the issue. The issue is that newly created files don't have dates. Can you also try to reproduce the issue test?

@Zepp-Hanzj
Copy link
Copy Markdown
Contributor Author

Can you please follow the PR template? It makes PRs consistent so they are much easier to search through.

Are you AI-generating the test logs? Why does it say NuttX 3.6.1?

hanzj-mi@hanzj-mi:/workspace/nuttx$ git diff
diff --git a/boards/sim/sim/sim/configs/nsh/defconfig b/boards/sim/sim/sim/configs/nsh/defconfig
index c44d9f3203..5d6ea0e858 100644
--- a/boards/sim/sim/sim/configs/nsh/defconfig
+++ b/boards/sim/sim/sim/configs/nsh/defconfig
@@ -72,3 +72,7 @@ CONFIG_SYSTEM_DUMPSTACK=y
CONFIG_SYSTEM_GCOV=y
CONFIG_SYSTEM_NSH=y
CONFIG_TESTING_OSTEST=y
+
+CONFIG_RTC=y
+CONFIG_RTC_DRIVER=y
+CONFIG_RTC_ARCH=y
hanzj-mi@hanzj-mi:
/workspace/nuttx$ make distclean
hanzj-mi@hanzj-mi:/workspace/nuttx$ ./tools/configure.sh sim:nsh
Copy files
Select CONFIG_HOST_LINUX=y
Refreshing...
CP: arch/dummy/Kconfig to /home/hanzj-mi/workspace/nuttx/arch/dummy/dummy_kconfig
CP: boards/dummy/Kconfig to /home/hanzj-mi/workspace/nuttx/boards/dummy/dummy_kconfig
LN: platform/board to /home/hanzj-mi/workspace/apps/platform/dummy
LN: include/arch to arch/sim/include
LN: include/arch/board to /home/hanzj-mi/workspace/nuttx/boards/sim/sim/sim/include
LN: drivers/platform to /home/hanzj-mi/workspace/nuttx/drivers/dummy
LN: include/arch/chip to /home/hanzj-mi/workspace/nuttx/arch/sim/include/sim
LN: arch/sim/src/chip to /home/hanzj-mi/workspace/nuttx/arch/sim/src/sim
LN: arch/sim/src/board to /home/hanzj-mi/workspace/nuttx/boards/sim/sim/sim/src
mkkconfig in /home/hanzj-mi/workspace/apps/audioutils
mkkconfig in /home/hanzj-mi/workspace/apps/benchmarks
mkkconfig in /home/hanzj-mi/workspace/apps/boot
mkkconfig in /home/hanzj-mi/workspace/apps/canutils
mkkconfig in /home/hanzj-mi/workspace/apps/crypto
mkkconfig in /home/hanzj-mi/workspace/apps/database
mkkconfig in /home/hanzj-mi/workspace/apps/examples/elf/tests
mkkconfig in /home/hanzj-mi/workspace/apps/examples/elf
mkkconfig in /home/hanzj-mi/workspace/apps/examples/mcuboot
mkkconfig in /home/hanzj-mi/workspace/apps/examples/module
mkkconfig in /home/hanzj-mi/workspace/apps/examples/rust
mkkconfig in /home/hanzj-mi/workspace/apps/examples/sotest
mkkconfig in /home/hanzj-mi/workspace/apps/examples
mkkconfig in /home/hanzj-mi/workspace/apps/fsutils
mkkconfig in /home/hanzj-mi/workspace/apps/games
mkkconfig in /home/hanzj-mi/workspace/apps/graphics
mkkconfig in /home/hanzj-mi/workspace/apps/industry/modbus
mkkconfig in /home/hanzj-mi/workspace/apps/industry
mkkconfig in /home/hanzj-mi/workspace/apps/inertial
mkkconfig in /home/hanzj-mi/workspace/apps/interpreters/luamodules
mkkconfig in /home/hanzj-mi/workspace/apps/interpreters
mkkconfig in /home/hanzj-mi/workspace/apps/logging
mkkconfig in /home/hanzj-mi/workspace/apps/lte
mkkconfig in /home/hanzj-mi/workspace/apps/math
mkkconfig in /home/hanzj-mi/workspace/apps/mlearning
mkkconfig in /home/hanzj-mi/workspace/apps/netutils
mkkconfig in /home/hanzj-mi/workspace/apps/sdr
mkkconfig in /home/hanzj-mi/workspace/apps/system
mkkconfig in /home/hanzj-mi/workspace/apps/tee
mkkconfig in /home/hanzj-mi/workspace/apps/testing/arch
mkkconfig in /home/hanzj-mi/workspace/apps/testing/cxx
mkkconfig in /home/hanzj-mi/workspace/apps/testing/drivers
mkkconfig in /home/hanzj-mi/workspace/apps/testing/fs
mkkconfig in /home/hanzj-mi/workspace/apps/testing/libc
mkkconfig in /home/hanzj-mi/workspace/apps/testing/mm
mkkconfig in /home/hanzj-mi/workspace/apps/testing/sched
mkkconfig in /home/hanzj-mi/workspace/apps/testing
mkkconfig in /home/hanzj-mi/workspace/apps/videoutils
mkkconfig in /home/hanzj-mi/workspace/apps/wireless/bluetooth
mkkconfig in /home/hanzj-mi/workspace/apps/wireless/ieee802154
mkkconfig in /home/hanzj-mi/workspace/apps/wireless
mkkconfig in /home/hanzj-mi/workspace/apps
Loaded configuration '.config'
Configuration saved to '.config'
hanzj-mi@hanzj-mi:
/workspace/nuttx$ make -j
Create version.h
LN: platform/board to /home/hanzj-mi/workspace/apps/platform/dummy
Register: gcov
Register: hello
Register: dd
Register: dumpstack
Register: nsh
Register: sh
Register: gpio
Register: ostest
CP: /home/hanzj-mi/workspace/nuttx/include/nuttx/config.h
CP: /home/hanzj-mi/workspace/nuttx/include/nuttx/fs/hostfs.h
LD: nuttx
Pac SIM with dynamic libs..
'/lib/x86_64-linux-gnu/libz.so.1' -> 'sim-pac/libs/libz.so.1'
'/lib/x86_64-linux-gnu/libc.so.6' -> 'sim-pac/libs/libc.so.6'
'/lib64/ld-linux-x86-64.so.2' -> 'sim-pac/ld-linux-x86-64.so.2'
SIM elf with dynamic libs archive in nuttx.tgz
hanzj-mi@hanzj-mi:~/workspace/nuttx$ ./nuttx

NuttShell (NSH) NuttX-3.6.1
nsh> date
Fri, Jun 05 13:58:33 2026
nsh>

This is my actual execution log. uttX 3.6.1 is the version of your local nuttx repository's current master branch. The version comes from the .version file:
CONFIG_VERSION_STRING="3.6.1"

@Zepp-Hanzj
Copy link
Copy Markdown
Contributor Author

Done. Ran ./tools/refresh.sh --silent sim:nsh to normalize the defconfig.

@linguini1
Copy link
Copy Markdown
Contributor

Hmmm @Zepp-Hanzj this version string is a bug, since NuttX is actually at 13.0.0 (or getting ready for it's release). Could you open an issue for it?

@Zepp-Hanzj
Copy link
Copy Markdown
Contributor Author

Also, this doesn't verify that it actually closes the issue. The issue is that newly created files don't have dates. Can you also try to reproduce the issue test?

image image The ls -l output in the default sim:nsh config doesn't display file timestamps (the hostfs/tmpfs in this config doesn't report them), so I can't directly show the file creation date.

@Zepp-Hanzj
Copy link
Copy Markdown
Contributor Author

Hmmm @Zepp-Hanzj this version string is a bug, since NuttX is actually at 13.0.0 (or getting ready for it's release). Could you open an issue for it?

This was a stale local .version file, not a code bug. After fetching upstream tags and regenerating, the version correctly shows NuttX-12.13.0. The latest upstream tag is nuttx-12.13.0 — there is no nuttx-13.0.0 tag yet. The version string is generated by tools/version.sh via git describe --match "nuttx-*", so it will automatically update to 13.0.0 once that tag is created.
Do we still need an issue for this, or is the tag simply not created yet?

…time

The default sim:nsh config has no RTC, causing NSH_DISABLE_DATE to be
auto-enabled (default: DEFAULT_SMALL || !RTC). This means the date
command is not compiled in, and the system time defaults to a hardcoded
value instead of syncing with the host.

Enable CONFIG_RTC, CONFIG_RTC_DRIVER, and CONFIG_RTC_ARCH in the
sim:nsh defconfig so the date command is available and shows the
correct host time out of the box.

Signed-off-by: hanzj <hanzjian@zepp.com>
@linguini1
Copy link
Copy Markdown
Contributor

The ls -l output in the default sim:nsh config doesn't display file timestamps (the hostfs/tmpfs in this config doesn't report them), so I can't directly show the file creation date.

Ah I see, this feature is added in the PR pending merge. Then maybe for now we don't say that this PR closes that issue but should fix it, and wait for the other author to confirm.

@linguini1 linguini1 dismissed their stale review June 5, 2026 15:55

explained

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

Labels

Board: simulator Size: XS The size of the change in this PR is very small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] SIM is creating file with wrong date/time

3 participants