2011年1月2日 星期日


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 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 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.

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


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.

關於在 Linux 下做 RTC WakeUp 與自動排程
首先, 自動排程與 Cron or Crontab 有關, 可以參考http://linux.vbird.org/linux_basic/0430cron.php
RTC WakeUp 有兩種, 要先查看 RTC Alarm 是在哪裡
1. /proc/acpi/alarm
2. /sys/class/rtc/rtc0/wakealarm
所以設定 RTC Alarm 有兩種方法, 詳情可以參考以下兩篇文章:
代表設定 40 秒之後發出 alarm,並且同時也會 enable ACPI
所以下面的命令就可以將系統 suspend to memory40 秒後 resume
# echo "+00-00-00 00:00:40" > /proc/acpi/alarm
# echo "mem" > /sys/power/state
要查看支援哪些 suspend mode
# more /sys/power/state
standby mem disk
這個 RTC WakeUp 已經在 GF8100 platform with Ubnutu 8.04.01  測試 OK!!
我們可以透過 ACPI 提供的 interface,設置 RTC alarm,如此在 alarm 發出 IRQ 時,ACPI 就會 resume systemEPC 中的 genrtc module 並不支援 alarm interrupt。如果手動加入 rtc module,雖然它有支援 alarm interrupt,但是透過 rtc module 來設 alarm,與透過 ACPI interface 的差別就在於,ACPI 是否有 enable event
我們可以看看 kernel source 中,driver/acpi/sleep/proc.c
acpi_system_write_alarm 這個 function,設定 RTC alarm 之後,還會做這一行
acpi_enable_event(ACPI_EVENT_RTC, 0);
單獨透過 rtc module 是不會跑這行的。

要查看支援哪些 suspend mode
# more /sys/power/state
standby mem disk
它們分別代表 S1 S3 S4
這種方式可以用軟體來做 suspend-resume 的測試。它和 suspend 後按 power button resume 的原理不盡相同。因為 power button 的訊號是透過 GPIO 接到 EC,然後再透過 LPC 來通知南橋。RTC 本身就在南橋內了,並無透過 EC
kernel 2.6.22 之後,ACPI 改用另一個 interface 來取代 /proc/acpi/alarm。相關資訊,請參照

後來在網路上找到一篇有用的文章「ACPI Wakeup 」裡面有說明如何設定定時從S1/S3回來。 我是在SLES11上試了Suspend to RAM WakeAlarm Timer 的簡單方法, 參考裡面的範例把喚醒的時間設為1分鐘...試完之後結果真的可以呢~ 超高興, 系統會在時間到時自動的被叫起來 :D
echo 0 > /sys/class/rtc/rtc0/wakealarm
echo `date '+%s' -d '+ 1 minutes'` > /sys/class/rtc/rtc0/wakealarm
12步驟主要是在歸零和設定定時, 進入S3 (Suspend to RAM) 主要是第3個命令, 如果要進入S1只要換這命令就好了, 1&2步不用動, 以這個script再配上shell loop 就可以做長時間的測試啦。
[*] Software Suspend (EXPERIMENTAL)  (y)
支援系統suspend(休眠),打開這項功能後, 可用swsusp或者shutdown -z 來掛起系統. 這樣系統會將你當前正在進行的工作(也就是當前記憶體中的內容)作成一個鏡象保存到你的交換分區中, 在你下一次啟動時使用啟動參數"resume=/dev/交換分區".內核就會將上一次的工作內核從鏡象檔中恢復到記憶體,這可以大大提高系統的啟動速 度. 當你不想恢復上次的工作時向內核傳遞參數“noresume".不過系統啟動後你的交換分區將不可以使用, 你可以使用mkswap命令來重新格式化你的交換分區. 這個功能不需要高級電源管理的支援.

17 則留言:

  1. Fantastic beat ! I would like to apprentice even as you amend your website, how
    could i subscribe for a weblog site? The account aided me a acceptable deal.
    I have been a little bit familiar of this your broadcast offered bright clear idea

    my page; bigger breasts without

  2. It's very straightforward to find out any topic on web as compared to textbooks, as I found this paragraph at this website.

    Look at my webpage: ideal waist to height ratio

  3. Terrific article! That is the kind of information
    that should be shared around the net. Shame on Google for no longer positioning this put up higher!

    Come on over and consult with my site . Thanks =)

    Also visit my webpage Waist to height Ratio ranges

  4. Hi, after reading this awesome post i am too happy to share my experience here with mates.

    Also visit my weblog waist to height ratio

  5. I love your blog.. very nice colors & theme. Did you make this website yourself or did you
    hire someone to do it for you? Plz answer back as I'm looking to construct my own blog and would like to know where u got this from. many thanks

    Review my web-site http://zetaclear.herbalcurenow.com/blog/treatments-nail-fungus

  6. Good article. I absolutely appreciate this site.
    Continue the good work!

    Look into my blog post virility exercise

  7. Piece of writing writing is also a excitement, if you be acquainted with then you can write if not
    it is difficult to write.

    Here is my page provacyl

  8. It's an remarkable piece of writing for all the online users; they will take benefit from it I am sure.

    Also visit my site; Breast Actives Exercise Program

  9. Good day! I just want to offer you a huge thumbs up for your excellent info you have
    here on this post. I'll be returning to your blog for more soon.

    Here is my blog post; natural male enhancement products

  10. What's up, its nice paragraph regarding media print, we all be aware of media is a wonderful source of facts.

    My web site :: natural gain plus

  11. Incredible! This blog looks just like my old one! It's on a entirely different subject but it has pretty much the same page layout and design. Great choice of colors!

    Visit my page http://www.strategic-workplace-solutions.com/

  12. It's amazing for me to have a web site, which is good for my knowledge. thanks admin

    Check out my website ... performer5

  13. I got this web site from my pal who told me regarding this website and now this time I am
    browsing this web page and reading very informative articles or reviews at this place.

    my web site; plantar fasciitis treatment

  14. I'm curious to find out what blog system you are working with?
    I'm having some minor security issues with my latest blog and I would like to find something more
    secure. Do you have any suggestions?

    Feel free to visit my weblog :: victoria's secret pure seduction body spray

  15. Hello, i think that i saw you visited my web site thus i came
    to “return the favor”.I'm trying to find things to enhance
    my web site!I suppose its ok to use a few of your ideas!!

    Here is my blog - evolution battle for Utopia hack

  16. Amazing blog! Do you have any recommendations for aspiring
    writers? I'm planning to start my own site soon but I'm a little
    lost on everything. Would you propose starting with a free platform like Wordpress or go for a paid option? There are so
    many options out there that I'm completely confused
    .. Any suggestions? Many thanks!

    Also visit my weblog clash of clans hack

  17. Oh my goodness! Awesome article dude! Thank you, However I amm going through troubles with your RSS.
    I don't know why I cannot join it. Is there anyhody having identical
    RSS issues? Anybody who knows thhe answer can you kindly
    respond? Thanks!!

    My weblog; basketball gears For Men