android alarm driver

1,643 views
Skip to first unread message

extrapedestrian

unread,
Sep 8, 2011, 11:48:35 AM9/8/11
to android-porting
Im porting Froyo to mips board, and I have trouble building alarm
driver.
I added source to kernel, it builds and I have driver log, but I don't
have device.
device node is not created: /dev/alarm
I also don't have /dev/rtc and I think this might be causing problem.
When does 'rtc_alarm_add_device' gets to be called?

thanks,
Petar

Liu Xin

unread,
Sep 9, 2011, 1:03:38 AM9/9/11
to extra.pe...@gmail.com, android-porting
/dev/alarm is necessary. It comes from a kernel patch called "android alarm". you have to patch it to regular kernel on your own.
Without it, AlarmManagerService will have trouble to setup alarm.

RTC is rarely referred directly in android. however, SystemServer will read current time using gettiemofday.  our kernel gives the value from RTC intial value. if it is 0, or (other uninitialized value), it's possible to crash AlarmManagerService later.

thanks,
--lx





extrapedestrian

unread,
Sep 9, 2011, 3:41:50 AM9/9/11
to android-porting
I found alarm is platform driver that needs rtc device. Our board
doesn't have rtc device and that is why I don't get node created.
Anyone has linux patch with fake rtc device?

best regards,
Petar Bajic

On Sep 9, 7:03 am, Liu Xin <navy.x...@gmail.com> wrote:
> /dev/alarm is necessary. It comes from a kernel patch called "android
> alarm". you have to patch it to regular kernel on your own.
> Without it, AlarmManagerService will have trouble to setup alarm.
>
> RTC is rarely referred directly in android. however, SystemServer will read
> current time using gettiemofday.  our kernel gives the value from RTC intial
> value. if it is 0, or (other uninitialized value), it's possible to crash
> AlarmManagerService later.
>
> thanks,
> --lx
>
> On Thu, Sep 8, 2011 at 11:48 PM, extrapedestrian <extra.pedestr...@gmail.com

Xin Liu

unread,
Sep 9, 2011, 10:30:11 AM9/9/11
to extra.pe...@gmail.com, android-porting
I don't think so . Android alarm doesn't assume that your CPUs have RTC.  we use timer to do the same job.

--lx

extrapedestrian

unread,
Sep 12, 2011, 9:24:27 AM9/12/11
to android-porting
do you have /dev/rtc on your platform?

Liu Xin

unread,
Sep 13, 2011, 7:47:52 AM9/13/11
to extra.pe...@gmail.com, android-porting
no. we have /dev/rtc0
# ls -l /dev/rtc*
crw------- root     root     254,   0 2011-09-13 19:32 rtc0

again, android doesn't use rtc directly. it sets current time by syscall gettimeofday and /dev/alarm

refer to  java API JNI:
dalvik/vm/native/java_lang_System.c

or android API JNI:
frameworks/base/core/jni/android_os_SystemClock.cpp
which calls SystemClock.cpp & Timers.cpp


thanks
--lx

extrapedestrian

unread,
Sep 13, 2011, 9:19:01 AM9/13/11
to android-porting
im not saying android uses rtc.
im saying /dev/alarm needs rtc device. like I said in first post, i
added kernel patch alarm.c and alarm.h, driver is registered on kernel
boot, but I don't get /dev/alarm and /dev/rtc* device nodes. Do you
know why /dev/alarm is not created?

best regards,
Petar Bajic



On Sep 13, 1:47 pm, Liu Xin <navy.x...@gmail.com> wrote:
> no. we have /dev/rtc0
> # ls -l /dev/rtc*
> crw------- root     root     254,   0 2011-09-13 19:32 rtc0
>
> again, android doesn't use rtc directly. it sets current time by syscall
> gettimeofday and /dev/alarm
>
> refer to  java API JNI:
> dalvik/vm/native/java_lang_System.c
>
> or android API JNI:
> frameworks/base/core/jni/android_os_SystemClock.cpp
> which calls SystemClock.cpp & Timers.cpp
>
> thanks
> --lx
> On Mon, Sep 12, 2011 at 9:24 PM, extrapedestrian <extra.pedestr...@gmail.com

Liu Xin

unread,
Sep 13, 2011, 11:21:32 PM9/13/11
to extra.pe...@gmail.com, android-porting
oh, you need to switch on in config file to enable android alarm. Did you do that in .config?
CONFIG_RTC_INTF_ALARM=y   

kernel/driver/rtc/Makefile
rtc-core-$(CONFIG_RTC_INTF_ALARM) += alarm.o  

--lx

extrapedestrian

unread,
Sep 14, 2011, 4:31:26 AM9/14/11
to android-porting
Yes, I have slightly different:

CONFIG_ANDROID_POWER_ALARM=y

