RTC is not work

Which version of system do you use? Khadas official images, self built images, or others?

vim1s-ubuntu-22.04-server-linux-5.4-fenix-1.4-221229.img.xz

Please describe your issue below:

I applied update packages using the below commands for fixing RTC behavior.

  1. Download update packages.
$ wget https://dl.khadas.com/.test/vim1s/linux-dtb-amlogic-5.4_1.4.2_arm64.deb
$ wget https://dl.khadas.com/.test/vim1s/linux-image-amlogic-5.4_1.4.2_arm64.deb
$ wget https://dl.khadas.com/.test/vim1s/linux-headers-amlogic-5.4_1.4.2_arm64.deb
  1. Install and apply update packages.
$ sudo dpkg -i linux-dtb-amlogic-5.4_1.4.2_arm64.deb
$ sudo dpkg -i linux-headers-amlogic-5.4_1.4.2_arm64.deb
$ sudo dpkg -i linux-image-amlogic-5.4_1.4.2_arm64.deb
$ sync
$ sudo reboot

It fixed the RTC initialize error at cold boot.
The RTC almost always returns an error response after inputting 'sudo hwclock` command.
It is rarely a success, but it returns an unstable date.

Post a console log of your issue below:

$ sudo hwclock ; until [ $? -eq 0 ]; do sudo hwclock; done
hwclock: select() to /dev/rtc0 to wait for clock tick timed out
hwclock: select() to /dev/rtc0 to wait for clock tick timed out
2023-03-15 00:37:12.224785+00:00
$ sudo hwclock ; until [ $? -eq 0 ]; do sudo hwclock; done
hwclock: select() to /dev/rtc0 to wait for clock tick timed out
hwclock: select() to /dev/rtc0 to wait for clock tick timed out
hwclock: select() to /dev/rtc0 to wait for clock tick timed out
2023-03-15 00:37:09.523792+00:00
$ sudo hwclock ; until [ $? -eq 0 ]; do sudo hwclock; done
hwclock: select() to /dev/rtc0 to wait for clock tick timed out
hwclock: select() to /dev/rtc0 to wait for clock tick timed out
hwclock: select() to /dev/rtc0 to wait for clock tick timed out
2023-03-15 00:37:14.497013+00:00
$ sudo hwclock ; until [ $? -eq 0 ]; do sudo hwclock; done
hwclock: select() to /dev/rtc0 to wait for clock tick timed out
hwclock: select() to /dev/rtc0 to wait for clock tick timed out
hwclock: select() to /dev/rtc0 to wait for clock tick timed out
2023-03-15 00:37:17.455794+00:00

Hello @s-ikeda

Based on current modifications, please try to upgrade a new dtb.

cd /tmp/
wget https://dl.khadas.com/.test/vim1s/230315/linux-dtb-amlogic-5.4_1.4.2_arm64.deb
sudo dpkg -i linux-dtb-amlogic-5.4_1.4.2_arm64.deb 
sync
sudo reboot

After reboot, please provide the information to me.

cat /sys/bus/i2c/devices/i2c-1/device/speed 

And then try to read the RTC.

sudo hwclock ; until [ $? -eq 0 ]; do sudo hwclock; done

If you still got errors, please provide the full kernel log.

Hi @numbqq

My environment never return RTC time this issue after applied a new dtb package.

$ sudo hwclock ; until [ $? -eq 0 ]; do sudo hwclock; done
[sudo] password for nandis:
hwclock: select() to /dev/rtc0 to wait for clock tick timed out
hwclock: select() to /dev/rtc0 to wait for clock tick timed out
hwclock: select() to /dev/rtc0 to wait for clock tick timed out
hwclock: select() to /dev/rtc0 to wait for clock tick timed out
hwclock: select() to /dev/rtc0 to wait for clock tick timed out
hwclock: select() to /dev/rtc0 to wait for clock tick timed out
hwclock: select() to /dev/rtc0 to wait for clock tick timed out
hwclock: select() to /dev/rtc0 to wait for clock tick timed out
hwclock: select() to /dev/rtc0 to wait for clock tick timed out
hwclock: select() to /dev/rtc0 to wait for clock tick timed out
:

The sysfs return value is below.

$ cat /sys/bus/i2c/devices/i2c-1/device/speed
100000

I shared the full kernel log that is output by the dmesg command.

Best regards,

Hello @s-ikeda

Updated a new version, please try to upgrade the new dtb again.

cd /tmp/
wget https://dl.khadas.com/.test/vim1s/230315/linux-dtb-amlogic-5.4_1.4.2_arm64.deb
sudo dpkg -i linux-dtb-amlogic-5.4_1.4.2_arm64.deb 
sync
sudo reboot

After reboot try to read the RTC.

sudo hwclock ; until [ $? -eq 0 ]; do sudo hwclock; done

And also provide the full kernel log.

Hi @numbqq

Thank you for your quick response.
It reproduced issue after applied a new dtb package.
sudo hwclock never returned RTC time.

$ sudo hwclock ; until [ $? -eq 0 ]; do sudo hwclock; done
hwclock: select() to /dev/rtc0 to wait for clock tick timed out
hwclock: select() to /dev/rtc0 to wait for clock tick timed out
:

Could you confirm full kernel log below?

Hello @s-ikeda

Please post the output of command below.

sudo hwclock -v; until [ $? -eq 0 ]; do sudo hwclock -v; done

