Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,769,622 Members 44,770 Now Online
XDA Developers Android and Mobile Development Forum

[Q] Hardware rtc (clock) incorrect

Tip us?
 
alvinhochun
Old
(Last edited by alvinhochun; 14th October 2013 at 05:16 PM.)
#1  
alvinhochun's Avatar
Senior Member - OP
Thanks Meter 178
Posts: 160
Join Date: Oct 2010
Default [Q] Hardware rtc (clock) incorrect

There's something fishy happening on my Xperia M (C1905).

Basically, the current time fails to be written to the hardware rtc, so the device is only counting on the time sync through network at boot.
Also, because the hardware rtc is out of sync, alarms won't fire up when the device is powered off.

Part of the kernel messages:

Code:
$ adb shell su -c dmesg | less
...
[    1.510056] using rtc device, pm8xxx_rtc, for alarms
[    1.510117] rtc-pm8xxx rtc-pm8xxx: rtc core: registered pm8xxx_rtc as rtc0
...
[    1.925286] rtc-pm8xxx rtc-pm8xxx: setting system clock to 1970-01-26 00:2
7:36 UTC (2161656)
...
[    8.209980] alarm_set_rtc: Failed to set RTC, time will be lost on reboot
...
[   32.398962] alarm_set_rtc: Failed to set RTC, time will be lost on reboot
...
Execution of some commands in the shell:

Code:
root@android:/ # date
Sat Oct 12 21:54:53 HKT 2013
root@android:/ # hwclock
Mon Jan 26 00:53:36 1970  0.000000 seconds
root@android:/ # hwclock -w
hwclock: RTC_SET_TIME: Invalid argument
1|root@android:/ #
There is only one rtc device under /dev, which is /dev/rtc0.

This problem really bothers me. Not only I will need to keep device on to get alarms firing, but also the operations done in CWM will have wrong timestamps.

I would like to know if anyone else having an Xperia M/M Dual have the same problem. Check by doing what I did, or set an alarm, power off and see if the alarm fires.
Current device: Xperia M (C1905) - MultiROM Xperia M

Past devices: Xperia Neo V, iPAQ 212
The Following User Says Thank You to alvinhochun For This Useful Post: [ Click to Expand ]
 
alvinhochun
Old
#2  
alvinhochun's Avatar
Senior Member - OP
Thanks Meter 178
Posts: 160
Join Date: Oct 2010
More insight:

The hardware rtc is at about 26 days after Unix epoch. My guess is that if the rtc actually resets, it will start at the Unix epoch, so that indicates that last reset of rtc is about 26 days ago.

Now the problem is that I don't remember the exact date I get the phone. After I got the phone, I actually did a few factory resets. If I know if the rtc starts before or after I get the phone, it will help to determine if this problem exists already when manufactured. But 26 days ago is pretty close to when I got the phone.

Sent from my Sony Xperia M (C1905)
Current device: Xperia M (C1905) - MultiROM Xperia M

Past devices: Xperia Neo V, iPAQ 212
 
icoolguy1995
Old
#3  
icoolguy1995's Avatar
Recognized Contributor
Thanks Meter 1206
Posts: 1,811
Join Date: Jun 2012
Location: HARDA

 
DONATE TO ME
Quote:
Originally Posted by alvinwong_1234 View Post
More insight:

The hardware rtc is at about 26 days after Unix epoch. My guess is that if the rtc actually resets, it will start at the Unix epoch, so that indicates that last reset of rtc is about 26 days ago.

Now the problem is that I don't remember the exact date I get the phone. After I got the phone, I actually did a few factory resets. If I know if the rtc starts before or after I get the phone, it will help to determine if this problem exists already when manufactured. But 26 days ago is pretty close to when I got the phone.

Sent from my Sony Xperia M (C1905)
Hmm thats interesting. I think problem will be solved after flashing 4.2.2 its a guess but it might work.

Sent from my C1904 using XDA Premium 4 mobile app
Devices which I supports
╬ Sony xperia M ╬ Sony xperia E ╬

My Works
Code:
Error not found
If you like my work consider a donation, or else hit the thanks button.

 
alvinhochun
Old
#4  
alvinhochun's Avatar
Senior Member - OP
Thanks Meter 178
Posts: 160
Join Date: Oct 2010
OK, I found the cause of the problem.

It appears that Sony intentionally or unintentionally didn't enable the function to write to the hardware rtc. (See kernel source: https://github.com/alvinhochun/sony-...30-pmic.c#L297)

What I need to do is to change `rtc_write_enable` to `true` and compile the kernel. After that the hardware rtc can finally be updated.



For the alarm, I thought the reason is similar, but even when I set `rtc_alarm_powerup` to `true` it didn't power on with alarm set. Perhaps this is a feature missing from Android, so never mind.
Current device: Xperia M (C1905) - MultiROM Xperia M

Past devices: Xperia Neo V, iPAQ 212
 
Mr. Hostel
Old
#5  
Junior Member
Thanks Meter 0
Posts: 1
Join Date: May 2011
Quote:
Originally Posted by alvinhochun View Post
OK, I found the cause of the problem.

It appears that Sony intentionally or unintentionally didn't enable the function to write to the hardware rtc.

What I need to do is to change `rtc_write_enable` to `true` and compile the kernel. After that the hardware rtc can finally be updated.



For the alarm, I thought the reason is similar, but even when I set `rtc_alarm_powerup` to `true` it didn't power on with alarm set. Perhaps this is a feature missing from Android, so never mind.
i've got the same problem with my xperia s. can you tell me how to change rtc_write_enable in kernel?
 
sasaengineeringworks
Old
#6  
Junior Member
Thanks Meter 5
Posts: 10
Join Date: Nov 2013
Dear,
You cant update your rtc unless u find way modify your bootloader which is ta because after unlocking bootloader load address offsets to some place else if you have ta backup you can check date of grub rck_h in hex editor but don't try to change it manually as it is associated with cert installed of locked bootloader if you have ASOP in external grub folder you have option for set date but you should have unlocked bootloader or else you should be able to inverse the effect of bootloader unlock from adb which will return it to factory state or final option you should have command line for factory image building with every parameter in it.
I am also quest for it?
please urge other members for cmdline from /proc if there ta is intact.
so we may figure out how to make factory image from asop.

please let me know if you find anything
Tags
xperia m
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


BrightNotes Makes Cloud Notes Simple and Easy

There are literally thousands of note taking apps available on Android, with practically every … more

Google Glass XE20.1 Update Brings Improved Contacts, Head Nudge, New Cards and Commands

Ever since Google unveiled Android Wear earlier this … more

Remote Control Your Android Device with Monitordroid

The Android OS showsgreat potential in many areas. One of most interesting things that … more

Intel Partners with Unity to Support Android on Intel-Based Devices

Intel, largely known for their long-standing reputation as the king of … more