In kernel\drivers\staging\android\Makefile
obj-$(CONFIG_ANDROID_POWER_ALARM) += alarm.o

and in Kconfig

config ANDROID_POWER
bool "Android power driver"
depends on PM && RTC_CLASS
default n

config ANDROID_POWER_ALARM
bool "Android alarm driver"
depends on ANDROID_POWER
default y

And alarm.o driver is built, and registered on kernel boot.


On Sep 14, 5:21 am, Liu Xin <navy.x...@gmail.com> wrote:
> oh, you need to switch on in config file to enable android alarm. Did you do
> that in .config?
> CONFIG_RTC_INTF_ALARM=y
>
> kernel/driver/rtc/Makefile
> rtc-core-$(CONFIG_RTC_INTF_ALARM) += alarm.o
>
> --lx
>
> On Tue, Sep 13, 2011 at 9:19 PM, extrapedestrian <extra.pedestr...@gmail.com

extrapedestrian

unread,
Sep 22, 2011, 9:46:46 AM9/22/11
to android-porting
I found that I was missing some rtc related kernel configs:
CONFIG_RTC_HCTOSYS=y
CONFIG_RTC_HCTOSYS_DEVICE="rtc"
CONFIG_RTC_INTF_SYSFS=y
CONFIG_RTC_INTF_PROC=y
CONFIG_RTC_INTF_DEV=y
after adding these, I got both rtc and alarm devices.

I have another problem now... I can't find where network time is being
set?
I found that SntpClient "requestTime" is called only from
ThrottleService and GpsLocationProvider. These two modules get the
current time from Internet. "SystemClock.setCurrentTimeMillis" is only
called from GsmServiceStateTracker and AlarmManagerService but I can't
find how these functions get called after getting time from the net.


On Sep 14, 10:31 am, extrapedestrian <extra.pedestr...@gmail.com>
wrote:
> Yes, I have slightly different:
>
> CONFIG_ANDROID_POWER_ALARM=y
>
> In kernel\drivers\staging\android\Makefile
> obj-$(CONFIG_ANDROID_POWER_ALARM) +=alarm.o
>
> and in Kconfig
>
> config ANDROID_POWER
>         bool "Android power driver"
>         depends on PM && RTC_CLASS
>         default n
>
> config ANDROID_POWER_ALARM
>         bool "Androidalarmdriver"
>         depends on ANDROID_POWER
>         default y
>
> Andalarm.o driver is built, and registered on kernel boot.
>
> On Sep 14, 5:21 am, Liu Xin <navy.x...@gmail.com> wrote:
>
>
>
>
>
>
>
> > oh, you need to switch on in config file to enable androidalarm. Did you do
> > that in .config?
> > CONFIG_RTC_INTF_ALARM=y
>
> > kernel/driver/rtc/Makefile
> > rtc-core-$(CONFIG_RTC_INTF_ALARM) +=alarm.o
>
> > --lx
>
> > On Tue, Sep 13, 2011 at 9:19 PM, extrapedestrian <extra.pedestr...@gmail.com
>
> > > wrote:
> > > im not saying android uses rtc.
> > > im saying /dev/alarmneeds rtc device. like I said in first post, i
> > > added kernel patchalarm.c andalarm.h, driver is registered on kernel
> > > boot, but I don't get /dev/alarmand /dev/rtc* device nodes. Do you
> > > know why /dev/alarmis not created?
>
> > > best regards,
> > > Petar Bajic
>
> > > On Sep 13, 1:47 pm, Liu Xin <navy.x...@gmail.com> wrote:
> > > > no. we have /dev/rtc0
> > > > # ls -l /dev/rtc*
> > > > crw------- root     root     254,   0 2011-09-13 19:32 rtc0
>
> > > > again, android doesn't use rtc directly. it sets current time by syscall
> > > > gettimeofday and /dev/alarm
>
> > > > refer to  java API JNI:
> > > > dalvik/vm/native/java_lang_System.c
>
> > > > or android API JNI:
> > > > frameworks/base/core/jni/android_os_SystemClock.cpp
> > > > which calls SystemClock.cpp & Timers.cpp
>
> > > > thanks
> > > > --lx
> > > > On Mon, Sep 12, 2011 at 9:24 PM, extrapedestrian <
> > > extra.pedestr...@gmail.com
>
> > > > > wrote:
> > > > > do you have /dev/rtc on your platform?
>
> > > > > On Sep 9, 4:30 pm, Xin Liu <navy.x...@gmail.com> wrote:
> > > > > > I don't think so . Androidalarmdoesn't assume that your CPUs have
> > > RTC.
> > > > >  we use timer to do the same job.
>
> > > > > > --lx
>
> > > > > > 在 2011-9-9,下午3:41, extrapedestrian 写道:
>
> > > > > > > I foundalarmis platform driver that needs rtc device. Our board
Reply all
Reply to author
Forward
0 new messages