View unanswered posts    View active topics

All times are UTC - 6 hours





Post new topic Reply to topic  [ 27 posts ] 
Go to page 1, 2  Next

Print view Previous topic   Next topic  
Author Message
Search for:
PostPosted: Sun Dec 02, 2007 9:24 am 
Offline
Joined: Wed Dec 10, 2003 8:31 pm
Posts: 1995
Location: /dev/null
Intro
This page describes the steps needed to get ACPI Wakeup running in conjunction with Mythwelcome on your KM box. Together they will automatically boot your machine prior to a scheduled recording and then shutdown your machine when not in use after a specified time thus saving power and insuring you never miss a show. This of course assumes RTC wakeup alarms are supported in the BIOS of your motherboard. You'll be hard pressed to find a modern motherboard that doesn't support this option. I'm using an old A7N8X-VM that's from 2003 and it works on it.

Using Mythwelcome
As I mentioned, the scripts that drive the shutdown/startup work in conjunction with Mythwelcome which maybe unfamiliar to some users. Here is my nickel tour of mythwelcome:

Image

As you can see, mythwelcome shows some basic info, like data/time, current status of the frontend and in this case a countdown until it shuts the machine off, and the next scheduled recording. It also lets you know if there are any conflicts (although this isn't depicted in the screenshot above), and may display additional info that I haven't seen too.

Aside from starting the frontend like the only button shows, you can also hit the menu button (the M key on the keyboard) if you want to manually force a shutdown, lock the auto shutdown feature or exit to your KM desktop. To me, that lock feature is little redundant since all you need to do is leave your frontend running and none of the auto shutdown stuff will happen -- remember auto shutdown only happens when mythwelcome is running.

Hit the info button (the I key on the keyboard) if you want to make mythwelcome automatically start your frontend instead of starting itself which will cause it to ignore the auto shutdown option until you manually exit the frontend. I have this set only because if I manually turn the mythbox on, I will very likely be there to hit the "start mythfrontend" button which as I mentioned disables the auto shutdown. I should add that mythwelcome is smart enough to know if other frontend machines on your network are hitting the backend server; in this case, it will not shutdown unless the frontend machine(s) is finished using the backend (i.e. you stop it or place it in its own mythwelcome).

Credit Where Credit is Due
Nearly all the content below came from fra's post here. Credit also goes to spalVl who helped me get this working with my "fussy BIOS". I merely distilled out the information from these posts (and a few other sources) and put the HOWTO together based on my experience enabling this cool and powerful feature.

Look for RTC Wakeup in Your BIOS
First thing you want to do is see if your BIOS is configured to accept ACPI wakeup commands. Each BIOS is different. Mine for example functions with the RTC Wakeup feature disabled! Look around in your BIOS for a section entitled, "Power Savings" or "Advanced Power Management" etc. for something like, "RTC Alarms" or "RTC Wakeup."

Image

You can set enable it or leave it set to whatever it is currently set to and simply test to see if it works as-is before you actually change the setting. Mine actually requires you to setup a date in the BIOS for it to boot if you enable it; again, I have mine set to "disable" and ACPI Wakeup still works.

Testing ACPI Wakeup Before Modifying Your KM Box
Assuming you have a functional KM install (guide was written and tested with R5F27), test your computer's ability to boot via an RTC alarm from a shell. Simply type:

Code:
$ cat /proc/acpi/alarm
2007-00-00 14:10:00


As you can see, my system returned the current year and GMT current time (since this option is disabled, there is no day or month). Your response may vary. If you get an error here, your hardware likely doesn't support ACPI Wakeup OR you actually have to go into the BIOS and enable the option.

If you did get a response similar to the one I got, setup the box to reboot in say 4 minutes by doing this:

Code:
# echo "2007-12-02 14:14:00" > /proc/acpi/alarm


Obviously, you'll need to substitute the current time and date in your case! Now when you re-cat the /proc/acpi/alarm, it should answer with this time you entered:

Code:
$ cat /proc/acpi/alarm
2007-12-02 14:14:00


Now you just need to shutdown your machine and wait the four minutes. (In case you don't know, you can shutdown via this command):
Code:
# shutdown -h now


If it successfully boots, your BIOS is correctly setup. If unsuccessful, you may need to fiddle with some BIOS settings as described above. If it continues to fail, your hardware might not support this and you can consider using the alternative nvram-wakeup method described on this wiki page.

Enable Mythwelcome
After you complete these steps, your box will boot to Mythwelcome. From there you can start the frontend. For the ACPI wakeup to work, you must exit your frontend and allow mythwelcome to handle everything including manually shutting down your box. If you manually enter a shutdown command, or shutdown the box from the frontend menu, you risk the machine not booting automatically (this depends on whether or not your recording schedule has changed since the last time the shutdown scripts ran).

To setup mythwelcome, simply modify your .fluxbox/apps:

Code:
$ nano /home/mythtv/.fluxbox/apps


And comment out the current line that reads "[startup] {KnoppMyth-run}" simply by putting a number sign (#) in front of it. Now under that line, type the following, "[startup] {mythwelcome}" and save the file (ctrl-x).

Here is what that section in mine looks like for your reference:

Code:
#[startup] {mythfrontend}
[startup] {mythwelcome}


Now we'll configure mythwelcome via this command:
Code:
 $ mythwelcome --setup


Make the following changes so it looks like this and then exit:

Image

Code:
nvram-wakeup Command: /usr/bin/setwakeup.sh
nvram-wakeup Restart Command: leave blank
Command to reboot: sudo shutdown -h now
Command to shutdown: sudo shutdown -h now
Command to run Xterm: xterm
Command to run to start the Frontend: KnoppMyth-run


For reference, here is the R5F27 defaults in case you want to revert to them:

Image

Configure Mythtv to RTC Write Alarms
We'll now make the script that does all the heavy lifting as follows:
Code:
# touch /usr/bin/setwakeup.sh
# nano /usr/bin/setwakeup.sh


You'll need to copy/paste the following into your nano window, then save the script (ctrl-x):
Code:
#!/bin/bash

# Script to set wakeup time using acpi alarm
# Called from mythwellcome:
# first option passed from mythwelcome is --settime second is seconds since 1970

# Convert from stupid time in seconds since 1970
datum=$(/bin/date -d "1970-01-01 UTC $2 sec" +%F\ %T\ %z)

# Reinterpret this in utc and write to alarm
utcdatum=$(/bin/date -u -d "$datum" +%F\ %T)

# Write wakeup time to acpi alarm
echo $utcdatum>/tmp/alarm   # Then, /etc/init.d/hwclock.sh is modified to read this file


Now set the permissions and make it a script as follows:

Code:
# chmod +x /usr/bin/setwakeup.sh
# chmod 755 /usr/bin/setwakeup.sh


Modify the hwclock.sh
Next, we'll modify /etc/init.d/hwclock.sh to make it set the alarm. Before modifying any existing file it is good practice to ALWAYS make a backup in case you mess it up.

Code:
# cp /etc/init.d/hwclock.sh /home/mythtv/hwclock.sh_virgin


Now you can safely edit the live file knowing that you can always restore it from this file you just created.

Code:
# nano /etc/init.d/hwclock.sh


Now do a search (ctrl-w) for a line that contains the phrase:

Code:
clock will not be carried across reboots


Position your cursor UNDER that line and paste in the following:

Code:
ACPITIME=`cat /tmp/alarm`

Notice those aren't quotation marks!

Now do a second search (ctrl-w) for a line that contains the phrase:

Code:
verbose_log_action_msg "Hardware Clock


Position your cursor UNDER that line and paste in the following:

Code:
echo "$ACPITIME" > /proc/acpi/alarm


That should be it. Save the file and exit.

Optional Section - Use only if the Above Doesn't Work
You may have to also add the following if the above modification doesn't work for you (this has been taken from the "fussy BIOS" section of the ACPI Wakeup page on the mythtv wiki, and from spalVl's post here. Again do NOT do it now, but if after you complete the next steps and your mythbox doesn't startup on its own, THEN come back here and add this additional info to your /etc/init.d/hwclock.sh

Again, from with nano, go to the end of your /etc/init.d/hwclock.sh where you should see the following line:

Code:
hwclocksh "$@"


Now directly ABOVE it, paste in the following 15 lines:

Code:
ACPITIME=`cat /proc/acpi/alarm`
                if [ "$HWCLOCKACCESS" != no ]
                then
                    if [ "$VERBOSE" != no ]
                    then
                        echo "Saving the System /etc/init.d/hwclock.shClock time to the Hardware Clock..."
                    fi
                    [ "$GMT" = "-u" ] && GMT="--utc"
                        /sbin/hwclock --systohc $GMT $BADYEAR
                    if [ "$VERBOSE" != no ]
                    then
                        echo "Hardware Clock updated to `date`."
                    fi
echo "$ACPITIME" > /proc/acpi/alarm


Now save your file and exit (ctrl-x)

Reconfigure Mythtv
First exit your frontend. Now stop the masterbackend and re-run mythtv-setup:

Code:
$ /etc/init.d/mythtv-backend stop
$ mythtv-setup


Now to go General>5th page and configure as follows:

Image

Blank out your Startup command and place a check in the check box. The next three settings can be whatever you like. These are just what I'm using. The final four settings need to be as described:

Code:
Wakeup time format: yyyy-MM-dd:hh:mm
Set wakeuptime command: sudo mythshutdown --setwakeup $time
Server halt command: sudo mythshutdown --shutdown
Pre-shutdown command: sudo mythshutdown --check


For reference, here is the R5F27 defaults in case you want to revert to them:

Image

Save the settings and exit mythtv-setup.
Now restart your backend with this command:
Code:
# /etc/init.d/mythtv-backend start


Restart X to insure that mythwelcome starts using this command:

Code:
$ pkill xinit


If everything worked right, your machine should have restarted X and you should see Mythwelcome.

That's it!

_________________
Retired KM user (R4 - R6.04); friend to LH users.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 03, 2007 3:33 pm 
Offline
Joined: Sun Nov 13, 2005 5:56 pm
Posts: 83
I love these HOWTOs. Great work.
I'd just like to mention that if one can not get the ACPI wakeup to work, check that the +5VSB is capable of delivering enough current in standby. I had this problem and it took a while to figure it out. This can easily happen when building a KM box out of spare parts.

-s-


Top
 Profile  
 
 Post subject: possible error
PostPosted: Wed Dec 19, 2007 10:39 pm 
Offline
Joined: Sat Oct 29, 2005 6:57 am
Posts: 176
Excellent write up. Thanks.
I don't know if this is an error or a normal message. When I type in setwakeup.sh from command line I get the following message.

/usr/bin/setwakeup.sh: line 17: /tmp/alarm: Permission denied

Any suggestions on its meaning.

rkshack

_________________
5.5
6150k8ma-8ekrs
Athlon64 3200+
1gb ram
250gb hda
750gb sda
nvidia 6200
central time


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 19, 2007 11:42 pm 
Offline
Joined: Mon May 10, 2004 8:08 pm
Posts: 1891
Location: Adelaide, Australia
Try changing to the root user first
Code:
su -


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 20, 2007 1:34 am 
Offline
Joined: Wed Dec 10, 2003 8:31 pm
Posts: 1995
Location: /dev/null
What he said :)

_________________
Retired KM user (R4 - R6.04); friend to LH users.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 20, 2007 8:13 am 
Offline
Joined: Sat Oct 29, 2005 6:57 am
Posts: 176
I did it under root and got a different permission error. I will post the results when I get home.


Correction: I thought that I had changed over to root and received an error. I guess I was mistaken because when I tried it tonight I did not receive the error. Thanks for the help

Rkshack

_________________
5.5
6150k8ma-8ekrs
Athlon64 3200+
1gb ram
250gb hda
750gb sda
nvidia 6200
central time


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 08, 2008 2:19 pm 
Offline
Joined: Mon Apr 23, 2007 1:45 pm
Posts: 389
Location: Fargo, ND, USA
I should have posted this six months ago. I worked on this on and off for over two years trying to get my machine to "manually Wake-up" before I made any other changes. One day out of frustration I installed it and it just worked. graysky has all the R5F27 defaults screens shown so if you bomb you can just back out of it.

Even now I manually can not get my motherboard to wake up. But it works great completely installed.

Motherboard ASUS K8N-E

graysky Thanks for your post
TVBox

_________________
TVBox
LinHES R8.4


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 15, 2008 9:58 pm 
Offline
Joined: Thu Sep 27, 2007 5:44 pm
Posts: 336
Generally speaking, this has been working for me. It starts up as it's supposed to and so on and so forth. But sometimes it gets "stuck" where mythwelcome shows "MythTV is idle" but it never starts the countdown. I have a screenshot here:

Image

I have the box unchecked for "Block shutdown before client connected". Actually, here is a screenshot of the settings on the backend:
Image

and my mythwelcome settings:
Image

For now I will just shut it down manually, but if anybody knows why it might be stuck in idle without counting down, I'd sure like to know. It only happens sometimes :roll:

Edit: at 11:00 pm sharp it suddenly started the countdown at 600 like it should have done 20 minutes before that. Does it only start the countdowns on the hour and half past the hour or something bizarre like that?

Image


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 23, 2008 1:24 pm 
Offline
Joined: Fri May 23, 2008 1:20 pm
Posts: 1
Thanxs :D


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 31, 2010 9:53 am 
Offline
Joined: Wed May 12, 2004 1:13 am
Posts: 82
Location: Germany
Hey Guys, is this still up to date?
I am trying to get acpi wakeup running in my R6.02 Setup.

Is there something newer than this? Or is this still working?

_________________
LinHES R6 on:
MSI K8T Neo2-F & Athlon-64 3200 - 4096 MB RAM
GeForce 8600GT
Mystique CaBiX-C2, PVR-350, PVR-250, Terratec CinergyT² & DBOX2


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 04, 2010 6:22 pm 
Offline
Joined: Thu Sep 27, 2007 5:44 pm
Posts: 336
wulf wrote:
Hey Guys, is this still up to date?
I am trying to get acpi wakeup running in my R6.02 Setup.

Is there something newer than this? Or is this still working?


I think I used the following link on the Wiki:
http://www.knoppmythwiki.org/index.php?page=Mythwelcome


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 04, 2010 8:50 pm 
Offline
Joined: Mon Aug 14, 2006 8:24 pm
Posts: 295
Location: Melbourne, Australia
Both are now out of date for R6, it is now much simpler. There is no need to modify ~.fluxbox /apps as this can be done from the menu and the date format has changed. The procedure I used is as follows:

Service Menu>LinHES>System Type> tick Run Welcome

Mythwelcome –-setup
Change Command to Set Wakeup Time to Sudo sh -c “/usr/local/bin/mythwelcome-set-alarm.sh $time”
Remove nvram-wakeup Restart Command
Command to start Frontend /usr/bin/mythfrontend -l /var/log/mythtv/mythfrontend.log"

Mythtv-setup (alt s)>1.General>page 5
Startup before rec: = 300
Wakeup time format:yyyy-MM-ddThh:mm:ss
Command to set Wakeup Time: /usr/bin/mythshutdown --setwakeup $time
Server Halt Command: sudo /usr/bin/mythshutdown --shutdown
Pre-shutdown Check Command: /usr/bin/mythshutdown –-check"

I found after doing this that a command would reappear in the nvram-wakeup Restart Command box which I would have to re-delete. After that it works fine.

The new settings are discussed here

_________________
Intel DG965WH, Dvico DVB-T Lite x2, HDHR, Gigabyte GT220, KingstonSSD, WD20EARS R8.4.3


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 05, 2010 12:04 am 
Offline
Joined: Wed May 12, 2004 1:13 am
Posts: 82
Location: Germany
THX, I`ll try that at home tonight...

Not that easy to find the newest information about that toppic...

CU Mr.Gosh

_________________
LinHES R6 on:
MSI K8T Neo2-F & Athlon-64 3200 - 4096 MB RAM
GeForce 8600GT
Mystique CaBiX-C2, PVR-350, PVR-250, Terratec CinergyT² & DBOX2


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 06, 2010 2:32 am 
Offline
Joined: Wed May 12, 2004 1:13 am
Posts: 82
Location: Germany
I am following your guide now, but some things are a bit different, so I write what I had to do:

Service Menu>LinHES>System Type> tick Run Welcome

mythwelcome –-setup

Change Command to Set Wakeup Time to
sudo sh -c “/usr/LH/bin/mythwelcome-set-alarm.sh $time”
Remove nvram-wakeup Restart Command
Command to start Frontend
/usr/bin/mythfrontend -l /var/log/mythtv/mythfrontend.log

Mythtv-setup (alt s)>1.General>page 5
Startup before rec: = 300
Wakeup time format:yyyy-MM-ddThh:mm:ss
Command to set Wakeup Time: /usr/bin/mythshutdown --setwakeup $time
Server Halt Command: sudo /usr/bin/mythshutdown --shutdown
Pre-shutdown Check Command: /usr/bin/mythshutdown –-check"


So I'll do a testrun now.

_________________
LinHES R6 on:
MSI K8T Neo2-F & Athlon-64 3200 - 4096 MB RAM
GeForce 8600GT
Mystique CaBiX-C2, PVR-350, PVR-250, Terratec CinergyT² & DBOX2


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 08, 2010 9:02 pm 
Offline
Joined: Mon Aug 14, 2006 8:24 pm
Posts: 295
Location: Melbourne, Australia
The only differences I can see are the quotation marks which were inserted when I cut and paste via this windows machine. I should have checked a bit closer.

I noticed in your version you still have a quotation mark at the end of the Pre-shutdown Check Command which should not be there.

_________________
Intel DG965WH, Dvico DVB-T Lite x2, HDHR, Gigabyte GT220, KingstonSSD, WD20EARS R8.4.3


Top
 Profile  
 

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 27 posts ] 
Go to page 1, 2  Next



All times are UTC - 6 hours




Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group

Theme Created By ceyhansuyu