Choosing Real time clock (RTC) to use in my android

3,227 views
Skip to first unread message

cha...@gmail.com

unread,
Jun 16, 2013, 5:21:50 PM6/16/13
to android...@googlegroups.com
Hi All,
I'm working on porting android (2.3.3) to some arm device and on that device I have two different Real Time Clocks (RTCs). First one comes from processor and the second comes from PMIC.
In my system I see them in the path /sys/class/rtc/rtc0 and /sys/class/rtc/rtc1.

On default Android system time is taken from the first RTC (rtc0). What is more, setting time and date in Android Settings changes exactly that clock.

I want to switch it to the second clock. I know how to do it from one direction - how to set system time from rtc1 (compile parameter for kernel), but I don't know how to change RTC standing behind Settings -> Change Date and Time option in user interface. In other words, I want to change time and date from user interface of second RTC (rtc1, not rtc0 as in default).

How can I do it?

Thanks for help.

chaqi 

Topher

unread,
Jun 19, 2013, 4:43:44 PM6/19/13
to android...@googlegroups.com
I'm not much of an expert here, but it looks like Android 2.3 is using /dev/alarm as its RTC interface. See system/core/toolbox/alarm.c and frameworks/base/libs/utils/SystemClock.cpp for example. Neither of these, however, define functions used to get the current date and time so it's not a great answer to your question. Android's AlarmManager uses the RTC to wake the device out of sleep at a given time.

gettimeofday() seems to be defined here: bionic/libc/arch-arm/syscalls/gettimeofday.S
But that *still* doesn't answer your question. Toolbox's "date" command uses a call to time() to get the local time, which must be the same thing Android uses. See system/core/toolbox/date.c. But I'm running out of luck tracking down the source code for that function call.

HTH to get you started.

 - Topher

Vishveshwar

unread,
Jun 20, 2013, 7:14:07 AM6/20/13
to android...@googlegroups.com

Is it not possible to disable the processor RTC in kernel config? That way the PMIC RTC becomes default.

-Vishveshwar

kavitha bk

unread,
Jun 20, 2013, 7:33:30 AM6/20/13
to vishves...@aim.com, android-porting
yes Disable the RTC of the chip in the defconfig then the PMIC RTC becomes the default rtc0
Or changing the order of the drivers in the Makefile should reverse
pmic rtc->rtc0
chip rtc ->rtc1

Usually hwclock opens you open the /dev/rtc0


Thanks,
Kavitha



--
--
unsubscribe: android-porti...@googlegroups.com
website: http://groups.google.com/group/android-porting
 
---
You received this message because you are subscribed to the Google Groups "android-porting" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-porti...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Hao Nguyen

unread,
Oct 27, 2014, 1:07:33 PM10/27/14
to android...@googlegroups.com, vishves...@aim.com
I have a questions here. How do I set hardware clock via command line? In linux, I use hwclock tools but it's not avaiable in Android. 
Can you show me a solutions for this? Set hardware clock and sync it to system clock in Android? Thanks for your reading???

Vào 18:33:30 UTC+7 Thứ năm, ngày 20 tháng sáu năm 2013, kavitha đã viết:
Reply all
Reply to author
Forward
0 new messages