Hi,
We build our custom main board for Apalis iMX6. Our plan is to test internal RTC. We have also external one, but if possible we would like to use the internal.
So I followed the instruction here:
I’ve created 99-rtc1.rules file:
root@apalis-imx6:~# cat /etc/udev/rules.d/99-rtc1.rules
KERNEL=="rtc1", SUBSYSTEM=="rtc", DRIVER=="", ATTR{name}=="m41t0", SYMLINK="rtc", MODE="0666"
Here is the log after reboot:
root@apalis-imx6:~# dmesg | grep -i rtc
[ 2.479275] rtc-ds1307: probe of 1-0068 failed with error -5
[ 2.490508] snvs_rtc 20cc000.snvs:snvs-rtc-lp: rtc core: registered 20cc000.snvs:snvs-r as rtc1
[ 3.313761] hctosys: unable to open rtc device (rtc0)
This is the result of timedatectl:
root@apalis-imx6:~# timedatectl
Local time: Sun 2020-05-31 12:16:25 UTC
Universal time: Sun 2020-05-31 12:16:25 UTC
RTC time: n/a
Time zone: Universal (UTC, +0000)
Network time on: no
NTP synchronized: no
RTC in local TZ: no
Could you please advice us how to switch to internal RTC.
Best regards,
Ivan
You can access internal iMX6 RTC by hwclock -f /dev/rtc1 command:
#hwclock -f /dev/rtc1 -r //(Show hardware clock time)
#hwclock -f /dev/rtc1 -w //(Set hardware clock from system time)
#hwclock -f /dev/rtc1 -s //(Set system time from hardware clock)
Thank you very much for your quick response. I successfully accessed the internal rtc with hwclock commands.
I was able to switch default rtc to rtc1 by creating symbolic link:
root@apalis-imx6:/dev# timedatectl
Local time: Tue 2020-06-02 08:18:59 UTC
Universal time: Tue 2020-06-02 08:18:59 UTC
RTC time: n/a
Time zone: Universal (UTC, +0000)
Network time on: no
NTP synchronized: no
RTC in local TZ: no
root@apalis-imx6:/dev# ln -s rtc1 rtc
root@apalis-imx6:/dev# timedatectl
Local time: Tue 2020-06-02 08:19:13 UTC
Universal time: Tue 2020-06-02 08:19:13 UTC
RTC time: Tue 2020-06-02 08:31:40
Time zone: Universal (UTC, +0000)
Network time on: no
NTP synchronized: no
RTC in local TZ: no
Unfortunately after reboot symbolic link is deleted. Following message still presence in boot log:
hctosys: unable to open rtc device (rtc0)
Is there a way to set rtc1 as default rtc permanently?
Best regards,
Ivan
Hi again,
I found another rule in Angstrom distribution - localextra.rules.
It implements the following rule:
# The first rtc device is symlinked to /dev/rtc
KERNEL=="rtc0", SYMLINK+="rtc"
I’ve updated it in the following way and rtc1 was set as rtc:
# The first rtc device is symlinked to /dev/rtc
KERNEL=="rtc1", SYMLINK+="rtc"
Unfotrunately there is still an issue with Local time and Universal time. After power-off, RTC is still ticking, as it should be, but Local time and Universal time are not synchronized. Seems like Kernel is still looking for rtc0.
root@apalis-imx6:~# timedatectl
Local time: Tue 2020-06-02 10:18:13 UTC
Universal time: Tue 2020-06-02 10:18:13 UTC
RTC time: Tue 2020-06-02 10:20:52
Time zone: Universal (UTC, +0000)
Network time on: no
NTP synchronized: no
RTC in local TZ: no
Should this topic be addressed to Angstrom/Yocto project?
Best regards,
Ivan
Symbolic as well as hard link should persists after reboot. How you done SW or HW reboot. Have you issued a “sync” command before reboot In the last case?
Hello,
It’s little bit old topic, but I would like to share some findings.
Regarding to Toradex WEB site, default RTC can be changed via 99-rtc1.rules file:
Regarding instructions, the content of the file has to be:
KERNEL==“rtc1”, SUBSYSTEM==“rtc”, DRIVER==“”, ATTR{name}==“m41t0”, SYMLINK=“rtc”, MODE=“0666”
In our case we were not able to change the default RTC from external RTC (the one placed on demo board) to i.MX6 internal RTC using this file.
I had to modify the content of the file.
ATTR{name}==“m41t0” is the name of the external RTC.
ATTR{name}==“20cc000.snvs:snvs-r” is the name of the i.MX6 internal RTC.
The content of 99-rtc1.rules file for our application is:
KERNEL==“rtc1”, SUBSYSTEM==“rtc”, DRIVER==“”, ATTR{name}==“20cc000.snvs:snvs-r”, SYMLINK=“rtc”, MODE=“0666”
After this modification, timedatectl can read RTC time and show it.
If RTC is running in UTC, hwclock option -u or --utc has to be used to be able to get or set the hardware time properly.
Best regards,
Ivan