You are not logged in.

#1 2022-12-31 07:14:19

heyyayyay
Member
Registered: 2022-11-19
Posts: 9

[SOLVED] RTC does not wake up from suspend, but only after >~12 H

Hello,

I use RTC on a daily basis.

RTC will only work if it is set to < ~12 hours. If RTC is set i.e. 20 hours ahead, it will not wake the computer.

[root@minipc ad]# dmesg | grep -i rtc
[    0.244783] PM: RTC time: 06:50:22, date: 2022-12-31
[    0.470318] platform rtc_cmos: registered platform RTC device (no PNP device found)
[    0.578097] rtc_cmos rtc_cmos: RTC can wake from S4
[    0.579019] rtc_cmos rtc_cmos: registered as rtc0
[    0.579196] rtc_cmos rtc_cmos: setting system clock to 2022-12-31T06:50:23 UTC (1672469423)
[    0.579206] rtc_cmos rtc_cmos: alarms up to one month, y3k, 114 bytes nvram

Everything looks fine. Fast startup in Windows 11 is disabled, BIOS is updated and just changed the motherboard battery.

I set RTC with:

echo $(date '+%s' -d "$time") > /sys/class/rtc/rtc0/wakealarm

The problem only started in the last couple of weeks, after updating. Does anyone know how to solve this?

Thank you.

Last edited by heyyayyay (2023-01-03 08:09:25)

Offline

#2 2022-12-31 15:20:11

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,769

Re: [SOLVED] RTC does not wake up from suspend, but only after >~12 H

My first guess would be that the computer is going from 'sleep' mode (suspend to RAM)  to 'hibernate' (suspend to disk) mode after about 12 Hours.

My second guess (if you are running on batteries) is that the sleep mode is still using batteries -- and after 12 hours there is not enough charge left in the batteries to come out of sleep.

heyyayyay wrote:

The problem only started in the last couple of weeks, after updating.

What did you update?  Check your pacman logs or post the last several weeks worth here.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#3 2022-12-31 17:47:20

heyyayyay
Member
Registered: 2022-11-19
Posts: 9

Re: [SOLVED] RTC does not wake up from suspend, but only after >~12 H

ewaller wrote:

My first guess would be that the computer is going from 'sleep' mode (suspend to RAM)  to 'hibernate' (suspend to disk) mode after about 12 Hours.

I do not think it hibernates, as hibernation would require a "full" boot process?

ewaller wrote:

My second guess (if you are running on batteries) is that the sleep mode is still using batteries -- and after 12 hours there is not enough charge left in the batteries to come out of sleep.

It is a stationary, if you by battery mean laptop battery. The system is a Asrock H470 DeskMini, i9-10900, 32 gb. ram, 3 x ssd and with 2 monitors.

The problem has been there before 3 months ago. When it happened then, the computer would not wake up from sleep and would have to manually restart. The problem fixed itself with me keep updating and reinstalling and regenerating grub. It doesn't work this time, have tried removing grub, grub-customizer and reinstalling and regenerating with and without grub-customizer.

cat /var/log/pacman.log

is here

dmesg

is here

journalctl --since="2022-12-20 00:00"

is here

I don't update on a daily or weekly basis, as some problem often arises. My "first" update in a couple of weeks where in the middle of december I think, which is where the problem began. I then updated a couple of times with a few days interval, but stopped when the problem didn't solve itself. I will update again later today and will report back if this solves it.

Also today I added "mem_sleep_default=deep" to boot parameters and enabled a "deep sleep" option in the bios.

Offline

#4 2022-12-31 17:56:25

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,769

Re: [SOLVED] RTC does not wake up from suspend, but only after >~12 H

Do you think this started 12/2 or 12/27?


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#5 2022-12-31 18:09:01

heyyayyay
Member
Registered: 2022-11-19
Posts: 9

Re: [SOLVED] RTC does not wake up from suspend, but only after >~12 H

EDIT: Understand now.

Then def. 12/27. The last time it happened "3 months ago" was november 7th/8th.

Sorry for the confusion, is studying for the exam.

