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

Post Reply
OdoroidAndroid26
Posts: 5
Joined: Wed Jun 20, 2018 7:43 pm
languages_spoken: english
ODROIDs: Odroid C2
Contact:

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

Unread post by 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?

User avatar
tobetter
Posts: 2652
Joined: Mon Feb 25, 2013 10:55 am
languages_spoken: Korean, English
ODROIDs: X, X2, U2, U3, XU3, C1
Location: Paju, South Korea
Contact:

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

Unread post by 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*

OdoroidAndroid26
Posts: 5
Joined: Wed Jun 20, 2018 7:43 pm
languages_spoken: english
ODROIDs: Odroid C2
Contact:

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

Unread post by 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

User avatar
rooted
Posts: 6295
Joined: Fri Dec 19, 2014 9:12 am
languages_spoken: english
Location: Gulf of Mexico, US
Contact:

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

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

Use:

sudo hwclock -w

OdoroidAndroid26
Posts: 5
Joined: Wed Jun 20, 2018 7:43 pm
languages_spoken: english
ODROIDs: Odroid C2
Contact:

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

Unread post by 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

User avatar
rooted
Posts: 6295
Joined: Fri Dec 19, 2014 9:12 am
languages_spoken: english
Location: Gulf of Mexico, US
Contact:

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

Unread post by 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
tobetter
Posts: 2652
Joined: Mon Feb 25, 2013 10:55 am
languages_spoken: Korean, English
ODROIDs: X, X2, U2, U3, XU3, C1
Location: Paju, South Korea
Contact:

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

Unread post by 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?

OdoroidAndroid26
Posts: 5
Joined: Wed Jun 20, 2018 7:43 pm
languages_spoken: english
ODROIDs: Odroid C2
Contact:

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

Unread post by 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.

User avatar
tobetter
Posts: 2652
Joined: Mon Feb 25, 2013 10:55 am
languages_spoken: Korean, English
ODROIDs: X, X2, U2, U3, XU3, C1
Location: Paju, South Korea
Contact:

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

Unread post by 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.

OdoroidAndroid26
Posts: 5
Joined: Wed Jun 20, 2018 7:43 pm
languages_spoken: english
ODROIDs: Odroid C2
Contact:

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

Unread post by 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.

User avatar
tobetter
Posts: 2652
Joined: Mon Feb 25, 2013 10:55 am
languages_spoken: Korean, English
ODROIDs: X, X2, U2, U3, XU3, C1
Location: Paju, South Korea
Contact:

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

Unread post by 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?

Post Reply

Return to “Android”

Who is online

Users browsing this forum: Google [Bot] and 2 guests