We have an M41T0M6
RTC device fitted to our custom Apalis TK1 carrier. When working with the system time recently, we noticed that the time is not being maintained - resetting to "2000-01-01 00:00"
every time our platform is being rebooted.
For reference, this is an L4T Ubuntu-based system.
Upon closer inspection, it would appear that our I2C RTC device is not being loaded at bootup:
ubuntu@linux-toradex:~$ dmesg | grep rtc
[ 4.165861] as3722-rtc as3722-rtc.1: rtc core: registered as3722 as rtc0
[ 4.173819] as3722-rtc as3722-rtc.1: RTC interrupt 449
[ 4.190254] rtc-ds1307: probe of 0-0068 failed with error -5
[ 4.197636] tegra_rtc tegra_rtc: rtc core: registered tegra_rtc as rtc1
[ 4.209827] tegra_rtc tegra_rtc: Tegra internal Real Time Clock
[ 5.562800] as3722-rtc as3722-rtc.1: setting system clock to 2000-01-01 00:00:08 UTC (946684808)
However, two RTC devices already exist on the system:
ubuntu@linux-toradex:~$ ls -l /dev/rtc*
lrwxrwxrwx 1 root root 4 Jan 1 00:00 /dev/rtc -> rtc0
crw------- 1 root root 254, 0 Jan 1 00:00 /dev/rtc0
crw------- 1 root root 254, 1 Jan 1 00:00 /dev/rtc1
One of which we assume is the RTC fitted on the TK1 module, the other, we are unsure of its source.
If we check the the hwclock
, it does indeed report the default time:
ubuntu@linux-toradex:~$ sudo hwclock
Sat Jan 1 00:27:23 2000 -0.983358 seconds
And upon closer inspection, the hwclock
is using one of the installed RTC devices:
ubuntu@linux-toradex:~$ sudo hwclock --debug
hwclock from util-linux 2.20.1
Using /dev interface to clock.
Last drift adjustment done at 1503997511 seconds after 1969
Last calibration done at 1503997511 seconds after 1969
Hardware clock is on UTC time
Assuming hardware clock is kept in UTC time.
Waiting for clock tick...
...got clock tick
Time read from Hardware Clock: 2000/01/01 00:28:24
Hw clock time : 2000/01/01 00:28:24 = 946686504 seconds since 1969
Sat Jan 1 00:28:24 2000 -0.428543 seconds
Now obviously, what we want is for the system to use our RTC rather than one of these other devices.
Having looked at the device-tree
, its obvious that we have not configured the device correctly as by default it is assigned to GEN1_I2C
(pins 209/211) whereas on our carrier, the RTC device is connected to I2C2
(pins 205/207).
Our question is this: once we have modified/rebuilt/updated the device tree, are there any special steps necessary in order to point the /dev/rtc
device to our new device?
Would this be a correct modification of the tegra124-apalis-eval.dtb
file to move the RTC onto the other I2C port:
i2c@7000c400 {
status = "okay";
clock-frequency = <100000>;
rtc@68 {
compatible = "st, m41t00";
reg = <0x68>;
};
};