# rtc wakealarm not working

## chris...

Hi,

I'm trying to get mythtv to wakeup my computer

I've read the tutorials but its not working

Any ideas?

----------

## eduardhc

 *chris... wrote:*   

> Hi,
> 
> I'm trying to get mythtv to wakeup my computer
> 
> I've read the tutorials but its not working
> ...

 

Hi, 

Make sure you are programming the RTC alarm with UTC time, indepedently from which mode your BIOS clock is in (local or UTC).

Other than that, disable the synchronization of "system" clock to "hardware" clock when powering down, as some BIOS resets RTC alarm in such a case. This can be done in /etc/conf.d/clock or /etc/conf.d/hwclock or somewhere like that...

If it works with it disabled, then (if you want to reenable it...) you'll need to modify /etc/init.d/hwclock scripts to save & restore RTC alarm before modifying hardware clock.

Regards

PS: I'm not at home right now, but lately if you want I'll post the scripts / configuration I'm using for it.

----------

## chris...

ive already edited the settings to stop the sync from system to hw clock

i'll check more

----------

## chris...

So i take it I have a dodgy bios.....  :Sad: 

----------

## eduardhc

Hi, 

    I don't know if this may help you, but here you have how I have my system configured:

In 'settings' table:

```

MythShutdownWakeupTimeFmt: time_t

MythShutdownNvRamCmd: sudo /usr/bin/mythsettime $time

SetWakeupTimeCommand: sudo /usr/bin/mythshutdown --setwakeup $time

ServerHaltCommand: sudo /usr/bin/mythshutdown --shutdown

preSDWUCheckCommand: sudo /usr/bin/mythshutdown --check

```

The '/usr/bin/mythsettime' script contains the following:

```

#!/bin/bash

# i.- convert date from local to UTC:

echo "  Local secs: $1" > /home/root/mythtv.time

LOCAL_DATE=`date -d @$1 +%F" "%T`

echo "  Local date: $LOCAL_DATE" >> /home/root/mythtv.time

UTC_SECS=`date -u --date "$LOCAL_DATE" +%s`

echo "    UTC secs: $UTC_SECS" >> /home/root/mythtv.time

UTC_DATE=`date -d @$UTC_SECS +%F" "%T`

echo "    UTC date: $UTC_DATE" >> /home/root/mythtv.time

# ii.- ok, store into RTC:

echo 0 > /sys/class/rtc/rtc0/wakealarm

echo $UTC_SECS > /sys/class/rtc/rtc0/wakealarm

```

As you can see, this setup involves using mythwelcome & mythshutdown auxiliary programs. Tthis means that my .xinitrc starts mythwelcome instead of mythfrontend directly, and shutting down & scheduling RTC is handled via mythshutdown instead of doing it directly from the backend.

I don't know you have configured your system, so it might be some differences for you.

I also have configured 'sudo' so it doesn't ask for password when these commands are invoked by the backend.

Regards, 

  Eduard

----------

## chris...

 *eduardhc wrote:*   

> 
> 
> ```
> # ii.- ok, store into RTC:
> 
> ...

 

this bit does not work when i do it manually to wake up in 5 mins

/proc/acpi/rtc shows that it should wakeup in 5 mins

shutdown, wait, nothing happens

should i make the rtc part modular?

----------

## eduardhc

 *chris... wrote:*   

>  *eduardhc wrote:*   
> 
> ```
> # ii.- ok, store into RTC:
> 
> ...

 

I really don't know. Maybe the RTC driver is buggy for your hardware, who knows...  :Sad: 

BTW, I don't have the /proc/acpi/rtc device, I don't know if this might be a difference.

Regards

----------

## chris...

Sorry i mean /proc/driver/rtc

```
fileserver ~ # cat /proc/driver/rtc

rtc_time        : 00:34:14

rtc_date        : 2009-03-26

alrm_time       : 00:36:14

alrm_date       : 2009-03-26

alarm_IRQ       : yes

alrm_pending    : no

24hr            : yes

periodic_IRQ    : no

update_IRQ      : no

HPET_emulated   : yes

DST_enable      : no

periodic_freq   : 1024

batt_status     : okay

```

Shouldn't alrm_pending be yes?

----------

## eduardhc

 *chris... wrote:*   

> Sorry i mean /proc/driver/rtc
> 
> ```
> fileserver ~ # cat /proc/driver/rtc
> 
> ...

 

I really don't know... I've just checked what means says and alrm_pending is also set to 'no' after programming the wakeup time.  Also alarm_irq is 'no' for my machine, but it still works...

Anyway, do you have the "automatic" daily wakeup enabled in your BIOS? For what I've read, some machines needs to have this disabled for this to work, even if it sound inconsistent...

regards

----------

## chris...

when daily wakeup was disabled it never woke up

when i did enable bios wakeup it did wakeup, but at the time that was entered in the bios, changing this time had no efffect

this means that at least it can wakeup via the rtc but so far doesnt seem to be programable

----------

## eduardhc

 *chris... wrote:*   

> when daily wakeup was disabled it never woke up
> 
> when i did enable bios wakeup it did wakeup, but at the time that was entered in the bios, changing this time had no efffect
> 
> this means that at least it can wakeup via the rtc but so far doesnt seem to be programable

 

That's strange. It seems that effectively it's capable of waking up automatically, then. Are you sure you are correctly specifying the wakeup time, by converting it to UTC, etc...?

Another possibility would be to get back to a previous kernel version and use ACPI alarm directly (by programming /proc/acpi/alarm device). This is even more obscure and machine-dependent, though, and you'll need to disable RTC driver from kernel first and then enable the deprecated ACPI devices / folders to show it up.

I was using it until 2.6.27 came up (forcing me to change to RTC), and it always worked fine me.

Regards, 

  Eduard

----------

