Difference between revisions of "ACPI Wakeup"

From MythTV Official Wiki
Jump to: navigation, search
m (BIOS setup)
(copyediting)
(25 intermediate revisions by 13 users not shown)
Line 5: Line 5:
  
 
== Introduction ==
 
== Introduction ==
Most users tend to leave their mythTV system running 24 by 7. This page describes the options you have in Linux to shutdown and automatically wakeup your machine before a recording. Doing so allows you to save energy, money and reduce your carbon footprint.
+
Most users tend to leave their MythTV system running 24 by 7. This page describes the options you have in Linux to shut down and automatically wake up your machine before a recording. Doing so allows you to save energy, money and reduce your carbon footprint.
  
  
 
{{SUSE_head| Your options:}}
 
{{SUSE_head| Your options:}}
* Hardware time switch - a cheap power switch and a simple cronjob to shutdown the machine can do the job
+
* Hardware timer switch - a cheap power switch and a simple cron job to shutdown the machine can do the job
* Wake On LAN - have another machine on your network wake your mythTV machine. ([[Wake-on-LAN|See the "Wake on LAN" mythTV HowTo]])
+
* Wake on LAN - have another machine on your network wake your MythTV machine. ([[Wake-on-LAN|See the "Wake on LAN" MythTV HowTo]])
* Use the BIOS - most machines (built in 2000 or later) have the ability to use the BIOS for time-controlled wakeup - this option is the subject of this HowTo
+
* Use the real time clock (RTC) - most machines (manufactured in 2000 or later) have the ability to use the RTC for time-controlled wakeup - this option is the subject of this HowTo
  
  
{{SUSE_head| Use the BIOS:}}  
+
{{SUSE_head| Use the RTC:}}  
MythTV has the ability to write the date and time of the next recording to the BIOS. This allows your machine to automatically shutdown (or suspend) and turn on again a few minutes before it needs to record again. The Advanced Configuration and Power Interface (ACPI) specification is an open industry standard first released in December 1996 developed by HP, Intel, Microsoft, Phoenix, and Toshiba that defines common interfaces for hardware recognition, motherboard and device configuration and power management.  
+
MythTV has the ability to write the date and time of the next recording to the RTC. This allows your machine to automatically shutdown (or suspend) and turn on again a few minutes before it needs to record again. The Advanced Configuration and Power Interface (ACPI) specification is an open industry standard first released in December 1996 developed by HP, Intel, Microsoft, Phoenix, and Toshiba that defines common interfaces for hardware recognition, motherboard and device configuration and power management.  
  
The ACPI Real Time Clock (RTC) Alarm function can be used by your mythTV system to wake up your machine at a certain date and time.
+
The ACPI real time clock alarm function can be used by your MythTV system to wake up your machine at a certain date and time.
  
  
{{SUSE_head| Required steps for using the BIOS to access the ACPI RTC Alarm function:}}
+
{{SUSE_head| Required steps for using the RTC to access the ACPI alarm function:}}
# Configure your BIOS
+
# Configure your RTC with your BIOS setup
# Disable HWclock updates
+
# Disable hwclock updates
# Configure mythTV
+
# Configure MythTV
  
  
 
== BIOS setup ==
 
== BIOS setup ==
If you want to use ACPI to wake up your mythTV system, you first need to ensure that your BIOS supports this functionality.  This information is stored in the FADT (Fixed ACPI Description Table).  If your kernel version is 2.6.22 or later, you may find this information in your kernel log file:
+
If you want to use ACPI to wake up your MythTV system, you first need to ensure that your motherboard supports this functionality by looking at your BIOS setup.  This information is stored in the FADT (Fixed ACPI Description Table).  If your kernel version is 2.6.22 or later, you may find this information in your kernel log file:
  
 
  $ grep -i rtc /var/log/kern.log
 
  $ grep -i rtc /var/log/kern.log
Line 33: Line 33:
 
  ...
 
  ...
 
  rtc0: alarms up to one month
 
  rtc0: alarms up to one month
 +
 +
For Fedora 13 or Mandriva try (as root)
 +
 +
# grep -i rtc /var/log/messages
 +
  
 
The above indicates this system can wake from state S4 and that the wakeup time can be set.
 
The above indicates this system can wake from state S4 and that the wakeup time can be set.
  
The ACPI specifications defines the following so-called "global states" -- from [http://en.wikipedia.org/wiki/Advanced_Configuration_and_Power_Interface Wikipedia ACPI]
+
The ACPI specifications defines the following so-called "global states" -- from [[wikipedia:Advanced_Configuration_and_Power_Interface|Wikipedia ACPI]]
  
 
* '''G1''' ''Sleeping'' subdivides into the four states S1 through S4.
 
* '''G1''' ''Sleeping'' subdivides into the four states S1 through S4.
** '''S1''': The CPU(s) stop executing instructions.
+
** '''S1''': The CPU(s) stop(s) executing instructions.
 
** '''S2''': The CPU is powered off.
 
** '''S2''': The CPU is powered off.
 
** '''S3''': ''Suspend to RAM''.
 
** '''S3''': ''Suspend to RAM''.
 
** '''S4''': ''Suspend to disk'' or hibernate.
 
** '''S4''': ''Suspend to disk'' or hibernate.
* '''G2''' ('''S5''') ''Soft Off'' Almost the same as G3 but computer can "wake" from input from the keyboard, clock, modem, LAN, or USB device.
+
* '''G2''' ('''S5''') ''Soft off'' Almost the same as G3 but computer can "wake" from input from the keyboard, clock, modem, LAN, or USB device.
* '''G3''' ''Mechanical Off''
+
* '''G3''' ''Mechanical off''
 
+
Next, check your BIOS for the wakeup alarm function. This setting is likely found under a sub-menu of "Power Management Setup", "APM", or "Advanced" - you just need to poke around to find it. It will likely be called something like Wake From Alarm, Power-on by Alarm, Wake from RTC, RTC Resume, etc.
+
 
+
For Fedora 13 try (as root)
+
 
+
# grep -i rtc /var/log/messages
+
  
 +
Next, check your BIOS setup program for the wakeup alarm function. This setting is likely found under a submenu of "Power Management Setup," "APM," "ACPI," or "Advanced" - you just need to poke around to find it. It will likely be called something like Wake From Alarm, Power-on by Alarm, Wake from RTC, RTC Resume, etc.
  
{{SUSE_head| UTC, localtime and BIOS date format}}
+
{{SUSE_head| UTC, local time and BIOS date format}}
  
If supported by your BIOS, set the time to UTC (Coordinated Universal Time); UTC is the most desirable option because translation to local time is not required and daylight savings time is automatically handled. If UTC is not supported in the BIOS you will need to recalculate the time before you write it to the BIOS. You should be able to determine the time format on your machine by inspecting the output of the following command (there are an integer number of hours difference between UTC and local time).
+
If supported by your environment, <!-- The BIOS doesn't care jack diddly squat about to what time it is set; only systems (such as MS Windows) which access it care at all --> set the time to UTC (Coordinated Universal Time); UTC is the most desirable option because translation to local time is not required and daylight saving time is automatically handled. If UTC is not supported in your environment you will need to recalculate the time before you write it to the RTC. <!-- The BIOS is a program (in ROM) and as such one cannot "write the time to" it --> You should be able to determine the time format on your machine by inspecting the output of the following command (there are an integer number of hours difference between UTC and local time).
  
 
  cat /proc/driver/rtc
 
  cat /proc/driver/rtc
  
== Disable HWclock updates ==
+
== Disable hwclock updates ==
The reason for this recommendation is that most Linux distributions write the current system time back to the BIOS when shutting down the machine. With most BIOS, the machine will not wake up if the hardware clock has been modified after the wakeup alarm has been set. To avoid this, it is necessary to disable the writing of the current system time to the BIOS by the system shutdown scripts. This is distribution specific, so here are some examples:
+
The reason for this recommendation is that most Linux distributions write the current system time back to the RTC when shutting down the machine. With most RTCs, the machine will not wake up if the hardware clock has been modified after the wakeup alarm has been set. To avoid this, it is necessary to disable the writing of the current system time to the RTC by the system shutdown scripts. This is distribution specific, so here are some examples:
  
  
Line 126: Line 126:
 
;Ubuntu 9.10 and later
 
;Ubuntu 9.10 and later
  
Ubuntu 9.10 and later does not mention HWCLOCKACCESS in the man pages of <code>/etc/default/rcS</code>. Do the following instead:
+
Ubuntu 9.10 and later (which uses Upstart instead of SysV init) does not mention HWCLOCKACCESS in the man pages of <code>/etc/default/rcS</code>. Do the following instead:
  
 
Disable the exec line in <code>/etc/init/hwclock-save.conf</code>
 
Disable the exec line in <code>/etc/init/hwclock-save.conf</code>
Line 175: Line 175:
 
</pre>}}
 
</pre>}}
  
