2008-09-04 13:19:50     hwclock - RTC problem

Document created by Aaronwu Employee on Aug 7, 2013
Version 1Show Document
  • View in full screen mode

2008-09-04 13:19:50     hwclock - RTC problem

Appalayagari Sreedhar (INDIA)

Message: 61630   




I am working with uClinux distribution 2007 R1-RC3. Custom board with RTC clock mounted on the board frequency 32.768 kHz.


I am using the hwclock -w command to write the system time to RTC.


but when i checked the value of RTC_STAT register it is not the corresponding value for the date and time of what hwclock gives.


Why this behaviour?. What does the hwclock -w does? will it write into the RTC registers (RTC_STAT) of blackfin.


If so can anyone suggest me what i am doing wrong?.


Best Regards, Sreedhar.




2008-09-04 14:02:29     Re: hwclock - RTC problem

Mike Frysinger (UNITED STATES)

Message: 61635   


works fine for me in 2008R1.5


root:/sys/kernel/debug/blackfin/RTC> hwclock

Thu Jan  1 04:04:29 1970  0.000000 seconds

root:/sys/kernel/debug/blackfin/RTC> cat RTC_STAT


root:/sys/kernel/debug/blackfin/RTC> date

Thu Jan  1 04:03:58 UTC 1970


root:/sys/kernel/debug/blackfin/RTC> date -s 010101012000

Sat Jan  1 01:01:00 UTC 2000


root:/sys/kernel/debug/blackfin/RTC> hwclock -w

root:/sys/kernel/debug/blackfin/RTC> hwclock

Sat Jan  1 01:01:07 2000  0.000000 seconds

root:/sys/kernel/debug/blackfin/RTC> cat RTC_STAT





2008-09-26 10:47:00     Re: hwclock - RTC problem

Appalayagari Sreedhar (INDIA)

Message: 62798   


Hi Mike,


The RTC date and time programemd through hwclock -w option is from the epoch time.


The RTC_STAT values reflected are from the epoch time is my understanding correct?


Is there any way to obtain the RTC values from 2008 onwards instead of from epoch time.


Best Regards, Sreedhar.




2008-09-26 11:21:04     Re: hwclock - RTC problem


Message: 62801   




Everything on the system (applications, C library, kernel, etc) is measured since epoch (Jan 1, 1970)




That way - everything just works - if I want to find the time/date my system booted, I can do it from the command line with awk. (Works on a desktop too).


root:~> grep btime /proc/stat | awk ' { printf( "%s\n", strftime("%c", $2)) } '

Fri Sep 26 10:12:00 2008



If you want something else, just subtract the number of seconds between Jan 1, 1970 and whatever date you want - but you are better off using the C libraries' time functions for whatever you want. All the POSIX required ones work in uClibc: