Odroid C2, Android OS - How to change RTC date and time

Moderators: mdrjr, odroid

Odroid C2, Android OS - How to change RTC date and time

Unread postby OdoroidAndroid26 » Wed Jun 20, 2018 7:52 pm

I have the PCF8563 RTC Shield on my odroid board, and I’m trying to change the date and time of the RTC.
I’ve tried using the Android terminal emulator, to do things such as “date -s” or just “date”, however it only changes the system time and date, not the RTC’s time and date.

Any idea how to do this?
OdoroidAndroid26
 
Posts: 5
Joined: Wed Jun 20, 2018 7:43 pm
languages_spoken: english
ODROIDs: Odroid C2

Re: Odroid C2, Android OS - How to change RTC date and time

Unread postby tobetter » Thu Jun 21, 2018 12:42 pm

OdoroidAndroid26 wrote:I have the PCF8563 RTC Shield on my odroid board, and I’m trying to change the date and time of the RTC.
I’ve tried using the Android terminal emulator, to do things such as “date -s” or just “date”, however it only changes the system time and date, not the RTC’s time and date.

Any idea how to do this?

Can you run this command in terminal and show me how it is?
Code: Select all
$ ls -l /dev/rtc*
tobetter
 
Posts: 2228
Joined: Mon Feb 25, 2013 10:55 am
Location: Paju, South Korea
languages_spoken: Korean, English
ODROIDs: X, X2, U2, U3, XU3, C1

Re: Odroid C2, Android OS - How to change RTC date and time

Unread postby OdoroidAndroid26 » Thu Jun 21, 2018 7:02 pm

tobetter wrote:
OdoroidAndroid26 wrote:I have the PCF8563 RTC Shield on my odroid board, and I’m trying to change the date and time of the RTC.
I’ve tried using the Android terminal emulator, to do things such as “date -s” or just “date”, however it only changes the system time and date, not the RTC’s time and date.

Any idea how to do this?

Can you run this command in terminal and show me how it is?
Code: Select all
$ ls -l /dev/rtc*


Of course, this is what was displayed:

Code: Select all
crw-r----- system    system    252,    0 2018-06-21 10:58 rtc0
OdoroidAndroid26
 
Posts: 5
Joined: Wed Jun 20, 2018 7:43 pm
languages_spoken: english
ODROIDs: Odroid C2

Re: Odroid C2, Android OS - How to change RTC date and time

Unread postby rooted » Fri Jun 22, 2018 7:10 am

Use:

sudo hwclock -w
User avatar
rooted
 
Posts: 5162
Joined: Fri Dec 19, 2014 9:12 am
Location: Gulf of Mexico, US
languages_spoken: english
ODROIDs: C1, C1+, C2
XU3 Lite, XU4
N1
VU7+
HiFi Shield 2
Smart Power (original)

Re: Odroid C2, Android OS - How to change RTC date and time

Unread postby OdoroidAndroid26 » Fri Jun 22, 2018 10:30 pm

rooted wrote:Use:

sudo hwclock -w



I presume you mean trying

Code: Select all
 su


and then

Code: Select all
 hwclock -w


Since I'm using the android terminal emulator,
however it get the following back:

hwclock: failed: No such file or directory
OdoroidAndroid26
 
Posts: 5
Joined: Wed Jun 20, 2018 7:43 pm
languages_spoken: english
ODROIDs: Odroid C2

Re: Odroid C2, Android OS - How to change RTC date and time

Unread postby rooted » Fri Jun 22, 2018 11:50 pm

Oh I somehow missed you were on Android, I'm not sure how it works here. Sorry about that.
User avatar
rooted
 
Posts: 5162
Joined: Fri Dec 19, 2014 9:12 am
Location: Gulf of Mexico, US
languages_spoken: english
ODROIDs: C1, C1+, C2
XU3 Lite, XU4
N1
VU7+
HiFi Shield 2
Smart Power (original)

Re: Odroid C2, Android OS - How to change RTC date and time

Unread postby tobetter » Sat Jun 23, 2018 11:10 am

If only /dev/rtc0 is there, it should work. Is your Android version is the latest one? Even the time is not set from Settings?
tobetter
 
Posts: 2228
Joined: Mon Feb 25, 2013 10:55 am
Location: Paju, South Korea
languages_spoken: Korean, English
ODROIDs: X, X2, U2, U3, XU3, C1

Re: Odroid C2, Android OS - How to change RTC date and time

Unread postby OdoroidAndroid26 » Mon Jun 25, 2018 8:04 pm

tobetter wrote:If only /dev/rtc0 is there, it should work. Is your Android version is the latest one? Even the time is not set from Settings?


/dev/rtc0 Is the only one there. And I have Android Marshmallow (v4.2) installed to the odroid c2 device.

Using the
Code: Select all
date
along with a string representing the date and time command, does change the system time.

i.e
Code: Select all
date 1111111111.11

outputs Fri Nov 11 11:11:11 GMT 2011,
and the command
Code: Select all
date

will return the newly set date.

However
Code: Select all
hwclock

will still return whatever the date and time previously was on the rtc. So when the device is powered off and back on, the system reverts to this date again.

The same applies if I change the time/date through settings.
OdoroidAndroid26
 
Posts: 5
Joined: Wed Jun 20, 2018 7:43 pm
languages_spoken: english
ODROIDs: Odroid C2

Re: Odroid C2, Android OS - How to change RTC date and time

Unread postby tobetter » Tue Jun 26, 2018 1:47 pm