Background: pc wakes me up at 0600 or 0700. Since december classes have been out/sporadically, so there will have been a lot of days when I didn't set the RTC wake.

Last edited by heyyayyay (2022-12-31 18:55:41)

Offline

#6 2022-12-31 18:21:40

heyyayyay
Member
Registered: 2022-11-19
Posts: 9

Re: [SOLVED] RTC does not wake up from suspend, but only after >~12 H

My workaround is to have a local server send a wake-on-lan signal +5 mins of the RTC wake. This way I can see if it suddenly starts working again.

Anyways, the help is much appreciated. Will report back if it starts working.

Offline

#7 2022-12-31 22:57:25

merlock
Member
Registered: 2018-10-30
Posts: 235

Re: [SOLVED] RTC does not wake up from suspend, but only after >~12 H

@heyyayyay...are you allowing that the RTC is (should) be set for UTC time?

Anyway...

Try using rtcwake instead of directly writing to /sys/.

This command will put the machine in S3, and wake it up at 00:01 New Years' Day (EST)

sudo /usr/bin/rtcwake -m mem -t $(date +%s -d 'tomorrow 00:01')

Check it by adding a

-n

flag:

sudo /usr/bin/rtcwake -n -m mem -t $(date +%s -d 'tomorrow 00:01') 
rtcwake: wakeup from "mem" using /dev/rtc0 at Sun Jan  1 05:01:00 2023

Yes, 05:01:00 *is* the correct time for the RTC alarm.


Eenie meenie, chili beanie, the spirits are about to speak -- Bullwinkle J. Moose
It's a big club...and you ain't in it -- George Carlin
Registered Linux user #149839
perl -e 'print$i=pack(c5,(41*2),sqrt(7056),(unpack(c,H)-2),oct(115),10); '

Offline

#8 2022-12-31 23:11:46

seth
Member
Registered: 2012-09-03
Posts: 50,933

Re: [SOLVED] RTC does not wake up from suspend, but only after >~12 H

Fast startup in Windows 11 is disabled

Do you believe that because at some point you disabled it or did you actively check when investigating the issue.
Cause windows keeps re-enabling it and it's super-prone to get you this kind of sh…tuff.

Offline

#9 2023-01-01 01:25:14

heyyayyay
Member
Registered: 2022-11-19
Posts: 9

Re: [SOLVED] RTC does not wake up from suspend, but only after >~12 H

merlock wrote:

are you allowing that the RTC is (should) be set for UTC time?

Yes, it works with a short time frame.

merlock wrote:

sudo /usr/bin/rtcwake -n -m mem -t $(date +%s -d '2023-01-01 01:27')

It doesn't wake up.

sudo /usr/bin/rtcwake -n -m mem -t $(date +%s -d '+2 min')

Doesn't work and

sudo /usr/bin/rtcwake -n -t $(date +%s -d '+2 min')

Doesn't work. Tried with and without kernel parameter mem_sleep_default=deep and deep sleep enabled and disabled in BIOS.

However this worked and the pc woke up +2 min.

echo 0 > /sys/class/rtc/rtc0/wakealarm 
echo $(date '+%s' -d "+2 min") > /sys/class/rtc/rtc0/wakealarm

Here is the difference:

[root@minipc ad]# echo 0 > /sys/class/rtc/rtc0/wakealarm 
[root@minipc ad]# echo $(date '+%s' -d "+2 min") > /sys/class/rtc/rtc0/wakealarm
[root@minipc ad]# cat /sys/class/rtc/rtc0/wakealarm 
1672533945
[root@minipc ad]# sudo /usr/bin/rtcwake -d /dev/rtc0 -n -m mem -t $(date +%s -d '+2 min')
rtcwake: wakeup from "mem" using /dev/rtc0 at Sun Jan  1 01:16:23 2023
[root@minipc ad]# cat /sys/class/rtc/rtc0/wakealarm 
[root@minipc ad]# 

Logs:

dmesg is here

journalctl --since="2022-01-01 00:00"

is here.

seth wrote:

did you actively check

Fast startup is still disabled

Offline