Hi @numbqq

Could you confirm it?

$ sudo hwclock -v; until [ $? -eq 0 ]; do sudo hwclock -v; done
hwclock from util-linux 2.37.2
System Time: 1678873145.467835
Trying to open: /dev/rtc0
Using the rtc interface to the clock.
Last drift adjustment done at 1678865721 seconds after 1969
Last calibration done at 1678865721 seconds after 1969
Hardware clock is on UTC time
Assuming hardware clock is kept in UTC time.
Waiting for clock tick...
hwclock: select() to /dev/rtc0 to wait for clock tick timed out
...synchronization failed
hwclock from util-linux 2.37.2
System Time: 1678873155.514537
Trying to open: /dev/rtc0
Using the rtc interface to the clock.
Last drift adjustment done at 1678865721 seconds after 1969
Last calibration done at 1678865721 seconds after 1969
Hardware clock is on UTC time
Assuming hardware clock is kept in UTC time.
Waiting for clock tick...
hwclock: select() to /dev/rtc0 to wait for clock tick timed out
...synchronization failed
hwclock from util-linux 2.37.2
System Time: 1678873165.568563
Trying to open: /dev/rtc0
Using the rtc interface to the clock.
Last drift adjustment done at 1678865721 seconds after 1969
Last calibration done at 1678865721 seconds after 1969
Hardware clock is on UTC time
Assuming hardware clock is kept in UTC time.
Waiting for clock tick...
hwclock: select() to /dev/rtc0 to wait for clock tick timed out
...synchronization failed
hwclock from util-linux 2.37.2
System Time: 1678873175.623503
Trying to open: /dev/rtc0
Using the rtc interface to the clock.
Last drift adjustment done at 1678865721 seconds after 1969
Last calibration done at 1678865721 seconds after 1969
Hardware clock is on UTC time
Assuming hardware clock is kept in UTC time.
Waiting for clock tick...

Hello @s-ikeda

Strange, everything works well on my side.

Could you try to upgrade a new kernel to try again?

cd /tmp/
wget https://dl.khadas.com/.test/vim1s/230315/linux-dtb-amlogic-5.4_1.4.2_arm64.deb
wget https://dl.khadas.com/.test/vim1s/230315/linux-image-amlogic-5.4_1.4.2_arm64.deb
sudo dpkg -i linux-dtb-amlogic-5.4_1.4.2_arm64.deb linux-image-amlogic-5.4_1.4.2_arm64.deb 
sync
sudo reboot

After reboot, check the time again.

sudo hwclock -v; until [ $? -eq 0 ]; do sudo hwclock -v; done

Hi @numbqq

Thanks a lot!
That fine work as below after I replaced the VIM1S device with another one.

1. Download and apply update packages.

cd /tmp/
wget https://dl.khadas.com/.test/vim1s/linux-dtb-amlogic-5.4_1.4.2_arm64.deb
wget https://dl.khadas.com/.test/vim1s/linux-image-amlogic-5.4_1.4.2_arm64.deb
wget https://dl.khadas.com/.test/vim1s/linux-headers-amlogic-5.4_1.4.2_arm64.deb
sudo dpkg -i linux-dtb-amlogic-5.4_1.4.2_arm64.deb linux-headers-amlogic-5.4_1.4.2_arm64.deb linux-image-amlogic-5.4_1.4.2_arm64.deb
sync
sudo reboot

2. Confirm behavior.

Commands:

  • RTC date time:
sudo hwclock -v ; until [ $? -eq 0 ]; do sudo hwclock -v; done
  • Local and RTC date time:
while true; do timedatectl; sleep 1 ; done

Log outputs:

Output logs below when work fine.

$ sudo hwclock -v ; until [ $? -eq 0 ]; do sudo hwclock -v; done
hwclock from util-linux 2.37.2
System Time: 1678928397.042902
Trying to open: /dev/rtc0
Using the rtc interface to the clock.
Assuming hardware clock is kept in UTC time.
Waiting for clock tick...
...got clock tick
Time read from Hardware Clock: 2023/03/16 00:59:58
Hw clock time : 2023/03/16 00:59:58 = 1678928398 seconds since 1969
Time since last adjustment is 1678928398 seconds
Calculated Hardware Clock drift is 0.000000 seconds
2023-03-16 00:59:57.545682+00:00
$ while true; do timedatectl; sleep 1 ; done
               Local time: Thu 2023-03-16 01:00:05 UTC
           Universal time: Thu 2023-03-16 01:00:05 UTC
                 RTC time: Thu 2023-03-16 01:00:06
                Time zone: Etc/UTC (UTC, +0000)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no
               Local time: Thu 2023-03-16 01:00:06 UTC
           Universal time: Thu 2023-03-16 01:00:06 UTC
                 RTC time: Thu 2023-03-16 01:00:07
                Time zone: Etc/UTC (UTC, +0000)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no
               Local time: Thu 2023-03-16 01:00:07 UTC
           Universal time: Thu 2023-03-16 01:00:07 UTC
                 RTC time: Thu 2023-03-16 01:00:08
                Time zone: Etc/UTC (UTC, +0000)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

It’s probably that the 1st tested device had something broken with the hardware, in my opinion.
How can I request to RMA the 1st device?

Thanks a lot!

@s-ikeda

  • You can check the mailbox. There should be an answer(Gary)