Can you try if you can see these?
Code: Select all
root@odroidc2:/ # ls /sys/class/rtc/rtc0/ -l                                   
-r--r--r-- root     root         4096 2018-08-24 13:38 date
-r--r--r-- root     root         4096 2018-08-24 13:38 dev
lrwxrwxrwx root     root              2018-08-24 13:38 device -> ../../../1-0051
-r--r--r-- root     root         4096 2018-06-26 13:35 hctosys
-rw-r--r-- root     root         4096 2018-08-24 13:38 max_user_freq
-r--r--r-- root     root         4096 2018-08-24 13:38 name
drwxr-xr-x root     root              2018-06-26 13:35 power
-r--r--r-- root     root         4096 2018-08-24 13:38 since_epoch
lrwxrwxrwx root     root              2018-08-24 13:38 subsystem -> ../../../../../class/rtc
-r--r--r-- root     root         4096 2018-08-24 13:38 time
-rw-r--r-- root     root         4096 2018-06-26 13:35 uevent


Also, try to run # cat /sys/class/rtc/rtc0/date. If it shows errors like these, I2C is not working with RTC module or RTC module itself could have a problem.
Code: Select all
[   83.062566@0] i2c i2c-1: [aml_i2c_xfer] error ret = -5 (-EIO)
[   83.062674@0] i2c i2c-1: token 1, master_no(1) 300K addr 0x51
[   83.068465@0] i2c i2c-1: [aml_i2c_xfer] error ret = -5 (-EIO)
[   83.074121@0] i2c i2c-1: token 1, master_no(1) 300K addr 0x51
[   83.079840@0] i2c i2c-1: [aml_i2c_xfer] error ret = -5 (-EIO)
[   83.085482@0] i2c i2c-1: token 1, master_no(1) 300K addr 0x51
[   83.091151@0] rtc-pcf8563 1-0051: pcf8563_get_datetime: read erro


Maybe you could post a picture how you connected the RTC module.
tobetter
 
Posts: 2228
Joined: Mon Feb 25, 2013 10:55 am
Location: Paju, South Korea
languages_spoken: Korean, English
ODROIDs: X, X2, U2, U3, XU3, C1

Re: Odroid C2, Android OS - How to change RTC date and time

Unread postby OdoroidAndroid26 » Wed Jul 04, 2018 10:07 pm

tobetter wrote:Can you try if you can see these?
Code: Select all
root@odroidc2:/ # ls /sys/class/rtc/rtc0/ -l                                   
-r--r--r-- root     root         4096 2018-08-24 13:38 date
-r--r--r-- root     root         4096 2018-08-24 13:38 dev
lrwxrwxrwx root     root              2018-08-24 13:38 device -> ../../../1-0051
-r--r--r-- root     root         4096 2018-06-26 13:35 hctosys
-rw-r--r-- root     root         4096 2018-08-24 13:38 max_user_freq
-r--r--r-- root     root         4096 2018-08-24 13:38 name
drwxr-xr-x root     root              2018-06-26 13:35 power
-r--r--r-- root     root         4096 2018-08-24 13:38 since_epoch
lrwxrwxrwx root     root              2018-08-24 13:38 subsystem -> ../../../../../class/rtc
-r--r--r-- root     root         4096 2018-08-24 13:38 time
-rw-r--r-- root     root         4096 2018-06-26 13:35 uevent


Also, try to run # cat /sys/class/rtc/rtc0/date. If it shows errors like these, I2C is not working with RTC module or RTC module itself could have a problem.
Code: Select all
[   83.062566@0] i2c i2c-1: [aml_i2c_xfer] error ret = -5 (-EIO)
[   83.062674@0] i2c i2c-1: token 1, master_no(1) 300K addr 0x51
[   83.068465@0] i2c i2c-1: [aml_i2c_xfer] error ret = -5 (-EIO)
[   83.074121@0] i2c i2c-1: token 1, master_no(1) 300K addr 0x51
[   83.079840@0] i2c i2c-1: [aml_i2c_xfer] error ret = -5 (-EIO)
[   83.085482@0] i2c i2c-1: token 1, master_no(1) 300K addr 0x51
[   83.091151@0] rtc-pcf8563 1-0051: pcf8563_get_datetime: read erro


Maybe you could post a picture how you connected the RTC module.


The rtc module is connected the same way as in the image linked below:
https://www.hardkernel.com/main/_Files/ ... 375783.jpg

I got the same output as you when running the command
Code: Select all
ls /sys/class/rtc/rtc0/ -l


And running
Code: Select all
cat /sys/class/rtc/rtc0/date
returned no errors, it simply returned the rtcs set date.
OdoroidAndroid26
 
Posts: 5
Joined: Wed Jun 20, 2018 7:43 pm
languages_spoken: english
ODROIDs: Odroid C2

Re: Odroid C2, Android OS - How to change RTC date and time

Unread postby tobetter » Wed Jul 04, 2018 11:52 pm

If that's the case, ODROID-C2 can talk with RTC shield, but RTC is not ticking??
Did you see time changes whenever you run hwclock?
Can you run the command hwclock -f /dev/rtc0 if it is still same?
Could you try to run Ubuntu for ODROID-C2 and do the same using hwclock in order to check RTC Shield is ok or not?
tobetter
 
Posts: 2228
Joined: Mon Feb 25, 2013 10:55 am
Location: Paju, South Korea
languages_spoken: Korean, English
ODROIDs: X, X2, U2, U3, XU3, C1


Return to Android

Who is online

Users browsing this forum: No registered users and 1 guest