Or FC13
+
Or FC13 (not needed for FC15)
  
 
{{Code box|/etc/init.d/halt|<pre>
 
{{Code box|/etc/init.d/halt|<pre>
Line 207: Line 207:
 
;format of the /sys/class/rtc/rtc0/wakealarm
 
;format of the /sys/class/rtc/rtc0/wakealarm
  
* Instead of accepting a formatted time, wakealarm accepts the number of seconds since Jan 1, 1970 (this is known as "unix time", "POSIX time" or "epoch time").
+
* Instead of accepting a formatted time, wakealarm accepts the number of seconds since midnight on Jan 1, 1970 GMT (this is known as "unix time", "POSIX time" or "epoch time").
* You must make sure that your BIOS clock is set to UTC time - not localtime - otherwise it will wakeup at the wrong time. However, it is still possible if the BIOS clock is set to localtime (likely if you also run windows); see the section below for how to set the alarm correctly when the BIOS clock is in localtime.
+
* You must make sure that your RTC is set to UTC time - not local time - otherwise it will wakeup at the wrong time. However, it is still possible if the RTC is set to local time (likely if you also run MS Windows); see the section below for how to set the alarm correctly when the RTC is in local time.
* If you want to change the wakealarm time, you will need to write the new wakealarm time to the BIOS.
+
* If you want to change the wakealarm time, you will need to write the new wakealarm time to the RTC.
  
 
If you can't find /sys/class/rtc/rtc0/wakealarm, and you're running a modular kernel, it might be the case that the correct module is not loaded. In that case, make sure the rtc module is unloaded, and then load the rtc-cmos module:  
 
If you can't find /sys/class/rtc/rtc0/wakealarm, and you're running a modular kernel, it might be the case that the correct module is not loaded. In that case, make sure the rtc module is unloaded, and then load the rtc-cmos module:  
Line 217: Line 217:
 
=== Manually test wakealarm ===
 
=== Manually test wakealarm ===
  
First verify that your Linux kernel is 2.6.22 or newer and the HWclock update function has been disabled as described [[#Disable HWclock updates|above]].
+
First verify that your Linux kernel is 2.6.22 or newer and the hwclock update function has been disabled as described [[#Disable hwclock updates|above]].
  
 
{{SUSE_head|Simple test to wake the machine 5 minutes from now}}
 
{{SUSE_head|Simple test to wake the machine 5 minutes from now}}
Line 227: Line 227:
 
  cat /proc/driver/rtc
 
  cat /proc/driver/rtc
  
This should return a list of parameters. Check the "alrm_time" is 5 minutes into the future and the "alrm_date" is today.  
+
This should return a list of parameters. Check the "alrm_time" is 5 minutes into the future and the "alrm_date" is appropriate (which could be but might not be "today," if now + 5 minutes is the next day UTC).
  
{{Tip box|the "cat /proc/driver/rtc" command is a powerful debugging tool, allowing you to see the BIOS RTC parameters of interest.}}  
+
{{Tip box|the "cat /proc/driver/rtc" command is a powerful debugging tool, allowing you to see the RTC parameters of interest.}}  
  
Shutdown your computer and see if it comes back up in ~5 min.
+
Shut down your computer and see if it comes back up in ~5 minutes.
  
 
  sudo shutdown -h now  (in Ubuntu 10.4 "sudo shutdown -P now" (-h may cause system to restart))
 
  sudo shutdown -h now  (in Ubuntu 10.4 "sudo shutdown -P now" (-h may cause system to restart))
Line 247: Line 247:
  
  
{{SUSE_head|Setting alarm when BIOS clock is in localtime}}
+
{{SUSE_head|Setting alarm when RTC is in localtime}}
  
The BIOS clock is in localtime, however wakealarm must be given a UTC time.
+
The RTC is in local time, however wakealarm must be given a UTC time.
  
To get a UTC time in seconds since epoch for a local time that we want mythTV to wake up we do the following.  We pass the local time that we want to wake up as --date "2008-12-22 10:45:00", we indicate we want it reported as UTC time with -u, and we indicate we want it reported as seconds since epoch with +%s.
+
To get a UTC time in seconds since the epoch for a local time that we want MythTV to wake up we do the following.  We pass the local time that we want to wake up as --date "2008-12-22 10:45:00", we indicate we want it reported as UTC time with -u, and we indicate we want it reported as seconds since epoch with the format string "+%s".
 
  date -u --date "2008-12-22 10:45:00" +%s
 
  date -u --date "2008-12-22 10:45:00" +%s
  
Line 262: Line 262:
 
  cat /proc/driver/rtc
 
  cat /proc/driver/rtc
  
If the alarm is set then you should see something like this.  If so then shutdown and see if it wakes up at the alarm date/time.
+
If the alarm is set then you should see something like this.  If so then shut down and see if it wakes up at the alarm date/time.
 
  rtc_time : 13:40:26
 
  rtc_time : 13:40:26
 
  rtc_date : 2008-12-21
 
  rtc_date : 2008-12-21
Line 292: Line 292:
 
  batt_status : okay
 
  batt_status : okay
  
=== Integrate into mythTV ===
+
=== Integrate into MythTV ===
  
 
{{SUSE_head| mythtv-setup settings for your script}}
 
{{SUSE_head| mythtv-setup settings for your script}}
Line 299: Line 299:
 
Select the backend's "General" options and on the "Shutdown/Wakeup Options" page, make the following settings:
 
Select the backend's "General" options and on the "Shutdown/Wakeup Options" page, make the following settings:
  
* Block shutdown before client connected: (checked, if you run frontend and backend on 1 machine. Do not check if you do not automatically start the front end, and want the system to shut down after an automatic recording.)
+
* Block shutdown before client connected: (checked, if you run frontend and backend on 1 machine. Do not check if you do not automatically start the frontend, and want the system to shut down after an automatic recording.)
  
 
* Idle shutdown timeout (secs): 1200 (if you set this to 0, it will disable auto shutdown)
 
* Idle shutdown timeout (secs): 1200 (if you set this to 0, it will disable auto shutdown)
Line 311: Line 311:
 
* Command to set Wakeup Time: '''sudo sh -c "/usr/bin/setwakeup.sh  $time"'''
 
* Command to set Wakeup Time: '''sudo sh -c "/usr/bin/setwakeup.sh  $time"'''
  
* Server halt command: sudo shutdown -h now  (in Ubuntu 10.4 "sudo shutdown -P now" (-h may cause system to restart))
+
* Server halt command: sudo shutdown -h now  (some systems may need "sudo shutdown -P now" instead (-h may cause system to restart))
  
 
* Pre Shutdown check-command: (leave this blank)
 
* Pre Shutdown check-command: (leave this blank)
 
  
  
Line 331: Line 330:
  
 
Change the permissions of the file so that it can execute
 
Change the permissions of the file so that it can execute
  sudo chmod +x /usr/bin/setwakeup.sh
+
  chmod +x /usr/bin/setwakeup.sh
  
 +
<!-- added this because it's important that people understand at least a little bit about the security of one's systems, especially since with the introduction of IPv6, all systems on a network potentially become exposed to the Internet.  Therefore it's a good idea they become at least a little familiar with sudo -->
  
Add the following line to your /etc/sudoers by running "sudo visudo" and pasting the line at the end of the file.
+
You should check to make sure the user as whom mythbackend runs is able to run sudo without prompting for a password.  Consult the documentation for sudo on how to set this up in the sudoers file, in particular the NOPASSWD tag.  For example, you could add the following line to your /etc/sudoers by running "sudo visudo" and pasting the line at the end of the file.
  %mythtv ALL = NOPASSWD: /sbin/shutdown, /bin/sh, /usr/bin/setwakeup.sh
+
 
 +
  %mythtv ALL = NOPASSWD: /sbin/shutdown, /usr/bin/setwakeup.sh
 +
 
 +
The above is probably preferable from a security perspective because it is very specific.  Alternatively, uncomment the following line using "sudo visudo" in the /etc/sudoers file
  
Alternatively, uncommenting the following line using "sudo visudo" in the /etc/sudoers file
 
 
  %wheel ALL=(ALL) NOPASSWD: ALL  
 
  %wheel ALL=(ALL) NOPASSWD: ALL  
Then add mythtv and any other uses you wish to the "wheel" group.  That can be done using the GNOME user GUI.
+
 
 +
Then add mythtv and any other uses you wish to the "wheel" group.  That can be done using the GNOME user GUI. (Note, this line is already uncommented in Fedora 15.  Adding users to the wheel group, including the "mythtv" user, may be sufficient).
  
 
Also, it may be necessary to use "sudo visudo" to modify the sudoers file by commenting out the following line with a "#" before "Defaults" as follows:
 
Also, it may be necessary to use "sudo visudo" to modify the sudoers file by commenting out the following line with a "#" before "Defaults" as follows:
 +
 
   #Defaults requiretty
 
   #Defaults requiretty
  
You may run mythbackend in "Terminal" to observe log message in real time.  Or you may check the logs in /var/log/mythtv/ if the system shutsdowns with the test method above but not when integrated with the backend.  
+
You may run mythbackend in "Terminal" to observe log message in real time.  Or you may check the logs in /var/log/mythtv/ if the system shuts down with the test method above but not when integrated with the backend.
  
 
{{SUSE_head|Desktop users}}
 
{{SUSE_head|Desktop users}}
 
'''(For a system used as a desktop that is also used as a MythTV backend, or both a MythTV frontend and a MythTV backend, use the above instructions for a dedicated MythTV backend modified by the following instructions)'''
 
'''(For a system used as a desktop that is also used as a MythTV backend, or both a MythTV frontend and a MythTV backend, use the above instructions for a dedicated MythTV backend modified by the following instructions)'''
  
If you use your machine as a desktop and you do not want to keep the front end running while you use your computer for other things, create the following script
+
If you use your machine as a desktop and you do not want to keep the frontend running while you use your computer for other things, create the following script
 
{{Code box|/usr/bin/checklogin.sh|<pre>
 
{{Code box|/usr/bin/checklogin.sh|<pre>
 
#!/bin/bash
 
#!/bin/bash
# Check to see if anyone is currently logged in. Return zero if not and 1 if so.
+
# Check to see if anyone is currently logged in or if the machine was recently switched on.
 
# Echoed text appears in log file. It can be removed and --quiet added to the  
 
# Echoed text appears in log file. It can be removed and --quiet added to the  
# grep command once you are satisfied that mythTV is working properly
+
# grep command once you are satisfied that mythTV is working properly.
 +
# Exit codes:-
 +
# 2 - Machine recently switched on, don't shut down.
 +
# 1 - A user is logged in, don't shut down.
 +
# 0 - No user logged in, OK to shut down.
 +
 
 +
# Customizable variables
 +
MIN_UPTIME=10  # Minimum up time in minutes
 +
# End of customizable variables
  
 
# Get a date/time stamp to add to log output
 
# Get a date/time stamp to add to log output
Line 360: Line 372:
 
DATE=${DATE:0:23}
 
DATE=${DATE:0:23}
  
if  
+
UPTIME=`cat /proc/uptime | awk '{print int($1/60)}'`
  # The leading space is important!
+
 
  w | grep " 0 users"
+
if [ "$UPTIME" -lt "$MIN_UPTIME" ]; then
  then
+
    echo $DATE Machine uptime less than $MIN_UPTIME minutes, don\'t shut down.
     echo $DATE Noone is logged in, ok to shut down.
+
    exit 2
 +
fi
 +
 
 +
if who -q | grep "users=0"; then
 +
     echo $DATE No users are logged in, ok to shut down.
 
     exit 0
 
     exit 0
 
   else
 
   else
     echo $DATE Someone is still logged in, don\'t shut down!
+
     echo $DATE Someone is still logged in, don\'t shut down.
 
     exit 1
 
     exit 1
 
fi
 
fi
Line 378: Line 394:
 
Change the Pre Shutdown check-command in MythTV Backend setup to:
 
Change the Pre Shutdown check-command in MythTV Backend setup to:
  
  Pre Shutdown check-command: checklogin.sh
+
  Pre Shutdown check-command: /usr/bin/checklogin.sh
  
 
This will prevent myth from shutting down when someone is logged in
 
This will prevent myth from shutting down when someone is logged in
Line 404: Line 420:
  
 
mythbackend Shutdown/Wakeup Options (mythtv-setup)
 
mythbackend Shutdown/Wakeup Options (mythtv-setup)
 +
  
 
  Block shutdown before client connected : unchecked
 
  Block shutdown before client connected : unchecked
 
  Idle shutdown timeout (secs)          : 900 (if using active EIT this may need to be set to a lower value)
 
  Idle shutdown timeout (secs)          : 900 (if using active EIT this may need to be set to a lower value)
  Max. wait for recording (min)          : 15
+
  Max. wait for recording (min)          : 15 (mythshutdown will ignore values less than 15. If less than
  Startup before rec. (secs)            : 600 (make this time long enough to complete the boot & disk check before the recording should start)
+
                                          15 minutes to next scheduled recording or wakeup period the shutdown
 +
                                          will always be blocked)
 +
  Startup before rec. (secs)            : 600 (make this time long enough to complete the boot & disk check  
 +
                                          before the recording should start)
 
  Wakeup time format                    : yyyy-MM-ddThh:mm:ss ('''Must be this format for mythshutdown''')
 
  Wakeup time format                    : yyyy-MM-ddThh:mm:ss ('''Must be this format for mythshutdown''')
 
  Command to set Wakeup Time            : mythshutdown --setwakeup $time
 
  Command to set Wakeup Time            : mythshutdown --setwakeup $time
 
  Server halt command                    : mythshutdown --shutdown
 
  Server halt command                    : mythshutdown --shutdown
 
  Pre Shutdown check-command            : mythshutdown --check
 
  Pre Shutdown check-command            : mythshutdown --check
 +
  
 
MythShutdown/MythWelcome Settings (mythwelcome --setup or F11 in mythwelcome)
 
MythShutdown/MythWelcome Settings (mythwelcome --setup or F11 in mythwelcome)
  
  Command to set wakeup time            : sudo sh -c "/usr/bin/setwakeup.sh $time"
+
  Command to set wakeup time            : sudo /usr/bin/setwakeup.sh $time
 
  Wakeup time format                    : time_t
 
  Wakeup time format                    : time_t
 
  nvram-wakeup Restart command          : ('''Must be blank''')
 
  nvram-wakeup Restart command          : ('''Must be blank''')
  Command to shutdown                    : sudo shutdown -h now     (in Ubuntu 10.4 "sudo shutdown -P now" (-h may cause system to restart))
+
  Command to shutdown                    : sudo shutdown -h now (some systems may need "sudo shutdown -P now"  
 +
                                          instead (-h may cause system to restart))
 
  Command to start the frontend          : /usr/bin/mythfrontend
 
  Command to start the frontend          : /usr/bin/mythfrontend
 
  
 
setwakeup.sh with option for bios in UTC or local time.
 
setwakeup.sh with option for bios in UTC or local time.
Line 446: Line 467:
 
fi
 
fi
  
echo 0 > /sys/class/rtc/rtc0/wakealarm       # clear alarm
+
echo 0 > /sys/class/rtc/rtc0/wakealarm   # clear alarm
 
echo $SECS > /sys/class/rtc/rtc0/wakealarm  # write the waketime
 
echo $SECS > /sys/class/rtc/rtc0/wakealarm  # write the waketime
 
</pre>}}
 
</pre>}}
  
  
To be able to shutdown from the mythwelcome pop up menu add /usr/bin/mythshutdown to your /etc/sudoers by running "sudo visudo" and pasting the line at the end of the file.
+
Setup your /etc/sudoers permissions by running "sudo visudo" and pasting the line at the end of the file.
 +
 
 +
%mythtv ALL = NOPASSWD: /sbin/shutdown, /usr/bin/setwakeup.sh, /usr/bin/mythshutdown
 +
 
 +
It might be that sudo is configured to require a real tty to run commands as a user (i.e. mythtv). In this case add this line
  
  %mythtv ALL = NOPASSWD: /sbin/shutdown, /bin/sh, /usr/bin/setwakeup.sh, /usr/bin/mythshutdown
+
  Defaults:mythtv !requiretty
  
 
'''When you are finished using the frontend you should exit back to the mythwelcome screen to allow the system to shutdown.'''
 
'''When you are finished using the frontend you should exit back to the mythwelcome screen to allow the system to shutdown.'''
Line 463: Line 488:
 
The backend 'Command to set Wakeup Time' (mythshutdown --setwakeup $time) will be called. This writes the time into the database which mythwelcome will then use to detect if the next start-up is manual or for a scheduled recording / daily wakeup period.  
 
The backend 'Command to set Wakeup Time' (mythshutdown --setwakeup $time) will be called. This writes the time into the database which mythwelcome will then use to detect if the next start-up is manual or for a scheduled recording / daily wakeup period.  
  
The backend 'Server halt command' (mythshutdown --shutdown) will be called. This runs the mythwelcome 'Command to set wakeup time' (sudo sh -c "/usr/bin/setwakeup.sh $time"). The $time variable here will either be the time of the next scheduled recording or the time of the next defined wakeup period. The mythwelcome 'Command to shutdown' will then be called (sudo shutdown -h now) to shutdown the system.
+
The backend 'Server halt command' (mythshutdown --shutdown) will be called. This runs the mythwelcome 'Command to set wakeup time' (sudo /usr/bin/setwakeup.sh $time). The $time variable here will either be the time of the next scheduled recording or the time of the next defined wakeup period. The mythwelcome 'Command to shutdown' will then be called (sudo shutdown -h now) to shutdown the system.
  
 
== Troubleshooting /sys/class/rtc/rtc0/wakealarm ==
 
== Troubleshooting /sys/class/rtc/rtc0/wakealarm ==
Line 503: Line 528:
 
=== HPET conflict ===
 
=== HPET conflict ===
  
In some kernels (2.6.27 and possibly others) and on some hardware, [http://en.wikipedia.org/wiki/HPET HPET] seems to conflict with ACPI wakeup capabilities: calls to /sys/class/rtc/rtc0/wakealarm seem to behave normally but computer won't wake up. The solution is adding "hpet=disable" as kernel parameter at boot.
+
In some kernels (2.6.27 and possibly others) and on some hardware, [[wikipedia:HPET]] seems to conflict with ACPI wakeup capabilities: calls to /sys/class/rtc/rtc0/wakealarm seem to behave normally but computer won't wake up. The solution is adding "hpet=disable" as kernel parameter at boot.
  
 
For more information, see [http://bugzilla.kernel.org/show_bug.cgi?id=12013 upstream] or [https://bugs.launchpad.net/linux/+bug/307090 Ubuntu] bug.
 
For more information, see [http://bugzilla.kernel.org/show_bug.cgi?id=12013 upstream] or [https://bugs.launchpad.net/linux/+bug/307090 Ubuntu] bug.
Line 509: Line 534:
  
  
{{SUSE_head| ACPI enabled}}
+
=== SUSE_head | ACPI enabled ===
 
Check if ACPI is enabled in your kernel and working.
 
Check if ACPI is enabled in your kernel and working.
 
  $powersave -S
 
  $powersave -S
Line 777: Line 802:
  
 
This maps to CONFIG_RTC_CLASS in the kernel .config
 
This maps to CONFIG_RTC_CLASS in the kernel .config
 +
 +
= Helper script: TurnOff =
 +
 +
TurnOff is a useful script for the scenario where your MythTV based HTPC acts as a MythBackend, as a MythFrontend (for viewing content) and for other server purposes (e.g. a NFS server) as well.
 +
 +
The script has several activity monitors (one of which monitors MythBackend recording activities) which together decide whether the computer can be shut off and when to wake it up the next time. In case the next "activity event" (e.g. a MythTV recording) happens far enough in the future, the script triggers
 +
the ACPI wakeup and shuts the computer down.
 +
 +
The script is mature without critical bugs found for a long while. [[User:Visit0r|I]] have used it for 3 years for shutdown purposes without major problems.
 +
 +
Download if from here:
 +
{{Webpage|launchpad.net/turnoff|TurnOff}}
  
 
= Links to additional information =
 
= Links to additional information =
  
{{Webpage|http://en.wikipedia.org/wiki/Advanced_Configuration_and_Power_Interface|Wikipedia ACPI article}}
+
[[wikipedia:Advanced_Configuration_and_Power_Interface|Wikipedia ACPI article]]
 
{{Webpage|www.vdr-wiki.de/wiki/index.php/ACPI_Wakeup|http://www.vdr-wiki.de/wiki/index.php/ACPI_Wakeup -- use "translate.google.com" to translate this German wiki}}
 
{{Webpage|www.vdr-wiki.de/wiki/index.php/ACPI_Wakeup|http://www.vdr-wiki.de/wiki/index.php/ACPI_Wakeup -- use "translate.google.com" to translate this German wiki}}
 
{{Webpage|help.ubuntu.com/community/MythTV/Install/WhatNext/ACPIWake|help.ubuntu.com/community/MythTV/Install/WhatNext/ACPIWake}}
 
{{Webpage|help.ubuntu.com/community/MythTV/Install/WhatNext/ACPIWake|help.ubuntu.com/community/MythTV/Install/WhatNext/ACPIWake}}
Line 857: Line 894:
  
 
[[User:rp_linux|rp_linux]] Aug 2010. Asus AT3N7A-I (Intel Atom, nvidia ion). Mythbuntu 10.04. Works good. Tried both shutdown and pm-hibernate on dedicated FE/BE using mythwelcome method and recommend using pm-hibernate. Didn't have to tweak BIOS or hwclock.sh.
 
[[User:rp_linux|rp_linux]] Aug 2010. Asus AT3N7A-I (Intel Atom, nvidia ion). Mythbuntu 10.04. Works good. Tried both shutdown and pm-hibernate on dedicated FE/BE using mythwelcome method and recommend using pm-hibernate. Didn't have to tweak BIOS or hwclock.sh.
 +
 +
[[User:wild-e|wild-e]] Feb 2011. Gigabyte GA-MA78GM-S2H, everything seems to work once I disable HPET. I'm just wondering, what are downsides of disabling HPET, Or are there any. There is an (impropr) patch on the upstream bug link, also wondering i that has any side effects?
 +
 +
[[User:danellisuk|danellisuk]] Jun 2011. Gigabyte GA-MA78LMT-US2H with Ubuntu 11.04.  Also fine once HPET disabled in BIOS.
 +
 +
[[User:Dschey|Dschey]] Aug 2011. Foxconn MB-A7GM-S 785G AM2+ µATX with Mythbuntu 10.04. Have to set option hpet=disable to make wakeup work.
 +
 +
[[User:Televiscerator|Televiscerator]] Sep 2012 This will never work with the very old Asus A7N8X mobos (circa 2003/4). The Bios ACPI is broken such that they will only ever wake up if they were put into "Soft-Off" mode from the hardware power button. Shutdown from any operating system (Linux or Windows) does not return them to this soft-off state although leds on the NIC and mobo would have you believe otherwise. Wake up from RTC (or LAN) is then totally disabled.

Revision as of 17:12, 17 September 2012

System Wakeup

Introduction

Most users tend to leave their MythTV system running 24 by 7. This page describes the options you have in Linux to shut down and automatically wake up your machine before a recording. Doing so allows you to save energy, money and reduce your carbon footprint.


Your options
  • Hardware timer switch - a cheap power switch and a simple cron job to shutdown the machine can do the job
  • Wake on LAN - have another machine on your network wake your MythTV machine. (See the "Wake on LAN" MythTV HowTo)
  • Use the real time clock (RTC) - most machines (manufactured in 2000 or later) have the ability to use the RTC for time-controlled wakeup - this option is the subject of this HowTo


Use the RTC

MythTV has the ability to write the date and time of the next recording to the RTC. This allows your machine to automatically shutdown (or suspend) and turn on again a few minutes before it needs to record again. The Advanced Configuration and Power Interface (ACPI) specification is an open industry standard first released in December 1996 developed by HP, Intel, Microsoft, Phoenix, and Toshiba that defines common interfaces for hardware recognition, motherboard and device configuration and power management.

The ACPI real time clock alarm function can be used by your MythTV system to wake up your machine at a certain date and time.


Required steps for using the RTC to access the ACPI alarm function
  1. Configure your RTC with your BIOS setup
  2. Disable hwclock updates
  3. Configure MythTV


BIOS setup

If you want to use ACPI to wake up your MythTV system, you first need to ensure that your motherboard supports this functionality by looking at your BIOS setup. This information is stored in the FADT (Fixed ACPI Description Table). If your kernel version is 2.6.22 or later, you may find this information in your kernel log file:

$ grep -i rtc /var/log/kern.log
RTC can wake from S4
...
rtc0: alarms up to one month

For Fedora 13 or Mandriva try (as root)

# grep -i rtc /var/log/messages


The above indicates this system can wake from state S4 and that the wakeup time can be set.

The ACPI specifications defines the following so-called "global states" -- from Wikipedia ACPI

  • G1 Sleeping subdivides into the four states S1 through S4.
    • S1: The CPU(s) stop(s) executing instructions.
    • S2: The CPU is powered off.
    • S3: Suspend to RAM.
    • S4: Suspend to disk or hibernate.
  • G2 (S5) Soft off Almost the same as G3 but computer can "wake" from input from the keyboard, clock, modem, LAN, or USB device.
  • G3 Mechanical off

Next, check your BIOS setup program for the wakeup alarm function. This setting is likely found under a submenu of "Power Management Setup," "APM," "ACPI," or "Advanced" - you just need to poke around to find it. It will likely be called something like Wake From Alarm, Power-on by Alarm, Wake from RTC, RTC Resume, etc.

UTC, local time and BIOS date format

If supported by your environment, set the time to UTC (Coordinated Universal Time); UTC is the most desirable option because translation to local time is not required and daylight saving time is automatically handled. If UTC is not supported in your environment you will need to recalculate the time before you write it to the RTC. You should be able to determine the time format on your machine by inspecting the output of the following command (there are an integer number of hours difference between UTC and local time).

cat /proc/driver/rtc

Disable hwclock updates

The reason for this recommendation is that most Linux distributions write the current system time back to the RTC when shutting down the machine. With most RTCs, the machine will not wake up if the hardware clock has been modified after the wakeup alarm has been set. To avoid this, it is necessary to disable the writing of the current system time to the RTC by the system shutdown scripts. This is distribution specific, so here are some examples:


Gentoo.png Gentoo

Set clock_systohc to "NO" in /etc/conf.d/hwclock:

Script.png /etc/conf.d/hwclock
# Set CLOCK to "UTC" if your system clock is set to UTC (also known as
# Greenwich Mean Time).  If your clock is set to the local time, then
# set CLOCK to "local".  Note that if you dual boot with Windows, then
# you should set it to "local".
clock="UTC"

# If you want to set the Hardware Clock to the current System Time
# during shutdown, then say "YES" here.
# You normally don't need to do this if you run a ntp daemon.
clock_systohc="NO"

# If you wish to pass any other arguments to hwclock during bootup,
# you may do so here. Alpha users may wish to use --arc or --srm here.
clock_args=""


Geeko head48.png openSUSE

Set SYSTOHC to "no" in /etc/sysconfig/clock

Script.png /etc/sysconfig/clock
# Set to "-u" if your system clock is set to UTC, and to "--localtime"
# if your clock runs that way.
#
HWCLOCK="-u"

SYSTOHC="no"
# Is set to "yes" write back the system time to the hardware
# clock at reboot or shutdown. Usefull if hardware clock is
# much more inaccurate than system clock.  Set to "no" if
# system time does it wrong due e.g. missed timer interrupts.
# If set to "no" the hardware clock adjust feature is also
# skipped because it is rather useless without writing back
# the system time to the hardware clock.
               


Debianlogo.png Debian (and Ubuntu 8.04 and earlier)

Set HWCLOCKACCESS to "no" in /etc/default/rcS

Script.png /etc/default/rcS
#
# /etc/default/rcS
#
# Default settings for the scripts in /etc/rcS.d/
#
# For information about these variables see the rcS(5) manual page.
#
# This file belongs to the "initscripts" package.

TMPTIME=0
SULOGIN=no
DELAYLOGIN=no
UTC=no
VERBOSE=no
FSCKFIX=no
HWCLOCKACCESS=no
Ubuntu 9.10 and later

Ubuntu 9.10 and later (which uses Upstart instead of SysV init) does not mention HWCLOCKACCESS in the man pages of /etc/default/rcS. Do the following instead:

Disable the exec line in /etc/init/hwclock-save.conf

Script.png /etc/init/hwclock-save.conf
# hwclock-save - save system clock to hardware clock
#
# This task saves the time from the system clock back to the hardware
# clock on shutdown.
description	"save system clock to hardware clock"
start on runlevel [06]
task
script
    . /etc/default/rcS
    [ "$UTC" = "yes" ] && tz="--utc" || tz="--localtime"
    [ "$BADYEAR" = "yes" ] && badyear="--badyear"
#    exec hwclock --rtc=/dev/rtc0 --systohc $tz --noadjfile $badyear
end script

Or add the HWCLOCKACCESS variable to /etc/default/rcS and change the script to:

Script.png /etc/init/hwclock-save.conf
# hwclock-save - save system clock to hardware clock
#
# This task saves the time from the system clock back to the hardware
# clock on shutdown.
description	"save system clock to hardware clock"
start on runlevel [06]
task
script
    . /etc/default/rcS
    [ "$UTC" = "yes" ] && tz="--utc" || tz="--localtime"
    [ "$BADYEAR" = "yes" ] && badyear="--badyear"
    if [ "$HWCLOCKACCESS" != "no" ]; then
        exec hwclock --rtc=/dev/rtc0 --systohc $tz --noadjfile $badyear
    fi
end script


Fedora.png Fedora Core 6 and later

modifying /etc/init.d/halt with the following will fix this problem:

Script.png /etc/init.d/halt

==>  ACPITIME=`cat /proc/acpi/alarm`

     [ -x /sbin/hwclock ] && action $"Syncing hardware clock to system time" /sbin/hwclock $CLOCKFLAGS
                
==>  echo "$ACPITIME" > /proc/acpi/alarm

Or FC13 (not needed for FC15)


Script.png /etc/init.d/halt

==>  ACPITIME=`cat /sys/class/rtc/rtc0/wakealarm`

     [ -x /sbin/hwclock ] && action $"Syncing hardware clock to system time" /sbin/hwclock --systohc
                
==>  echo "$ACPITIME" > /sys/class/rtc/rtc0/wakealarm

Which kernel are you using?

The ACPI interface in Linux changed with kernel 2.6.22 (released on 8 July 2007). You can determine your kernel version by entering the following command in a terminal window:

uname -a

Kernels 2.6.22 and higher may be configured to use the legacy /proc/acpi/alarm instead of the new rtc wakealarm. See the notes about compiling your own kernel below.

Note that kernel version 2.6.26, included in the current Debian stable distribution, contains a bug that makes ACPI wakeup fail on at least some motherboards. If this affects you, either upgrade to 2.6.33-rc4 or patch 2.6.26 with this patch.

Using /sys/class/rtc/rtc0/wakealarm

Kernel versions 2.6.22 and newer use /sys/class/rtc/rtc0/wakealarm

ls /sys/class/rtc/rtc0/wakealarm
format of the /sys/class/rtc/rtc0/wakealarm
  • Instead of accepting a formatted time, wakealarm accepts the number of seconds since midnight on Jan 1, 1970 GMT (this is known as "unix time", "POSIX time" or "epoch time").
  • You must make sure that your RTC is set to UTC time - not local time - otherwise it will wakeup at the wrong time. However, it is still possible if the RTC is set to local time (likely if you also run MS Windows); see the section below for how to set the alarm correctly when the RTC is in local time.
  • If you want to change the wakealarm time, you will need to write the new wakealarm time to the RTC.

If you can't find /sys/class/rtc/rtc0/wakealarm, and you're running a modular kernel, it might be the case that the correct module is not loaded. In that case, make sure the rtc module is unloaded, and then load the rtc-cmos module:

rmmod rtc
modprobe rtc-cmos

Manually test wakealarm

First verify that your Linux kernel is 2.6.22 or newer and the hwclock update function has been disabled as described above.

Simple test to wake the machine 5 minutes from now
sudo sh -c "echo 0 > /sys/class/rtc/rtc0/wakealarm"
sudo sh -c "echo `date '+%s' -d '+ 5 minutes'` > /sys/class/rtc/rtc0/wakealarm"
cat /sys/class/rtc/rtc0/wakealarm

Check

cat /proc/driver/rtc

This should return a list of parameters. Check the "alrm_time" is 5 minutes into the future and the "alrm_date" is appropriate (which could be but might not be "today," if now + 5 minutes is the next day UTC).


Information.png Tip: the "cat /proc/driver/rtc" command is a powerful debugging tool, allowing you to see the RTC parameters of interest.

Shut down your computer and see if it comes back up in ~5 minutes.

sudo shutdown -h now  (in Ubuntu 10.4 "sudo shutdown -P now" (-h may cause system to restart))


Example to convert to epoch time and set date/time
echo 0 > /sys/class/rtc/rtc0/wakealarm
date -u --date "Jul 1, 2008 10:32:00" +%s > /sys/class/rtc/rtc0/wakealarm


Example to convert from epoch time to readable date/time
date -d @1214908320 +%F" "%T
2008-07-01 12:32:00


Setting alarm when RTC is in localtime

The RTC is in local time, however wakealarm must be given a UTC time.

To get a UTC time in seconds since the epoch for a local time that we want MythTV to wake up we do the following. We pass the local time that we want to wake up as --date "2008-12-22 10:45:00", we indicate we want it reported as UTC time with -u, and we indicate we want it reported as seconds since epoch with the format string "+%s".

date -u --date "2008-12-22 10:45:00" +%s

So to set the alarm we can do the following.

SECS=`date -u --date "2008-12-22 10:45:00" +%s`
echo 0 > /sys/class/rtc/rtc0/wakealarm
echo $SECS > /sys/class/rtc/rtc0/wakealarm

Then we can confirm that the alarm is set with the following.

cat /proc/driver/rtc

If the alarm is set then you should see something like this. If so then shut down and see if it wakes up at the alarm date/time.

rtc_time	: 13:40:26
rtc_date	: 2008-12-21
alrm_time	: 10:45:00
alrm_date	: 2008-12-22
alarm_IRQ	: yes
alrm_pending	: no
24hr		: yes
periodic_IRQ	: no
update_IRQ	: no
HPET_emulated	: no
DST_enable	: no
periodic_freq	: 1024
batt_status	: okay

If you see the alarm date similar to ****-12-21 then the alarm is set to a time in the past and it won't wake up.

rtc_time	: 13:42:01
rtc_date	: 2008-12-21
alrm_time	: 13:46:59
alrm_date	: ****-12-21
alarm_IRQ	: no
alrm_pending	: no
24hr		: yes
periodic_IRQ	: no
update_IRQ	: no
HPET_emulated	: no
DST_enable	: no
periodic_freq	: 1024
batt_status	: okay

Integrate into MythTV

mythtv-setup settings for your script

(use these instructions for a dedicated backend system)

Select the backend's "General" options and on the "Shutdown/Wakeup Options" page, make the following settings:

  • Block shutdown before client connected: (checked, if you run frontend and backend on 1 machine. Do not check if you do not automatically start the frontend, and want the system to shut down after an automatic recording.)
  • Idle shutdown timeout (secs): 1200 (if you set this to 0, it will disable auto shutdown)
  • Max. wait for recording (min): 120
  • Startup before rec. (secs): 600 (If you have not disabled the occasional disk check on boot, make this time long enough to complete the boot & disk check before the recording should start)
  • Wakeup time format: time_t
  • Command to set Wakeup Time: sudo sh -c "/usr/bin/setwakeup.sh $time"
  • Server halt command: sudo shutdown -h now (some systems may need "sudo shutdown -P now" instead (-h may cause system to restart))
  • Pre Shutdown check-command: (leave this blank)


Write the startup script

You'll need to copy/paste the following into your editor:


Script.png setwakeup.sh
#!/bin/sh
#$1 is the first argument to the script. It is the time in seconds since 1970
#this is defined in mythtv-setup with the time_t argument

echo 0 > /sys/class/rtc/rtc0/wakealarm      #this clears your alarm.
echo $1 > /sys/class/rtc/rtc0/wakealarm     #this writes your alarm

Change the permissions of the file so that it can execute

chmod +x /usr/bin/setwakeup.sh


You should check to make sure the user as whom mythbackend runs is able to run sudo without prompting for a password. Consult the documentation for sudo on how to set this up in the sudoers file, in particular the NOPASSWD tag. For example, you could add the following line to your /etc/sudoers by running "sudo visudo" and pasting the line at the end of the file.

%mythtv ALL = NOPASSWD: /sbin/shutdown, /usr/bin/setwakeup.sh

The above is probably preferable from a security perspective because it is very specific. Alternatively, uncomment the following line using "sudo visudo" in the /etc/sudoers file

%wheel ALL=(ALL) NOPASSWD: ALL 

Then add mythtv and any other uses you wish to the "wheel" group. That can be done using the GNOME user GUI. (Note, this line is already uncommented in Fedora 15. Adding users to the wheel group, including the "mythtv" user, may be sufficient).

Also, it may be necessary to use "sudo visudo" to modify the sudoers file by commenting out the following line with a "#" before "Defaults" as follows:

 #Defaults requiretty

You may run mythbackend in "Terminal" to observe log message in real time. Or you may check the logs in /var/log/mythtv/ if the system shuts down with the test method above but not when integrated with the backend.

Desktop users

(For a system used as a desktop that is also used as a MythTV backend, or both a MythTV frontend and a MythTV backend, use the above instructions for a dedicated MythTV backend modified by the following instructions)

If you use your machine as a desktop and you do not want to keep the frontend running while you use your computer for other things, create the following script

Script.png /usr/bin/checklogin.sh
#!/bin/bash
# Check to see if anyone is currently logged in or if the machine was recently switched on.
# Echoed text appears in log file. It can be removed and --quiet added to the 
# grep command once you are satisfied that mythTV is working properly.
# Exit codes:-
# 2 - Machine recently switched on, don't shut down.
# 1 - A user is logged in, don't shut down.
# 0 - No user logged in, OK to shut down.

# Customizable variables
MIN_UPTIME=10   # Minimum up time in minutes
# End of customizable variables

# Get a date/time stamp to add to log output
DATE=`date +%F\ %T\.%N`
DATE=${DATE:0:23}

UPTIME=`cat /proc/uptime | awk '{print int($1/60)}'`

if [ "$UPTIME" -lt "$MIN_UPTIME" ]; then
    echo $DATE Machine uptime less than $MIN_UPTIME minutes, don\'t shut down.
    exit 2
fi

if who -q | grep "users=0"; then
    echo $DATE No users are logged in, ok to shut down.
    exit 0
  else
    echo $DATE Someone is still logged in, don\'t shut down.
    exit 1
fi

Change its attributes to executable

sudo chmod +x /usr/bin/checklogin.sh

Change the Pre Shutdown check-command in MythTV Backend setup to:

Pre Shutdown check-command: /usr/bin/checklogin.sh

This will prevent myth from shutting down when someone is logged in

You must remember to log out rather than shut down when you are done with your session, allowing the mythTV backend to shut off the computer when it is idle. This is because the mythTV shutdown sequence writes the wakealarm time to the BIOS just before shutting down the system. If, instead, you shut the system down, the mythTV backend is not able to update the BIOS with the correct wakealarm time. Failure to follow this procedure could interrupt a recording, or prevent the system from powering on for a later recording.

Note that the Idle Timeout time is the time you have to type your username and password when logging in. It would be a good idea to make it long enough to log in before the system can shut itself off.

In the BIOS, set your system to power on when power is restored. This will allow the system to recover after a power outage. Some systems will disable the wakealarm after a power outage, but even if it doesn't, if the power is off at the programmed wake time, the wakealarm could be missed. Powering up after a power outage allows mythTV to reset the wakealarm so that future recordings are not missed.

Using ACPI & MythTV to run other applications


Mythwelcome users

Mythwelcome is useful if you run a combined frontend / backend machine and want to use ACPI Wakeup. It allows :-

  • Automatic startup of the frontend. If the system has been started due to a scheduled recording the mythwelcome status page will be shown instead to allow the system to shut itself back down.
  • Locking the machine to prevent shutdown, useful if you need to perform maintenance or other tasks on the system.
  • Pre defined wakeup/shutdown periods.


Configuration changes needed :-

Change the system so that mythwelcome is started instead of mythfrontend.

Information.png Tip: In Mythbuntu to start mythwelcome instead of mythfrontend you just need to uncomment the MYTHWELCOME line in /etc/mythtv/session-settings.

mythbackend Shutdown/Wakeup Options (mythtv-setup)


Block shutdown before client connected : unchecked
Idle shutdown timeout (secs)           : 900 (if using active EIT this may need to be set to a lower value)
Max. wait for recording (min)          : 15 (mythshutdown will ignore values less than 15. If less than
                                         15 minutes to next scheduled recording or wakeup period the shutdown
                                         will always be blocked)
Startup before rec. (secs)             : 600 (make this time long enough to complete the boot & disk check 
                                         before the recording should start)
Wakeup time format                     : yyyy-MM-ddThh:mm:ss (Must be this format for mythshutdown)
Command to set Wakeup Time             : mythshutdown --setwakeup $time
Server halt command                    : mythshutdown --shutdown
Pre Shutdown check-command             : mythshutdown --check


MythShutdown/MythWelcome Settings (mythwelcome --setup or F11 in mythwelcome)

Command to set wakeup time             : sudo /usr/bin/setwakeup.sh $time
Wakeup time format                     : time_t
nvram-wakeup Restart command           : (Must be blank)
Command to shutdown                    : sudo shutdown -h now (some systems may need "sudo shutdown -P now" 
                                         instead (-h may cause system to restart))
Command to start the frontend          : /usr/bin/mythfrontend

setwakeup.sh with option for bios in UTC or local time.

Script.png setwakeup.sh
#!/bin/sh
#
# set ACPI Wakeup time
# usage: setwakeup.sh seconds
#    seconds - number of seconds from epoch to UTC time (time_t time format)
#
# set UTCBIOS to true if bios is using UTC time
# set UTCBIOS to false if bios is using local time

UTCBIOS=true

if $UTCBIOS
then
    #utc bios - use supplied seconds
    SECS=$1
else
    #non utc bios - convert supplied seconds to seconds from
    #epoch to local time
    SECS=`date -u --date "\`date --date @$1 +%F" "%T\`" +%s`
fi

echo 0 > /sys/class/rtc/rtc0/wakealarm    # clear alarm
echo $SECS > /sys/class/rtc/rtc0/wakealarm   # write the waketime


Setup your /etc/sudoers permissions by running "sudo visudo" and pasting the line at the end of the file.

%mythtv ALL = NOPASSWD: /sbin/shutdown, /usr/bin/setwakeup.sh, /usr/bin/mythshutdown

It might be that sudo is configured to require a real tty to run commands as a user (i.e. mythtv). In this case add this line

Defaults:mythtv !requiretty

When you are finished using the frontend you should exit back to the mythwelcome screen to allow the system to shutdown.

Shutdown procedure when using this configuration :-

The backend 'Pre Shutdown check-command' will be called - if it returns 0 then

The backend 'Command to set Wakeup Time' (mythshutdown --setwakeup $time) will be called. This writes the time into the database which mythwelcome will then use to detect if the next start-up is manual or for a scheduled recording / daily wakeup period.

The backend 'Server halt command' (mythshutdown --shutdown) will be called. This runs the mythwelcome 'Command to set wakeup time' (sudo /usr/bin/setwakeup.sh $time). The $time variable here will either be the time of the next scheduled recording or the time of the next defined wakeup period. The mythwelcome 'Command to shutdown' will then be called (sudo shutdown -h now) to shutdown the system.

Troubleshooting /sys/class/rtc/rtc0/wakealarm

Getting your PC to wakeup using the ACPI RTC can be challenging. Here are some tips on getting it working.


Consider updating your BIOS

Since this wakeup functionality utilizes your BIOS, you may need to update your BIOS to it's later version. But please understand the potential risks of updating your BIOS before doing so.

Check your hardware

Check if your BIOS supports ACPI/RTC You will need to have a motherboard that supports both ACPI and a Real Time Clock Alarm Functions in the BIOS. Check your BIOS and look for a tab similar to "Advanced Power management".

The wake-up function is provided on most modern boards by the ability to "wake from RTC alarm" - setting a date and time in BIOS will cause the computer to power itself on and boot at the set time. This setting is likely found under a sub-menu of "Power Management" "APM", or "Advanced" - you just need to poke around to find it. It will likely be called something like Wake from RTC, Wake From Alarm, RTC Resume, etc.

If you don't have an ACPI-compliant BIOS, you could use nvram-wakeup instead, which is a small program which modifies the BIOS settings memory (NVRAM) directly (this is no longer recommended). All modern BIOSes should support ACPI, however.


Manually test wakealarm

see the Manually test wakealarm above


Fussy BIOS

There are a lot of fussy BIOSes out there. In some cases you need to disable the RTC alarm function in the bios to make things work. After you have set the RTC alarm from Linux, you might not see the changes in the BIOS, but it still works. If things are still not working for you ... try the following:

Disable/Enable RTC in BIOS
  • In some cases you need to disable the RTC alarm function is the BIOS to make things work.
  • On many boards, when the RTC setting is enabled in the BIOS, it will wake only from a time set and saved from BIOS setup, and not from a time set outside of the BIOS setup environment - as we want. All of the boards the original author of this document needed this setting disabled to correctly wake with ACPI. This is the recommended starting point.


Time/Date not visible in BIOS

After you have set the RTC alarm from Linux, it could be that you not see changes in the BIOS but it still works.

Make use of the following command to determine if the relevant wakealarm BIOS contents are proper.

cat /proc/driver/rtc

HPET conflict

In some kernels (2.6.27 and possibly others) and on some hardware, wikipedia:HPET seems to conflict with ACPI wakeup capabilities: calls to /sys/class/rtc/rtc0/wakealarm seem to behave normally but computer won't wake up. The solution is adding "hpet=disable" as kernel parameter at boot.

For more information, see upstream or Ubuntu bug.


SUSE_head | ACPI enabled

Check if ACPI is enabled in your kernel and working.

$powersave -S
  ACPI

If powersaved is not installed on your system, do not install it, it may break other things. Installing powersaved will uninstall powernow which will prevent some systems from controlling their processor speed, and bring up an unattributed message box on every boot telling you it is unable to control the processor clock.

Backend not shutting down when using EIT

Using EIT (program guide scanned directly from channels) you may find that your backend doesn't shut down after the time specified, even when it's idle. This seems to be caused by the EIT scanning resetting the backend idle counter. This can be prevented by going into mythtv-setup and setting the General->"EIT Scanner Options"->"Backend Idle Before EIT Crawl" time to the same as (or greater than) the General->"Shutdown/Wakeup Options"->"Idle shutdown timeout".

S3 (Suspend to RAM)

First, see the BIOS setup section above to confirm which powerdown states your computer's ACPI supports. Some computers are unable to wake up from S5 (Soft Off) by an RTC alarm set through ACPI. For example some HP Compaq desktop computers allow you to set wakeup from BIOS at a specific time and at specific week days, however it is ignored ACPI alarm. In this case you may want to try to see if it does wake up from S3 (Suspend to RAM) instead.

The following check needs pm-utils package to work. You may also want to turn off X windows, as quite a few drivers don't like suspend to RAM.

 # Set the alarm to five minutes in the future 
 echo 0 > /sys/class/rtc/rtc0/wakealarm
 echo `date '+%s' -d '+ 5 minutes'` > /sys/class/rtc/rtc0/wakealarm

 /usr/sbin/pm-suspend

If the computer wakes up after 5 minutes, then congratulations.

Because "suspend to RAM" may not be very stable with the exotic hardware that a lot of mythTV users have, we want to reboot after we wake up from suspend. In fact we can add an init.d script that will suspend the computer just before it physically reboots, on wake up the computer will then do the actual reboot.

I have included an example script for Ubuntu below that will check for an /wakeup file in the root filesystem which contains the time to wakeup (seconds since epoch). You will have to change the mythtv shutdown scripts to create this file and use reboot instead of shutdown.


Script.png /etc/init.d/wakeup
#!/bin/sh

### BEGIN INIT INFO
# Provides:        wakeup
# Required-Start:
# Required-Stop:
# Default-Start:
# Default-Stop:    0 6
# Short-Description: Start NTP daemon
### END INIT INFO
 
PATH=/sbin:/bin:/usr/sbin:/usr/bin
 
. /lib/lsb/init-functions

NAME=wakeup

case $1 in
	stop)
		if [ -f /wakeup ]
		then
			WAKETIME=`cat /wakeup`
			CURTIME=`date +%s`
			if [ "$WAKETIME" -gt "$CURTIME" ]
			then
				log_daemon_msg "suspending with wakeup" "wakup"

				# Make it wakeup from ethernet
				ethtool -s eth0 wol g
				echo PCI0 >/proc/acpi/wakeup

				# Make it wakeup from alarm.
				echo 0 >/sys/class/rtc/rtc0/wakealarm
				echo $WAKETIME >/sys/class/rtc/rtc0/wakealarm

				/usr/sbin/pm-suspend

				log_daemon_msg "continuing with wakeup" "wakup"
			fi
			rm -f /wakeup
		fi
  		;;
	*)
		echo "Usage: $0 {stop}"
		exit 2
		;;
 esac

This script is linked to from the /etc/rc0.d and /etc/rc6.d directories at a position just before the /proc, /sys and / get unmounted.

 ln -s ../init.d/wakeup /etc/rc0.d/S50wakeup
 ln -s ../init.d/wakeup /etc/rc6.d/S50wakeup
 


Archive: Using /proc/acpi/alarm

This section is archival in nature and may not be up to date.

/proc/acpi/alarm
  • Kernels 2.6.21 and older use /proc/acpi/alarm
ls /proc/acpi/alarm 
format of /proc/acpi/alarm

Year-month-day hour:min:sec - yyyy-MM-dd hh:mm:ss - (e.g. 2005-12-29 10:10:04)

Before making complex scripts, do a simple test to ensure that a wakeup time can be written to the BIOS and that the computer correctly wakes up based on this time:

Initiate manually

The commands set the wakeup time to 5 minute from now, regardless of whether the RTC is in UTC or locatltime and then turns off the machine.


The following example will set the wakeup time to 5 minute from now, regardless of whether the RTC is in UTC or locatltime. You may not see the change in the bios, but it should still work.

if you are using the /proc/acpi/alarm interface
echo "+00-00-00 00:05:00" > /proc/acpi/alarm 

Check that it was written, the format is YYYY-MM-DD HH:MM:SS

cat /proc/acpi/alarm

If the year part looks like "0007" instead of "2007", change +00 with +2000; Shutdown your machine and wait for it to wakeup

shutdown -h now


Here are the commands to check that you have ACPI working.

$powersave -S
  ACPI

Check that you have the alarm function in /proc/acpi/alarm. This prints out the RTC Alarm clock from the BIOS.

$cat /proc/acpi/alarm
 2005-**-29 10:10:04

Check that you can write a new time to the RTC Clock Alarm (you will need to be Root) Format is YYYY-MM-DD HH:MM:SS

#echo "2005-12-29 10:10:04" >/proc/acpi/alarm

Check that it was written, shut down and wait for it to wakeup.

#cat /proc/acpi/alarm
 2005-*12-29 10:10:04 
#shutdown -h now


For example (Assuming bios is in localtime):

Wakeup time format: yyyy-MM-dd hh:mm:ss
Set wakeuptime command: sudo sh -c 'echo $time > /proc/acpi/alarm'

Example for a bios configured for universal time, assuming mythshutdown is run as superuser:

 Wakeup time format: time_t
 Command to Set Wakeup Time: date -u -d @$time +%F\ %T > /proc/acpi/alarm

Integrate into mythTV

Remember, your bios time might be in UTC rather than local time using:

  # echo "+00-00-00 00:05:00" > /proc/acpi/alarm 

will set the wakeup time to 5 minute from now, regardless of whether the RTC is in UTC or locatltime.

Since the wake-up time given by mythtv to the mythtv wakeup command is in local time, you need to do some bash handling of the obtained time to be able to setup the wakeup time in the bios in UTC (independent of daylight savings time and such). The following bash code might help here:

#!/bin/bash
stamp_file=/home/mythtv/timestamp
echo $1\ $2 > $stamp_file
# If using mythwelcome you can try the next line instead on the one above.
#echo $1 | sed "s/T/ /" >$stamp_file
# Read the date in the locale time format and add the time-zone info to the stamp_file
datum=$(/bin/date -f $stamp_file +%F\ %T\ %z)
echo $datum > $stamp_file
# reinterpret this in utc and write to alarm
utcdatum=$(/bin/date -u -f $stamp_file +%F\ %T)
echo $utcdatum > $stamp_file
#rm -f $stamp_file
#echo $utcdatum >/proc/acpi/alarm


As you noticed the echo to the acpi-alarm is commented out by default, because it is really better to check first if everything is working correctly (time format the same on your BIOS and such).

An alternative script to the above is the following:

 #!/bin/bash
 stamp_file=/home/mythtv/timestamp
 
 #just log what we get as command line parameters
 echo $1 $2 $3> $stamp_file
 
 #I set mythtv to output the number of seconds since epoch
 #so I calculate the number of hours, minutes and seconds from
 #now the computer has to wakeup:
 sfn=$(($2 - `date +"%s"`))
 
 # Offset from GMT as the awk function does timezone correction.
 tzone=3600

 #and then send it to /proc/acpi/wakeup in the format we saw above
 y=`(echo $(($sfn - $tzone))|awk '{print strftime("+00-00-00 %H:%M:%S", $1)}')`
 
 echo "$y">/proc/acpi/alarm
 echo "$y">>$stamp_file
 echo "executed at `date`" >> $stamp_file
 exit

This works on a lot of different EPIA and ASUS Motherboards, and is not dependent on the timezone you use in the bios.


Another contributed script

This acpi-alarm script will function with the new sys wakealarm interface or the old acpi/alarm interface


Script.png sample.sh
#!/bin/sh
# $1 is the --settime switch that nvram-wakeup normally expects
# $2 is the date/time in seconds since 1970

DATE=`date -d "1970-01-01 $2 sec" "+%F %H:%M:%S" -u`
SECS=`date -d "1970-01-01 $2 sec" "+%s" -u`

# Save the wakeup time
echo "$*"  > /myth.wakeup.args
echo $DATE > /myth.wakeup.time
echo $SECS > /myth.wakeup.secs

if [ -e /sys/class/rtc/rtc0/wakealarm ]; then
        echo 0 > /sys/class/rtc/rtc0/wakealarm
        echo $SECS > /sys/class/rtc/rtc0/wakealarm
fi
if [ -e /proc/acpi/alarm ]; then
        echo $DATE > /proc/acpi/alarm
fi

If leaving the RTC wakeup alarm on the BIOS worked with the old interface, you may need to disable it when migrating to the new interface.

Warning.png Warning: The wakealarm interface is incompatible with the kernel's old "Enhanced Real Time Clock Support" and "Generic /dev/rtc emulation" options. If your kernel was built with these enabled your kernel log will contain messages such as
rtc_cmos: probe of 00:03 failed with error -16
The solution is to rebuild your kernel with the above two options excluded (find them under Drivers -> Character Devices) and the various RTC interfaces (found under Drivers -> Real Time Clock) included. From a .config point of view CONFIG_RTC and CONFIG_GEN_RTC must be unset and, at a minimum, RTC_INTF_SYSFS must be set.


Troubleshooting /proc/acpi/alarm

First, check the Troubleshooting /sys/class/rtc/rtc0/wakealarm section above. The following tips are for /proc/acpi/alarm and older systems.


Consider updating your BIOS

Since this wakeup functionality utilizes your BIOS, you may need to update your BIOS to it's latest version. But please understand the potential risks of updating your BIOS before doing so.

Check your hardware

If you don't have an ACPI-compliant BIOS, you could use nvram-wakeup instead, which is a small that modifies the BIOS settings memory (NVRAM) directly (no longer recommended). All modern BIOSes should support ACPI, however.

Initiate manually

see the "Initiate manually" Initiate manually section above.


Fussy BIOS

There are a lot of fussy BIOSes out there. If things are still not working for you... try the following:

Disable/Enable RTC in BIOS

Another possible glitch is, that the option "Resume By Alarm" (or whatever it is called) is set to Enabled but wake up using /proc/acpi/alarm only works if the option is set to Disabled. Sounds weird but works with some boards.

Required to write time/date two times

Some users reported that their BIOS is only updated after writing 2 times to the alarm file. (reported with proc/acpi/alarm)


Advanced: Compile your own kernel

For the ones that compile their own kernel, make sure ACPI is turned on. (Not required for standard distributions) The setup of /proc/acpi/alarm is done in kernel file drivers/acpi/sleep/proc.c and controlled by the CONFIG_ACPI_SLEEP_PROC_FS flag. You can test support for you architecture by going to you kernel source and do:

$grep -r CONFIG_ACPI_SLEEP_PROC_FS arch/*
 arch/x86_64/defconfig:CONFIG_ACPI_SLEEP_PROC_FS=y


Important.png Note: To enable acpi-sleep in the kernel, it is necessary to set "Support for hot-pluggable CPUs

( Processor type and features  ---> [*] Support for hot-pluggable CPUs) so that
"CONFIG_HOTPLUG_CPU=y" in the ".config" file. After this it is possible to set
([*]   Sleep States) under ACPI support.

To use /proc/acpi/alarm with kernel versions 2.6.22 and higher, disable Device Drivers / Real Time Clock

This maps to CONFIG_RTC_CLASS in the kernel .config

Helper script: TurnOff

TurnOff is a useful script for the scenario where your MythTV based HTPC acts as a MythBackend, as a MythFrontend (for viewing content) and for other server purposes (e.g. a NFS server) as well.

The script has several activity monitors (one of which monitors MythBackend recording activities) which together decide whether the computer can be shut off and when to wake it up the next time. In case the next "activity event" (e.g. a MythTV recording) happens far enough in the future, the script triggers the ACPI wakeup and shuts the computer down.

The script is mature without critical bugs found for a long while. I have used it for 3 years for shutdown purposes without major problems.

Download if from here:

Webpage.png - TurnOff

Links to additional information

Wikipedia ACPI article

Webpage.png - http://www.vdr-wiki.de/wiki/index.php/ACPI_Wakeup -- use "translate.google.com" to translate this German wiki

Webpage.png - help.ubuntu.com/community/MythTV/Install/WhatNext/ACPIWake

Webpage.png - http://acpi.sourceforge.net/documentation/alarm.html -- only for kernels 2.6.21 and older

Document.png - Article about wakeup, Linux Magazine -- mostly for kernels 2.6.21 and older


User experience

Moosylog - March 2007: Works fine with MSI RS482M-IL and openSUSE 10.2 after I made the following change to /etc/sysconfig/clock.....SYSTOHC="yes" to SYSTOHC="no".

Turpie: Works great with the Asus M2NPV-VM. Rad: Yep, but needs a recent bios version

Murph - April 2007: Works also great with the Legend QDI Advance 5/133E.

mythwog: No problems with ECS PT890T-A. Simply wrote wake up time to /proc/acpi/alarm, halted, and system wakes up.

Fuchur - August 2007: Had to replace the wakeup script with the one from http://www.mythwiki.de/index.php?title=HOWTO_Mythwelcome as my mythshutdown produces another time format. Otherwise it seems to work so far.

Mattwire - September 2007: Works fine with MSI K8NGM2-FID and NC6120 laptop running Ubuntu Feisty and Gutsy. Both require modification to /etc/init.d/hwclock.sh to save the wakeup time.

Dumdideldum - September 2007: Works with Epox 8rda+ running Ubuntu Feisty. It is important to disable the wakeup on rtc in the Bios and editing the /etc/init.d/hwclock.sh as described in the Ubuntu guide linked in the section below.

Pkendall - September 2007: Works fine with MSI K9NBPM2-FID running Ubuntu Feisty. As above, edit the hwclock.sh file and make sure Bios RTC wakeup is disabled.

Jmwislez - September 2007: Problem with ASUS P5GD1 motherboard (BIOS v1.014). Writing 'echo "2007-09-09 14:15:00" > /proc/acpi/alarm' works perfectly, reading via 'cat /proc/acpi/alarm' yields the expected '2007-09-09 14:15:00', but the system doesn't start at the specified time. After a manually initiated boot, 'cat /proc/acpi/alarm' yields '2007-09-00 14:15:00', with '00' for the day.

Thewizzard - October 2007: Works with MSI K7N2 Delta-ILSR, be sure to use the hwclock.sh script and have it set the time two times.

Spitzbub - December 2007: Works with Biostar NF325-A7, be sure to modify your /etc/init.d/hwclock.sh script (or equivalent) to set the wake-up time again after the --systohc, as described above under Fussy Bios.

Per Olofsson - December 2007: Works very well with Asus P5GC-VM motherboard and Debian lenny with Linux 2.6.22. I don't use the "fussy BIOS" hack since I only suspend the system instead of shutting it down.

KIB - February 2008: Shuttle XPC model SS58G2 / SS58v10, motherboard FS58V10 works with Mythbuntu 7.10, kernel 2.6.22-14. Required BIOS settings - PM Wake Up Events -> IRQ8:enabled, PCIPME:enabled, Powerup by Alarm:disabled. I use /proc/acpi/alarm interface and the patch to hwclock.sh and hwclockfirst.sh is requred as above. Wake on LAN works as well - just add "ethtool -s eth0 wol umbg" to /etc/rc.local .

imcecil - April 2008: Work for Asus P5n-E SLI Gentoo 2.6.24 configured the Kernel as required above but used time_t as the wakeup time format (time since epoch) which seems to work when echoed straight to /sys/class/rtc/rtc0/wakealarm.

Cymen - April 2008: Works great for PCChips P53G but be sure to only have the rtc-cmos module loaded (not the rtc module -- if rtc module is loaded, unload both rtc and rtc-cmos and then load rtc-cmos again and the device will appear in /sys...). Blacklist the rtc module or don't compile it in (the option in under "character drivers" is the one to be excluded).

Moosylog - June 2008: Works fine with MSI RS482M-IL and openSUSE 11.0

Chaup - July 2008: Works with /proc/acpi/alarm on mythbuntu 8.04 running on Lenovo M55E. Had to disable BIOS wakeup for it to work - another fuzzy BIOS. I did update /etc/init.d/hwclock.sh as suggested.

kja999 - July 2008: Worked fine for me using Fedora 9 on an Intel Mac Mini. Use the /sys/class/rtc method ...

piratebab - July 2008: Works fine with debian lenny, kernel 2.6.18 and /proc/acpi/alarm. But with kernel 2.6.25 it dos not work; no /sys/class/rtc/rtc0/wakealarm available, only a /proc/driver/rtc .

bajjisw - August 2008: Wakeup works well with Mythdora 5 on Abit NF7S2, AMD AthlonXP, ATI AIW 9700 Pro for graphics and Aver A180 for tuner. 2.6.25.14-69.fc8 . Had to (1) Disable wakeup by alarm in bios. (2) patch /etc/init.d/halt, per instructions above. (3) Write wakeup time to /proc/acpi/alarm (4) Shutdown. The box wakes up per time set in (3) . October 2008: If you have ntpd running, Do the same changes to /etc/init.d/ntpd. Otherwise, wakeup happens, but BIOS time gets reset.

specto - September 2008: Works on Gentoo 2.6.24 kernel using /sys/class/rtc/rtc0/wakealarm on an Asus M3N-HT Deluxe/HDMI. Did not change BIOS RTC wakeup setting from default of 'disable'. Had to do some time hacking in the wake-up script as system clock is in local time. You can tell if the system thinks it needs to wake up by looking at /proc/driver/rtc - if 'alarm_IRQ' is "yes" then the system should wake up as scheduled. yunosh - Asus M3N78 PRO works fine too.

ronny - works like a charm on Gigabyte GA-MA69GM-S2H using /sys/class/rtc/rtc0/wakealarm on archlinux. Haven't changed any bios settings, neither had to override systohgstra. --Ronny 07:48, 20 November 2008 (UTC)

Gilles - works fine on a ASROCK K7VT2 using /sys/class/rtc/rtc0/wakealarm on mythbuntu kernel 2.6.27. Disabled RTC BIOS settings (they don't seem to be useful unless you want to wakeup your PC on a particular hardcoded time). Had to customize setwakeup.sh so that the wakeup time stays on the same year. If the wakeup time is on the next year, the rtc timer doesn't seem to respond well. --Gilles 19:18, 30 December 2008 (UTC)

zapp - works fine with my FOXCONN A74MX usuing /sys/class/rtc/rtc0/wakealarm on Ubuntu 8.10. RTC has to be disabled as well as HPET --zapp 13:27, 18 Jan 2009 (UTC)


Kroylar 02:03, 23 February 2009 (UTC) - I got this working on gentoo-sources-2.6.26-r3 on an Intel D865PERL motherboard only after applying the patch found on this linux-kernel mailing list entry. This patch has probably already been applied to newer kernels.

Pavol Zibrita 02:25, 21. March 2009 (UTC) - works fine with mythbuntu with kernel 2.6.27-11-generic on MSI's KT4AV-L mainboard. I'm using my machine as a storage server but I don't wanted to run it all the time. I configured the server to start using WOL when I turn on my notebook and I modyfied the check-command to check also if notebook is running or someone is logged in or at last mythshutdown --check is fine. Works great!

Henrik 13:30, 12. May 2009 (UTC) -Gigabyte GA-73PVM-S2H, works fine but needs HPET disabled in BIOS. ABIT I-N73HD works fine. Both boards tested with ubuntu 8.10.

joker4791 20:00, 20. July 2009 (UTC) -Asus P2B-DS Rev. 1.06 D03 works fine with Debian 4.0r3, kernel 2.6.27-6. Undo blacklist for ACPI is needed first, since older revisions of this board have bugs in ACPI-support.

prupert 19.10.09 I use an Intel D945GCLF2, the stuff here was useful, but confusing and didn't tell the full story, I found the most useful and succesful resource for me was: http://ubuntuforums.org/showthread.php?t=1176528 I am however using MythBuntu so that might be why I needed to use that link. For the D945GCLF2 I had to use the settings under Setting alarm when bios clock is in localtime. Thus for the script mentioned in the post, I had to use: SECS=$(date -u --date "$1 $2" "+%s"). Also read through all the comments, as you need to use visudo to add the mythtv user to the sudoers group and also change the settings in mythwelcome from time_t to yyyy-MM-dd hh:mm:ss.

Scary_jeff December 2009. Asus P5Q SE. Worked fine, Ubuntu 8.10.

Jamie S Jan 2010. Asus M2V MX SE. I upgraded from Mythdora 5 to Mythdora 10, which included changing from /proc/acpi/alarm to the new ACPI RTC driver. The new RTC driver did not think my system could wake from S5 using the RTC. After much pain, I built my own kernel with the legacy /proc/acpi/alarm, and now I am happy again...

Avelach January 2010. Asus P3-P5G43 (Intel Core 2 Duo (2x 1GB RAM), GMA X4500). Mythbuntu 9.10 amd64. All OK. No need tweaking BIOS nor hwclock.sh. Need to pull 2.6.33-rc4 kernel because HDMI resolution under Intel does not work under 2.6.31 and wakealarm does not work under 2.6.32!!!

rp_linux Aug 2010. Asus AT3N7A-I (Intel Atom, nvidia ion). Mythbuntu 10.04. Works good. Tried both shutdown and pm-hibernate on dedicated FE/BE using mythwelcome method and recommend using pm-hibernate. Didn't have to tweak BIOS or hwclock.sh.

wild-e Feb 2011. Gigabyte GA-MA78GM-S2H, everything seems to work once I disable HPET. I'm just wondering, what are downsides of disabling HPET, Or are there any. There is an (impropr) patch on the upstream bug link, also wondering i that has any side effects?

danellisuk Jun 2011. Gigabyte GA-MA78LMT-US2H with Ubuntu 11.04. Also fine once HPET disabled in BIOS.

Dschey Aug 2011. Foxconn MB-A7GM-S 785G AM2+ µATX with Mythbuntu 10.04. Have to set option hpet=disable to make wakeup work.

Televiscerator Sep 2012 This will never work with the very old Asus A7N8X mobos (circa 2003/4). The Bios ACPI is broken such that they will only ever wake up if they were put into "Soft-Off" mode from the hardware power button. Shutdown from any operating system (Linux or Windows) does not return them to this soft-off state although leds on the NIC and mobo would have you believe otherwise. Wake up from RTC (or LAN) is then totally disabled.