Solved: hwclock on N2+

Post Reply
Richard Schaefer
Posts: 52
Joined: Wed Oct 11, 2017 9:40 am
languages_spoken: english
ODROIDs: C1, C2, HC1, XU4, N2
Has thanked: 6 times
Been thanked: 6 times
Contact:

Solved: hwclock on N2+

Post by Richard Schaefer »

I am having problems with the RTC on my N2+ (Tested on two different machines).
If I hard boot (power cycle) with the network disconnected (login via console)
I get the following:
odroid@mfsc-com:~$ sudo su
[sudo] password for odroid:
root@mfsc-com:/home/odroid#
root@mfsc-com:/home/odroid#
root@mfsc-com:/home/odroid# hwclock
hwclock: ioctl(RTC_RD_TIME) to /dev/rtc0 to read the time failed: Invalid argument
root@mfsc-com:/home/odroid# dmesg | grep rtc
[ 4.359499] hctosys: unable to open rtc device (rtc0)
[ 9.009839] rtc-pcf8563 1-0051: low voltage detected, date/time is not reliable.
[ 9.018160] rtc-pcf8563 1-0051: rtc core: registered rtc-pcf8563 as rtc0
[ 59.749319] rtc-pcf8563 1-0051: low voltage detected, date/time is not reliable.
root@mfsc-com:/home/odroid#
The following then works:
root@mfsc-com:/home/odroid# hwclock -w
root@mfsc-com:/home/odroid# hwclock
2021-02-25 09:18:12.089481-06:00
root@mfsc-com:/home/odroid#
If I reboot (soft boot) without the network ... the hwclock command works.
If I cycle the power again, without the network ... the hwclock fails again.
When the network is connected ... the NTP server seems to set the hwclock ... so it works after the NTP server detects the time.

Seems like a hard boot wipes out the RTC setting.
For devices that are often disconnected from the net ... this is a problem.
Last edited by Richard Schaefer on Wed Mar 24, 2021 1:12 am, edited 1 time in total.

User avatar
odroid
Site Admin
Posts: 37371
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 1785 times
Been thanked: 1138 times
Contact:

Re: hwclock on N2+

Post by odroid »

It seems the RTC backup battery was not installed properly since you could see low voltage detected, date/time is not reliable. message.

Carefully look into the battery contact pin location on the battery holder.
https://wiki.odroid.com/odroid-n2/getti ... tc_battery

Richard Schaefer
Posts: 52
Joined: Wed Oct 11, 2017 9:40 am
languages_spoken: english
ODROIDs: C1, C2, HC1, XU4, N2
Has thanked: 6 times
Been thanked: 6 times
Contact:

Re: hwclock on N2+

Post by Richard Schaefer »

That message goes away when I do a hwclock -w
Also I had already tried a second new battery.
I am not sure if that message is an OR or an AND of the two clauses in the message.

User avatar
odroid
Site Admin
Posts: 37371
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 1785 times
Been thanked: 1138 times
Contact:

Re: hwclock on N2+

Post by odroid »

If you have a DMM, measure the voltage of the backup battery to narrow down root causes.
Touch the DMM probes to the battery holder land areas on the PCB.

Richard Schaefer
Posts: 52
Joined: Wed Oct 11, 2017 9:40 am
languages_spoken: english
ODROIDs: C1, C2, HC1, XU4, N2
Has thanked: 6 times
Been thanked: 6 times
Contact:

Solved: hwclock on N2+

Post by Richard Schaefer »

After getting a DMM .. I found the problem was that the PINS inside the battery container that connect to the + side of the battery are bent down. Probably from improper battery installation.
I unboxed a new N2 and can now see that you need to slide the battery in with a sideways motion to compress the + contact pins and not a straight in from the top motion ... which will bend the + contact pins.
These users thanked the author Richard Schaefer for the post:
odroid (Wed Mar 24, 2021 8:00 am)

User avatar
vjoel
Posts: 33
Joined: Sat Nov 09, 2013 7:51 am
languages_spoken: English
ODROIDs: U2 (x2)
C2 (x2)
N2 (x1)
N2+ (x2)
Has thanked: 5 times
Been thanked: 0
Contact:

Re: Solved: hwclock on N2+

Post by vjoel »

Richard, if it's working for you now, would you mind showing the output of sudo dmesg | grep rtc?

The problem I am having is that the rtc appears to be working (the + is in the correct position), and hwclock reads the correct time, but the system clock is wrong (until ntpd runs). It seems that hwclock --hctosys is not succeeding on boot. Here's what I see after rebooting and quickly logging in before ntpd fixes the system clock (note the incorrect March 17, 2021 date):

Code: Select all

Last login: Wed Mar 17 14:36:20 2021 from 192.168.1.198
$ sudo hwclock
[sudo] password for vjoel: 
2021-04-08 13:47:41.855824-07:00
$ date
Wed 17 Mar 2021 02:36:28 PM PDT
$ sudo hwclock --hctosys
$ date                  
Thu 08 Apr 2021 01:51:27 PM PDT
This is what happens on boot:

Code: Select all

$ sudo dmesg | grep rtc
[    5.048998] hctosys: unable to open rtc device (rtc0)
[    9.710770] rtc-pcf8563 1-0051: rtc core: registered rtc-pcf8563 as rtc0
So, to sum up: the hwclock is set correctly and maintains time during reboot, and I can set the system clock from it manually, but setting the system clock fails during boot, maybe because it's happening before the kernel module is initialized.

I checked that this behavior is the same when doing a full shutdown, unplug power, plug power cycle, rather than just a reboot.

User avatar
vjoel
Posts: 33
Joined: Sat Nov 09, 2013 7:51 am
languages_spoken: English
ODROIDs: U2 (x2)
C2 (x2)
N2 (x1)
N2+ (x2)
Has thanked: 5 times
Been thanked: 0
Contact:

Re: Solved: hwclock on N2+

Post by vjoel »

I get the same results on my other N2+ as well.

These are the stock ubuntu installations: 20.04.2 LTS (GNU/Linux 4.9.241-113 aarch64).

User avatar
odroid
Site Admin
Posts: 37371
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 1785 times
Been thanked: 1138 times
Contact:

Re: Solved: hwclock on N2+

Post by odroid »

The symptom is normal since the pcf8563 device driver is not embedded in to the Kernel image.

Here is a workaround.
Make "hwrtc.service" file as the second method in this wiki page.
https://wiki.odroid.com/accessory/add-o ... figuration
These users thanked the author odroid for the post:
vjoel (Fri Apr 09, 2021 12:17 pm)

User avatar
vjoel
Posts: 33
Joined: Sat Nov 09, 2013 7:51 am
languages_spoken: English
ODROIDs: U2 (x2)
C2 (x2)
N2 (x1)
N2+ (x2)
Has thanked: 5 times
Been thanked: 0
Contact:

Re: Solved: hwclock on N2+

Post by vjoel »

Seems to work. Thanks!

Post Reply

Return to “Ubuntu”

Who is online

Users browsing this forum: No registered users and 3 guests