Change default RTC Apalis iMX8


I have a rather simple question. We are using a custom carrier board for an Apalis iMX8QP module. This carrier board does not have an RTC (but does have a battery).

Based on the eval board devie-tree, what changes or patches can I apply to use the internal RTC by default instead of the external one? We are using a custom boot2Qt distro and it would be much practical to apply the changes at building rather than afterward by applying changes to the file system.

Here is what I have concerning rtc in dmesg:

dmesg | grep rtc
[    3.270848] imx-drm display-subsystem: bound imx-dpu-crtc.0 (ops dpu_crtc_ops)
[    3.278300] imx-drm display-subsystem: bound imx-dpu-crtc.1 (ops dpu_crtc_ops)
[    3.285755] imx-drm display-subsystem: bound imx-dpu-crtc.3 (ops dpu_crtc_ops)
[    3.293199] imx-drm display-subsystem: bound imx-dpu-crtc.4 (ops dpu_crtc_ops)
[    4.266530] rtc-ds1307: probe of 4-0068 failed with error -5
[    4.273646] imx_sc_rtc rtc: rtc core: registered rtc as rtc1
[    6.168978] hctosys: unable to open rtc device (rtc0)

An other weird thing is that timedatectl return this:

               Local time: Mon 2020-10-05 12:54:31 CEST
           Universal time: Mon 2020-10-05 10:54:31 UTC
                 RTC time: n/a
                Time zone: Europe/Zurich (CEST, +0200)
System clock synchronized: no
              NTP service: active
          RTC in local TZ: no

Even if it is 9:20 in the morning. The system time seems to always be 12:45 at boot…



The alias node in the device tree does the reserve /dev/rtcX nodes for specific RTCs.
So you will have to change the device-tree to have the imx_sc_rtc being the one to get /dev/rtc0.
Alternatively you could change the kernel assigned rtc node with an udev rule. E.g. like described here.

The linux system uses the /dev/rtc0 as its hwclock. If that does not exist then the systemtime will not be set correctly until e.g. it acquires time over the network with NTP or manually with date or …
I guess the kernel does advance the system clock to at least its build time which may be what you see.

In our regular images we install a poor man’s RTC, i.e. on shutdown the current time is stored in /etc/timestamp and on boot, if the systemtime is in the in the past of /etc/timestamp it gets advanced there to at least have a monotonous time. Compare with the meta-toradex-demos/recipes-core/systemd/ I don’t think that this makes it into a boot2qt build though.


I just forced rtc0 to be set to the SoM RTC in the device tree, like this:

(in my case it was imx6dl-colibri-eval-v3.dts, line 73)


Hope it helps someone.