#10 2023-01-01 03:49:52

merlock
Member
Registered: 2018-10-30
Posts: 235

Re: [SOLVED] RTC does not wake up from suspend, but only after >~12 H

heyyayyay wrote:
merlock wrote:

sudo /usr/bin/rtcwake -n -m mem -t $(date +%s -d '2023-01-01 01:27')

It doesn't wake up.

sudo /usr/bin/rtcwake -n -m mem -t $(date +%s -d '+2 min')

Doesn't work and

sudo /usr/bin/rtcwake -n -t $(date +%s -d '+2 min')

Doesn't work. Tried with and without kernel parameter mem_sleep_default=deep and deep sleep enabled and disabled in BIOS.

You keep adding the dry-run flag (it shouldn't suspend at all).

man rtcwake wrote:

-n, --dry-run
       This option does everything apart from actually setting up the
       alarm, suspending the system, or waiting for the alarm.

heyyayyay wrote:
[root@minipc ad]# sudo /usr/bin/rtcwake -d /dev/rtc0 -n -m mem -t $(date +%s -d '+2 min')
rtcwake: wakeup from "mem" using /dev/rtc0 at Sun Jan  1 01:16:23 2023
[root@minipc ad]# cat /sys/class/rtc/rtc0/wakealarm 
[root@minipc ad]# 

And, again you ran the rtcwake command with the -n flag. The first output tells you what it would set to. You don't have anything in the second command, because -n.

When you issue the proper command, your machine will immediately suspend, then wake up when you told it to.


Eenie meenie, chili beanie, the spirits are about to speak -- Bullwinkle J. Moose
It's a big club...and you ain't in it -- George Carlin
Registered Linux user #149839
perl -e 'print$i=pack(c5,(41*2),sqrt(7056),(unpack(c,H)-2),oct(115),10); '

Offline

#11 2023-01-01 09:21:12

heyyayyay
Member
Registered: 2022-11-19
Posts: 9

Re: [SOLVED] RTC does not wake up from suspend, but only after >~12 H

merlock wrote:

When you issue the proper command, your machine will immediately suspend, then wake up when you told it to.

That is correct, yes. It works now. Only tried with +2 min.

Unfortunately rtcwake has no practically meaning for me, as the current "flow" is:
1. I boot the pc and a script is running in the background monitoring a text file with rtc wake up dates
2. the script echoes a time into rtc wake
3. the pc is used
4. I leave the pc, it goes to sleep by default method of KDE
5. the pc wakes up at a time from the text file and performs a command

If using rtcwake, KDE default sleep settings would be overwritten, so that the text file is monitored for rtc wake up dates and then it is rtcwake that issues the sleep command and the command to be run at the specified time is then handled by another script or cron, as far as I understand.

Will try the latter method, but in some time, after I have debugged and updated some more, to see if I can get it back to working (is using the workaround now).

But thanks for the help and input, much appreciated.

Offline

#12 2023-01-01 15:48:36

merlock
Member
Registered: 2018-10-30
Posts: 235

Re: [SOLVED] RTC does not wake up from suspend, but only after >~12 H

heyyayyay wrote:

If using rtcwake, KDE default sleep settings would be overwritten

You could try investigating

-m no

rather than

-m mem

Eenie meenie, chili beanie, the spirits are about to speak -- Bullwinkle J. Moose
It's a big club...and you ain't in it -- George Carlin
Registered Linux user #149839
perl -e 'print$i=pack(c5,(41*2),sqrt(7056),(unpack(c,H)-2),oct(115),10); '

Offline

#13 2023-01-01 16:02:26

heyyayyay
Member
Registered: 2022-11-19
Posts: 9

Re: [SOLVED] RTC does not wake up from suspend, but only after >~12 H

merlock wrote:

You could try investigating

-m no

rather than

-m mem

Have updated my script to use rtcwake with the "-m no" option and it works with +2 min.

Will also keep updating etc., hopefully it solves itself. I'll put a [SOLVED] on the topic after it has run flawlessly for a week or so.

Thanks again.

Offline

Board footer

Powered by FluxBB