I’m developing an application in the imx6 SOM board. To display the date and time in the application UI, I’m trying to read the hardware time from RTC. I tried the default command as “hwclock -r”. While executing this, it shows error message as below.
Error: “hwclock: Cannot access the Hardware Clock via any known method.”
I tried to check the status of RTC by typing “hwclock --verbose”. This shows that, “No usable clock interface found”. I attached the screenshot for the error message for details. Kindly help to get the hardware clock in the application.
Thanks for support.
I tried the “timedatectl” command to retrieve the RTC clock. It is working while the application is in ON state. If I restart the device, the timer stopped at the same instant and after startup of the application it continues. Even the battery was connected continuously while at the restart state. It stops the timer when I shutdown the system and it starts again from the last instant when I logged in. The timer is not running at the back-end to hold the continuous time stamp.
I don’t know whether I’m missing any process to update. Please guide me to do the continuous running of RTC timer to get the proper time stamp in the application UI.
The output you are seeing from hwclock indicates that there is not rtc device in /dev. That can have two reasons:
The driver for the hardware clock is not enabled in the Linux kernel configuration.in defconfigCONFIG_RTC_CLASS=y and the specific driver need to be enabled. There is an NXP built-in hardware clock for which it it is CONFIG_RTC_DRV_SNVS. The Verdin modules also have an external (more power efficient) hardware clock connected via I2C. For that the config is CONFIG_RTC_DRV_DS1307=y.
The hardware clock device must be declared in the device tree and enabled. That is normally the case for the Toradex device trees.
The default uses the external hardware clock. Here from a Verdin IMX8MP:
# ls -l /dev/rtc*
lrwxrwxrwx 1 root root 4 Feb 16 06:19 /dev/rtc -> rtc0
crw------- 1 root root 251, 0 Feb 16 06:19 /dev/rtc0
crw------- 1 root root 251, 1 Feb 16 06:19 /dev/rtc1
rtc0 is the external hardware clock on the link from /dev/rtc to /dev/rtc0 makes it the default for hwclock and timedatectl.