RTC battery installed but RTC doesn't keep time across power cycle

Post Reply
rpineau
Posts: 25
Joined: Sun Sep 30, 2018 12:19 pm
languages_spoken: english
ODROIDs: XU4
Has thanked: 0
Been thanked: 1 time
Contact:

RTC battery installed but RTC doesn't keep time across power cycle

Unread post by rpineau » Sat Jun 22, 2019 10:03 am

I installed a battery for the N2 RTC but after a power cycle if I do hwclock -r, the date is the default one , not the one I had written to the RTC with hwclock -w :

Code: Select all

root@n2:~# hwclock -r
2018-01-28 07:58:54.015580-0800
The N2 is sync'd to a GPS :

Code: Select all

root@n2:~# ntpq -np
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*127.127.28.0    .GPS.            0 l   13   16    7    0.000  -50.532  36.540
and the date is correct :

Code: Select all

root@n2:~# date
Fri Jun 21 17:49:10 PDT 2019
I can store the time in the RTC :

Code: Select all

root@n2:~# hwclock -w
root@n2:~# hwclock -r
2019-06-21 17:49:42.655073-0700
Now I power cycle :

Code: Select all

root@n2:~# hwclock -r
2018-01-28 07:58:48.026170-0800
root@n2:~# date
Fri Jun 21 17:51:54 PDT 2019
I checked the battery and it's good and deliver over 3V
Is my RTC defective ?

Edit : I also checked that there is power on the RTC chip (vss to vdd shows almost 4V from a brand new CR2032) when everything is disconnected except the RTC battery. So the RTC do get power... the mystery deepens

phaseshifter
Posts: 3459
Joined: Fri May 08, 2015 9:12 am
languages_spoken: english
ODROIDs: U-2,U3+,,XU-3,,XU3-LITE,,XU-4
C1+,,C-2,,,
N-1,,N-2,...other odroid acc`s as well
Has thanked: 37 times
Been thanked: 42 times
Contact:

Re: RTC battery installed but RTC doesn't keep time across power cycle

Unread post by phaseshifter » Sun Jun 23, 2019 3:33 am

https://wiki.odroid.com/odroid-n2/appli ... akeup_time

https://wiki.odroid.com/accessory/add-o ... rtc_shield

some of this maybe usefully...i said some...!!!

also if you have the mate gui loaded set the time and location via it at the top right side of the desktop...

put

Code: Select all

hwclock -s 
into the

Code: Select all

/etc/rc.local 
file

all i did was to set the time and location via the gui and everything works fine even when i open a prompt and code hwclock -r...it`s the correct time...
Build It And They Will Come...Be Bold And Mighty Forces Will Come To Your Aid..!!!

rpineau
Posts: 25
Joined: Sun Sep 30, 2018 12:19 pm
languages_spoken: english
ODROIDs: XU4
Has thanked: 0
Been thanked: 1 time
Contact:

Re: RTC battery installed but RTC doesn't keep time across power cycle

Unread post by rpineau » Sun Jun 23, 2019 9:35 am

