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   

 

Hi,

 

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.

QuoteReplyEditDelete

 

 

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

0x000040fa

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

0x559a104a

QuoteReplyEditDelete

 

 

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.

QuoteReplyEditDelete

 

 

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

Robin Getz (UNITED STATES)

Message: 62801   

 

Sreedhar:

 

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

 

http://en.wikipedia.org/wiki/Epoch_(reference_date)#Notable_epoch_dates_in_computing

 

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:

 

http://www.gnu.org/software/libtool/manual/libc/Date-and-Time.html#Date-and-Time

 

http://www.opengroup.org/onlinepubs/009695399/basedefs/time.h.html

 

-Robin

Attachments

    Outcomes