The issue is not with setting the time or reading it (and I've read the wiki article already), but thanks for trying to help.
The issue is that even with the battery the RTC doesn't keep track of time when the N2 is powered off.
So if I do a hwclock -s it will set the wrong time on my system. So before doing this I need to get the RTC battery to get it to keep time while the N2 is off (or there is no point).

phaseshifter
Posts: 3459
Joined: Fri May 08, 2015 9:12 am
languages_spoken: english
ODROIDs: U-2,U3+,,XU-3,,XU3-LITE,,XU-4
C1+,,C-2,,,
N-1,,N-2,...other odroid acc`s as well
Has thanked: 37 times
Been thanked: 42 times
Contact:

Re: RTC battery installed but RTC doesn't keep time across power cycle

Unread post by phaseshifter » Sun Jun 23, 2019 9:47 am

all i did was to set the time and location via the gui and everything works fine even when i open a prompt and code hwclock -r...it`s the correct time...after having the unit off for days

did you measure that the polarity of the wires are correct...did you check the voltage at the connector end of the battery wires...???

the red wire should be towards the cpu/inner side of the board and the black wire closest to the outer edge heat-sink...

oh your not plugging it into the fan connector by mistake are you..

the fan connector is closest to the audio output jack....the battery socket is middle left depending which way you look at the board....!!!
Build It And They Will Come...Be Bold And Mighty Forces Will Come To Your Aid..!!!

rpineau
Posts: 25
Joined: Sun Sep 30, 2018 12:19 pm
languages_spoken: english
ODROIDs: XU4
Has thanked: 0
Been thanked: 1 time
Contact:

Re: RTC battery installed but RTC doesn't keep time across power cycle

Unread post by rpineau » Mon Jun 24, 2019 2:50 am

I checked the voltage and the polarity, and it's plugged in the right connector (the fan one says FAN next to it :) , the RTC one says RTC next to it).

phaseshifter
Posts: 3459
Joined: Fri May 08, 2015 9:12 am
languages_spoken: english
ODROIDs: U-2,U3+,,XU-3,,XU3-LITE,,XU-4
C1+,,C-2,,,
N-1,,N-2,...other odroid acc`s as well
Has thanked: 37 times
Been thanked: 42 times
Contact:

Re: RTC battery installed but RTC doesn't keep time across power cycle

Unread post by phaseshifter » Mon Jun 24, 2019 10:50 am

have a read of this topic pls...


viewtopic.php?f=177&t=34737
Build It And They Will Come...Be Bold And Mighty Forces Will Come To Your Aid..!!!

rpineau
Posts: 25
Joined: Sun Sep 30, 2018 12:19 pm
languages_spoken: english
ODROIDs: XU4
Has thanked: 0
Been thanked: 1 time
Contact:

Re: RTC battery installed but RTC doesn't keep time across power cycle

Unread post by rpineau » Fri Jun 28, 2019 3:42 am

I did already. And I do understand that the kernel is trying to access a device that is not yet present (we then see the device registration a little bit latter). So unless the kernel force reset the RTC, nothing writes to it and when I log in it should have the proper date and time as the battery is in place.
My issue is that the date and time IN the RTC is reset back to 0 (2018-01-28) even with the battery connected when the N2 is powered off. So if just after reboot, before anything tries to write to the RTC, I do a hwclock -r I get a 2018-01-28 7:xx time .. which means the battery, even though it's present and provide power to the pcf8563, the time is not kept and it's like the RTC was powered off and lost time.
If you do a dmesg, you'll find the 2 messages about rtc0 but at no point does the kernel write to rtc0. Systemd doesn't have any service related to the hwclock started/enabled/installed.
/etc/init.d/hwclock.sh is never called (added a log in it and it never shows up, so not called).
So nothing touches the RTC at boot time and the time is not saved, as far as I can tell. I did a grep -r hwclock /etc/* ... nothing besides /etc/init.d/hwclock.sh. I move /etc/init.d/hwclock.sh out of the way and retested.. same thing.
just after reboot :

Code: Select all

root@n2:~# hwclock -r
2018-01-28 07:59:39.461523-0800
root@n2:~# uptime
 11:30:46 up 1 min,  1 user,  load average: 2.62, 0.87, 0.31
As I have NTP running with a GPS, the RTC will be set to the proper time at some point (ntpd daemon has the kernel sync to the hardware clock every 11 minutes) but still doesn't keep time when powered off.

Code: Select all

root@n2:~# ntpq -np
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*127.127.28.0    .GPS.            0 l    9   16   17    0.000    0.554 205.078
root@n2:~# date
Thu Jun 27 11:32:18 PDT 2019
root@n2:~# hwclock -r
2018-01-28 08:02:07.426525-0800
and the 11 minutes update :

Code: Select all

root@n2:~# hwclock 
2018-01-28 08:04:57.302712-0800
root@n2:~# uptime
 11:37:44 up 8 min,  1 user,  load average: 1.03, 1.09, 0.65
root@n2:~# uptime
 11:41:01 up 11 min,  1 user,  load average: 1.02, 1.06, 0.74
root@n2:~# hwclock 
2019-06-27 11:41:07.342152-0700
So either the RTC has an issue, or something that we haven't yet uncovered writes to it at boot time before the system get a proper time.

User avatar
odroid
Site Admin
Posts: 31852
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 89 times
Been thanked: 255 times
Contact:

Re: RTC battery installed but RTC doesn't keep time across power cycle

Unread post by odroid » Fri Jun 28, 2019 9:38 am

We will try to find a way to check the HW RTC tick count functionality.

nikodemus
Posts: 25
Joined: Fri Mar 08, 2019 2:15 pm
languages_spoken: german, english
ODROIDs: C1, C2, XU4, N2
Has thanked: 3 times
Been thanked: 1 time
Contact:

Re: RTC battery installed but RTC doesn't keep time across power cycle

Unread post by nikodemus » Sat Jun 29, 2019 8:10 pm

This is indeed very weird. You could additionally check without battery if you can measure some current (when the board is powered). You should read a very low voltage of max 0.1V but that might be enough to proof your wires are connected.

rpineau
Posts: 25
Joined: Sun Sep 30, 2018 12:19 pm
languages_spoken: english
ODROIDs: XU4
Has thanked: 0
Been thanked: 1 time
Contact:

Re: RTC battery installed but RTC doesn't keep time across power cycle

Unread post by rpineau » Mon Jul 01, 2019 11:32 am

I'll try that (probably not before mid-July).
As another way to test I ordered another N2 and will see if that one can keep the time when the battery is installed.

rpineau
Posts: 25
Joined: Sun Sep 30, 2018 12:19 pm
languages_spoken: english
ODROIDs: XU4
Has thanked: 0
Been thanked: 1 time
Contact:

Re: RTC battery installed but RTC doesn't keep time across power cycle

Unread post by rpineau » Sun Jul 14, 2019 12:21 am

Another user has the exact same issue and also though there might be a problem with his battery or RTC..
So something is resetting the RTC on boot.
I disable systemd timesync and ntp as a test and rebooted. When no time sync is running the hwclock keeps it time properly.
As soon as ntp starts, the hwclock is reset :

Code: Select all

root@n2:~# hwclock 
2019-07-13 08:20:23.592914-0700
root@n2:~# systemctl start ntp
root@n2:~# hwclock 
2018-01-28 07:59:42.883135-0800
root@n2:~#
So there is a software issue with NTP and the RTC.

User avatar
venkatbo
Posts: 526
Joined: Mon Feb 25, 2013 3:10 pm
languages_spoken: english
ODROIDs: C0/C1+/C2; U3+; XU3-Lite/XU4; H2; VU/VU7+; Touchscreen Show TFT Cloudshell SmartPower mAHRS DAC GPS Multiscope Ocam
Location: Bay Area, California
Has thanked: 0
Been thanked: 4 times
Contact:

Re: RTC battery installed but RTC doesn't keep time across power cycle

Unread post by venkatbo » Sun Jul 14, 2019 12:31 am


User avatar
rooted
Posts: 6588
Joined: Fri Dec 19, 2014 9:12 am
languages_spoken: english
Location: Gulf of Mexico, US
Has thanked: 88 times
Been thanked: 17 times
Contact:

Re: RTC battery installed but RTC doesn't keep time across power cycle

Unread post by rooted » Sun Jul 14, 2019 8:39 am

Let me see the output of:

Code: Select all

zcat /proc/config.gz | grep RTC 
These users thanked the author rooted for the post:
phaseshifter (Sun Jul 14, 2019 8:46 am)

phaseshifter
Posts: 3459
Joined: Fri May 08, 2015 9:12 am
languages_spoken: english
ODROIDs: U-2,U3+,,XU-3,,XU3-LITE,,XU-4
C1+,,C-2,,,
N-1,,N-2,...other odroid acc`s as well
Has thanked: 37 times
Been thanked: 42 times
Contact:

Re: RTC battery installed but RTC doesn't keep time across power cycle

Unread post by phaseshifter » Sun Jul 14, 2019 8:47 am

Hmmm this is rather interesting indeed....
Build It And They Will Come...Be Bold And Mighty Forces Will Come To Your Aid..!!!

rpineau
Posts: 25
Joined: Sun Sep 30, 2018 12:19 pm
languages_spoken: english
ODROIDs: XU4
Has thanked: 0
Been thanked: 1 time
Contact:

Re: RTC battery installed but RTC doesn't keep time across power cycle

Unread post by rpineau » Sun Jul 14, 2019 9:48 am

Here is the output :

Code: Select all

roro@n2:~$ zcat /proc/config.gz | grep RTC 
CONFIG_AMLOGIC_VRTC=y
CONFIG_AMLOGIC_SMARTCARD=y
CONFIG_RTC_LIB=y
CONFIG_RTC_CLASS=y
CONFIG_RTC_HCTOSYS=y
CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
CONFIG_RTC_SYSTOHC=y
CONFIG_RTC_SYSTOHC_DEVICE="rtc0"
# CONFIG_RTC_DEBUG is not set
# RTC interfaces
CONFIG_RTC_INTF_SYSFS=y
CONFIG_RTC_INTF_PROC=y
CONFIG_RTC_INTF_DEV=y
# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
# CONFIG_RTC_DRV_TEST is not set
# I2C RTC drivers
# CONFIG_RTC_DRV_ABB5ZES3 is not set
# CONFIG_RTC_DRV_ABX80X is not set
# CONFIG_RTC_DRV_DS1307 is not set
# CONFIG_RTC_DRV_DS1374 is not set
# CONFIG_RTC_DRV_DS1672 is not set
# CONFIG_RTC_DRV_HYM8563 is not set
# CONFIG_RTC_DRV_MAX6900 is not set
# CONFIG_RTC_DRV_RS5C372 is not set
# CONFIG_RTC_DRV_ISL1208 is not set
# CONFIG_RTC_DRV_ISL12022 is not set
# CONFIG_RTC_DRV_X1205 is not set
# CONFIG_RTC_DRV_PCF8523 is not set
# CONFIG_RTC_DRV_PCF85063 is not set
CONFIG_RTC_DRV_PCF8563=m
# CONFIG_RTC_DRV_PCF8583 is not set
# CONFIG_RTC_DRV_M41T80 is not set
# CONFIG_RTC_DRV_BQ32K is not set
# CONFIG_RTC_DRV_S35390A is not set
# CONFIG_RTC_DRV_FM3130 is not set
# CONFIG_RTC_DRV_RX8010 is not set
# CONFIG_RTC_DRV_RX8581 is not set
# CONFIG_RTC_DRV_RX8025 is not set
# CONFIG_RTC_DRV_EM3027 is not set
# CONFIG_RTC_DRV_RV8803 is not set
# SPI RTC drivers
# CONFIG_RTC_DRV_M41T93 is not set
# CONFIG_RTC_DRV_M41T94 is not set
# CONFIG_RTC_DRV_DS1302 is not set
# CONFIG_RTC_DRV_DS1305 is not set
# CONFIG_RTC_DRV_DS1343 is not set
# CONFIG_RTC_DRV_DS1347 is not set
# CONFIG_RTC_DRV_DS1390 is not set
# CONFIG_RTC_DRV_MAX6916 is not set
# CONFIG_RTC_DRV_R9701 is not set
# CONFIG_RTC_DRV_RX4581 is not set
# CONFIG_RTC_DRV_RX6110 is not set
# CONFIG_RTC_DRV_RS5C348 is not set
# CONFIG_RTC_DRV_MAX6902 is not set
# CONFIG_RTC_DRV_PCF2123 is not set
# CONFIG_RTC_DRV_MCP795 is not set
CONFIG_RTC_I2C_AND_SPI=y
# SPI and I2C RTC drivers
# CONFIG_RTC_DRV_DS3232 is not set
# CONFIG_RTC_DRV_PCF2127 is not set
# CONFIG_RTC_DRV_RV3029C2 is not set
# Platform RTC drivers
# CONFIG_RTC_DRV_DS1286 is not set
# CONFIG_RTC_DRV_DS1511 is not set
# CONFIG_RTC_DRV_DS1553 is not set
# CONFIG_RTC_DRV_DS1685_FAMILY is not set
# CONFIG_RTC_DRV_DS1742 is not set
# CONFIG_RTC_DRV_DS2404 is not set
# CONFIG_RTC_DRV_EFI is not set
# CONFIG_RTC_DRV_STK17TA8 is not set
# CONFIG_RTC_DRV_M48T86 is not set
# CONFIG_RTC_DRV_M48T35 is not set
# CONFIG_RTC_DRV_M48T59 is not set
# CONFIG_RTC_DRV_MSM6242 is not set
# CONFIG_RTC_DRV_BQ4802 is not set
# CONFIG_RTC_DRV_RP5C01 is not set
# CONFIG_RTC_DRV_V3020 is not set
# CONFIG_RTC_DRV_ZYNQMP is not set
# on-CPU RTC drivers
# CONFIG_RTC_DRV_PL030 is not set
# CONFIG_RTC_DRV_PL031 is not set
# CONFIG_RTC_DRV_SNVS is not set
# HID Sensor RTC drivers
# CONFIG_RTC_DRV_HID_SENSOR_TIME is not set
roro@n2:~$ sudo -i
[sudo] password for roro: 
root@n2:~# zcat /proc/config.gz | grep RTC 
CONFIG_AMLOGIC_VRTC=y
CONFIG_AMLOGIC_SMARTCARD=y
CONFIG_RTC_LIB=y
CONFIG_RTC_CLASS=y
CONFIG_RTC_HCTOSYS=y
CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
CONFIG_RTC_SYSTOHC=y
CONFIG_RTC_SYSTOHC_DEVICE="rtc0"
# CONFIG_RTC_DEBUG is not set
# RTC interfaces
CONFIG_RTC_INTF_SYSFS=y
CONFIG_RTC_INTF_PROC=y
CONFIG_RTC_INTF_DEV=y
# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
# CONFIG_RTC_DRV_TEST is not set
# I2C RTC drivers
# CONFIG_RTC_DRV_ABB5ZES3 is not set
# CONFIG_RTC_DRV_ABX80X is not set
# CONFIG_RTC_DRV_DS1307 is not set
# CONFIG_RTC_DRV_DS1374 is not set
# CONFIG_RTC_DRV_DS1672 is not set
# CONFIG_RTC_DRV_HYM8563 is not set
# CONFIG_RTC_DRV_MAX6900 is not set
# CONFIG_RTC_DRV_RS5C372 is not set
# CONFIG_RTC_DRV_ISL1208 is not set
# CONFIG_RTC_DRV_ISL12022 is not set
# CONFIG_RTC_DRV_X1205 is not set
# CONFIG_RTC_DRV_PCF8523 is not set
# CONFIG_RTC_DRV_PCF85063 is not set
CONFIG_RTC_DRV_PCF8563=m
# CONFIG_RTC_DRV_PCF8583 is not set
# CONFIG_RTC_DRV_M41T80 is not set
# CONFIG_RTC_DRV_BQ32K is not set
# CONFIG_RTC_DRV_S35390A is not set
# CONFIG_RTC_DRV_FM3130 is not set
# CONFIG_RTC_DRV_RX8010 is not set
# CONFIG_RTC_DRV_RX8581 is not set
# CONFIG_RTC_DRV_RX8025 is not set
# CONFIG_RTC_DRV_EM3027 is not set
# CONFIG_RTC_DRV_RV8803 is not set
# SPI RTC drivers
# CONFIG_RTC_DRV_M41T93 is not set
# CONFIG_RTC_DRV_M41T94 is not set
# CONFIG_RTC_DRV_DS1302 is not set
# CONFIG_RTC_DRV_DS1305 is not set
# CONFIG_RTC_DRV_DS1343 is not set
# CONFIG_RTC_DRV_DS1347 is not set
# CONFIG_RTC_DRV_DS1390 is not set
# CONFIG_RTC_DRV_MAX6916 is not set
# CONFIG_RTC_DRV_R9701 is not set
# CONFIG_RTC_DRV_RX4581 is not set
# CONFIG_RTC_DRV_RX6110 is not set
# CONFIG_RTC_DRV_RS5C348 is not set
# CONFIG_RTC_DRV_MAX6902 is not set
# CONFIG_RTC_DRV_PCF2123 is not set
# CONFIG_RTC_DRV_MCP795 is not set
CONFIG_RTC_I2C_AND_SPI=y
# SPI and I2C RTC drivers
# CONFIG_RTC_DRV_DS3232 is not set
# CONFIG_RTC_DRV_PCF2127 is not set
# CONFIG_RTC_DRV_RV3029C2 is not set
# Platform RTC drivers
# CONFIG_RTC_DRV_DS1286 is not set
# CONFIG_RTC_DRV_DS1511 is not set
# CONFIG_RTC_DRV_DS1553 is not set
# CONFIG_RTC_DRV_DS1685_FAMILY is not set
# CONFIG_RTC_DRV_DS1742 is not set
# CONFIG_RTC_DRV_DS2404 is not set
# CONFIG_RTC_DRV_EFI is not set
# CONFIG_RTC_DRV_STK17TA8 is not set
# CONFIG_RTC_DRV_M48T86 is not set
# CONFIG_RTC_DRV_M48T35 is not set
# CONFIG_RTC_DRV_M48T59 is not set
# CONFIG_RTC_DRV_MSM6242 is not set
# CONFIG_RTC_DRV_BQ4802 is not set
# CONFIG_RTC_DRV_RP5C01 is not set
# CONFIG_RTC_DRV_V3020 is not set
# CONFIG_RTC_DRV_ZYNQMP is not set
# on-CPU RTC drivers
# CONFIG_RTC_DRV_PL030 is not set
# CONFIG_RTC_DRV_PL031 is not set
# CONFIG_RTC_DRV_SNVS is not set
# HID Sensor RTC drivers
# CONFIG_RTC_DRV_HID_SENSOR_TIME is not set

User avatar
rooted
Posts: 6588
Joined: Fri Dec 19, 2014 9:12 am
languages_spoken: english
Location: Gulf of Mexico, US
Has thanked: 88 times
Been thanked: 17 times
Contact:

Re: RTC battery installed but RTC doesn't keep time across power cycle

Unread post by rooted » Sun Jul 14, 2019 2:34 pm

It's all configured correctly in the kernel, I was hoping someone made a mistake and compiled it as a module which would explain this behavior.

I will dig up a battery and attach it to the N2 and see if it behaves the same way.

rpineau
Posts: 25
Joined: Sun Sep 30, 2018 12:19 pm
languages_spoken: english
ODROIDs: XU4
Has thanked: 0
Been thanked: 1 time
Contact:

Re: RTC battery installed but RTC doesn't keep time across power cycle

Unread post by rpineau » Mon Jul 15, 2019 12:52 am

It is compiled as a module :

Code: Select all

root@n2:~# lsmod | grep rtc
rtc_pcf8563            20480  0
and so is the SPI :

Code: Select all

root@n2:~# lsmod | grep spi
spidev                 20480  0
spi_meson_spicc        20480  0
But as shown above ( viewtopic.php?f=180&t=35465#p262134 )If I totally disable systemd timesync and NTP and reboot the RTC keep its time. As soon as I start NTP the RTC get reset.
Here is my NTP config :

Code: Select all

# /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help

disable monitor

# GPS Serial data reference
server 127.127.28.0 minpoll 4 maxpoll 4 true prefer
fudge 127.127.28.0 time1 0.0 refid GPS

restrict default kod notrap nomodify nopeer noquery
restrict 127.0.0.1
restrict ::1

driftfile /var/lib/ntp/ntp.drift

# Leap seconds definition provided by tzdata
leapfile /usr/share/zoneinfo/leap-seconds.list
The GPS works fine with NTP and will update the RTC (hwclock) every 11 minutes as expected.

Rodolphe

nikodemus
Posts: 25
Joined: Fri Mar 08, 2019 2:15 pm
languages_spoken: german, english
ODROIDs: C1, C2, XU4, N2
Has thanked: 3 times
Been thanked: 1 time
Contact:

Re: RTC battery installed but RTC doesn't keep time across power cycle

Unread post by nikodemus » Mon Jul 15, 2019 10:12 am

The only reason i can imgine is that the low voltage detection bit was set:

address reserved for the PCF8563: A2h (10100010)
static VL_SEC_REG = 0x02; // bit 7

>> 8.4.1.1 Voltage-low detector and clock monitor
>> The PCF8563 has an on-chip voltage-low detector (see Figure 6). When VDD drops below
>> Vlow, bit VL in the VL_seconds register is set to indicate that the integrity of the clock
>> information is no longer guaranteed. The VL flag can only be cleared by using the interface

link to manual: https://www.nxp.com/docs/en/data-sheet/PCF8563.pdf

rpineau
Posts: 25
Joined: Sun Sep 30, 2018 12:19 pm
languages_spoken: english
ODROIDs: XU4
Has thanked: 0
Been thanked: 1 time
Contact:

Re: RTC battery installed but RTC doesn't keep time across power cycle

Unread post by rpineau » Mon Jul 15, 2019 10:49 am

but this happens only when NTP starts. So unless NTP use so much power on starts that the overall motherboard 3.3v drop so low as to reset the RTC but nothing else ( ... joking .. ), this sounds more like a software issue than hardware issue (clock fine before starting NTP, keep the time after reboot, start NTP, date reset to 2018-01-28 07:59:xx), NTP is sync'd to GPS on ttyS2, NTP re-sync the RTC after 11 minutes as expected (normal kernel behavior).

rpineau
Posts: 25
Joined: Sun Sep 30, 2018 12:19 pm
languages_spoken: english
ODROIDs: XU4
Has thanked: 0
Been thanked: 1 time
Contact:

Re: RTC battery installed but RTC doesn't keep time across power cycle

Unread post by rpineau » Mon Jul 15, 2019 11:58 am

So ..
Rebooted the N2, ssh into it before ntp had time to sync ...

Code: Select all

root@n2:~# date
Sun Jan 28 07:58:35 PST 2018
root@n2:~#  hwclock
2018-01-28 07:58:51.149427-0800
So the "bad" date is the default N2 system time/date before any time setup is done ... so NTP write this to the RTC before it has time to sync.
At least that's what I see.

rpineau
Posts: 25
Joined: Sun Sep 30, 2018 12:19 pm
languages_spoken: english
ODROIDs: XU4
Has thanked: 0
Been thanked: 1 time
Contact:

Re: RTC battery installed but RTC doesn't keep time across power cycle

Unread post by rpineau » Mon Jul 15, 2019 12:07 pm

I just found this post that confirms my suspicions :
viewtopic.php?t=21765#p238904

So .. NTP trashes the RTC on starts ....

nikodemus
Posts: 25
Joined: Fri Mar 08, 2019 2:15 pm
languages_spoken: german, english
ODROIDs: C1, C2, XU4, N2
Has thanked: 3 times
Been thanked: 1 time
Contact:

Re: RTC battery installed but RTC doesn't keep time across power cycle

Unread post by nikodemus » Mon Jul 15, 2019 11:19 pm

There is a simple way to check, if the issue is ntp related. Just reboot but do not powerdown. Then verify if start of ntp resets the time stored in RTC.

rpineau
Posts: 25
Joined: Sun Sep 30, 2018 12:19 pm
languages_spoken: english
ODROIDs: XU4
Has thanked: 0
Been thanked: 1 time
Contact:

Re: RTC battery installed but RTC doesn't keep time across power cycle

Unread post by rpineau » Tue Jul 16, 2019 4:04 am

I've done that as explained a few post above.. and it is NTP ..

nikodemus
Posts: 25
Joined: Fri Mar 08, 2019 2:15 pm
languages_spoken: german, english
ODROIDs: C1, C2, XU4, N2
Has thanked: 3 times
Been thanked: 1 time
Contact:

Re: RTC battery installed but RTC doesn't keep time across power cycle

Unread post by nikodemus » Tue Jul 16, 2019 5:09 am

You are right and i have read the post.
It fortunately offers a suitable workaround that will help with N2 too.

But the post does not bring an explanation for the strange behavior of ntp.
So i wanted to dig still somewhat deeper.

Edit:
As it turns out the VL Bit is not involved, as my test shows after powerdown (without battery)
(tested on ubuntu 18.04, keep in mind that ubuntu uses timesyncd rather than ntpd)
root@odroidN2:~# hwclock -r
hwclock: ioctl(RTC_RD_TIME) to /dev/rtc0 to read the time failed: Invalid argument
root@odroidN2:~# i2cget -f -y 3 0x51 2
0x96
Last edited by nikodemus on Wed Jul 17, 2019 12:50 pm, edited 2 times in total.

rpineau
Posts: 25
Joined: Sun Sep 30, 2018 12:19 pm
languages_spoken: english
ODROIDs: XU4
Has thanked: 0
Been thanked: 1 time
Contact:

Re: RTC battery installed but RTC doesn't keep time across power cycle

Unread post by rpineau » Tue Jul 16, 2019 7:23 am

I "fixed" my issue by disabling the systemd ntp service and adding a hxclock -s followed by /etc/init.d/ntp start in /etc/rc.local (similar to what the other post suggest).
As for the NTP behavior, we probably need to go ding into the NTP code to see why it's doing this.
In any case, thanks to all of you for helping on this. At least now we know it's not a hardware issue.
These users thanked the author rpineau for the post:
nikodemus (Tue Jul 16, 2019 10:26 am)

User avatar
odroid
Site Admin
Posts: 31852
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 89 times
Been thanked: 255 times
Contact:

Re: RTC battery installed but RTC doesn't keep time across power cycle

Unread post by odroid » Tue Jul 16, 2019 3:41 pm

Thank you for sharing the workaround against the weird NTP behavior in Ubuntu.
We've added your experience to our wiki page for other users.
https://wiki.odroid.com/odroid-n2/appli ... e_protocol
These users thanked the author odroid for the post:
nikodemus (Wed Jul 17, 2019 3:41 am)

User avatar
mad_ady
Posts: 6390
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Has thanked: 146 times
Been thanked: 109 times
Contact:

Re: RTC battery installed but RTC doesn't keep time across power cycle

Unread post by mad_ady » Tue Jul 16, 2019 3:59 pm

You could to the following for a more clean solution:
1. copy the ntp systemd service from /usr/lib/... to /etc/systemd/system/ntp.service
2. Edit it and add an ExecPre= statement that calls the command you need (prefix it with a "-" if you don't want the service to fail should the command return non-zero (e.g. when you don't have a rtc)
3. Run systemctl daemon-reload

Post Reply

Return to “Hardware and peripherals”

Who is online

Users browsing this forum: No registered users and 0 guests