nicnic
Posts: 3
Joined: Wed Apr 11, 2018 2:27 am

rtcwake: /dev/rtc0 not enabled for wakeup events

Wed Apr 11, 2018 3:12 am

Hello all!

I am trying to setup rtcwake commands to stop/start the system on a RaspberryPI 3B hardware, with Jessie updated, using a "DS 3231" module (actually I tried 2 different RTC type of modules that are behaving the same way).

The clock/timing part works properly.

When issuing the command below, I got these errors:

Code: Select all

sudo rtcwake -m mem -s 60
rtcwake: cannot open /sys/class/rtc/rtc0/device/power/wakeup: No such file or directory
rtcwake: /dev/rtc0 not enabled for wakeup event[/i]

I checked for solutions to fix this on the net; however I did not find anything solved, even though the error can be found in several posts over the years. Some of the posts are for older versions of the OS that are built slightly differently than the latest version of Jessie and being a newbie with the Linux OS settings I having a hard time to fix this.

Any suggestions would help.

epoch1970
Posts: 7262
Joined: Thu May 05, 2016 9:33 am
Location: France

Re: rtcwake: /dev/rtc0 not enabled for wakeup events

Fri Apr 13, 2018 12:06 pm

The Pi never sleeps, its power modes are either on or off. So there is no point waking it from RTC and no device/driver for that.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

nicnic
Posts: 3
Joined: Wed Apr 11, 2018 2:27 am

Re: rtcwake: /dev/rtc0 not enabled for wakeup events

Sat Apr 14, 2018 12:44 am

epoch1970 Thank you for your reply.

The problem was that I used rctwake and “-m mem”, that is not supported by PI, as the state triggered with the mem flag is not ON or OFF.
Then probably the solution is to stop PI completely at a defined time of the day (probably using cron) and set the RTC device (I intend to use ZS-042 with DS3231) through a predefined alarm, to trigger the PI to start.
I am able now to setup properly the alarm date/time in the DS3231 from PI, and those settings are accessible in PI.

Now I have to figure out how to use the alarm.
My understanding is that the alarm is accessible on the INT/SQW pin of the DS.
I do not know yet how to setup, from PI, the pin to output the alarm signal instead of a square wave (optional setting).

The plan is to control the RUN pins to restart PI: I think that bringing programmatically that pin from High to Low (short period) and back to High, would do the trick.

Alternate solution is to use a different library for the DS3231.
This solution is more controllable, however I have to start almost from scratch and I need to interface with an Arduino for programing.
I found several posts that I have to read about this approach.

I am still open to suggestions as what I am planning might not work.

andrum99
Posts: 1555
Joined: Fri Jul 20, 2012 2:41 pm

Re: rtcwake: /dev/rtc0 not enabled for wakeup events

Sat Apr 14, 2018 12:20 pm

To clarify - all models of Raspberry Pi are either on or off - there is no way of powering them down to a "sleep" mode. In fact, when you "power off" the Pi from within the operating system, what it actually does is reboot with a special reason code that tells the firmware to stop and do nothing (and not attempt to load an operating system). The only way to actually power off a Pi is therefore to stop supplying it with power, either by disconnecting the cable or some other method.

nicnic
Posts: 3
Joined: Wed Apr 11, 2018 2:27 am

Re: rtcwake: /dev/rtc0 not enabled for wakeup events

Sat Apr 14, 2018 1:40 pm

Thank you for the extra clarification. I got the fact that I cannot put the PI in "sleep" mode. What I want is to shutdown the OS; something like below done in cron. I did this from the terminal prompt and it works.

Code: Select all

 30 11 * * 1-5 /sbin/shutdown -h now 
After the above command is completed, PI will still be powered and has the RUN pin status High. By putting that pin to ground (tried and it works) or providing a puls: from High to Low and Back to High (need to achieve), will restart to OS.

What I would like next, is to restart the OS using the alarm signal from the RTC (DS3231). I have the RTC with the time set and maintained, and also the alarm set and working.
What I need to figure out next is:
  • if I can integrate the existing alarm provided by the RTC with minimal changes (mostly a transistor if needed) to the RUN pin of the PI; or
  • probably it would be safer (as I do not have an oscilloscope to visualize the alarm) to load a new library on the DS3231, creating the program to do the: time maintenance, alarm setting and the alarm puls format that will fit the PI RUN pin expected behaviour needed to restart the OS. This is the longer path as it involves an Arduino and testing the new code. Most of this functionality is already created and shared on the net.
I will start with experimenting the first option and keep you posted; I hope that I will not corrupt my OS card or ruin the PI :( .

User avatar
DougieLawson
Posts: 41898
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: rtcwake: /dev/rtc0 not enabled for wakeup events

Sat Apr 14, 2018 2:32 pm

nicnic wrote:
Sat Apr 14, 2018 1:40 pm
What I would like next, is to restart the OS using the alarm signal from the RTC (DS3231). I have the RTC with the time set and maintained, and also the alarm set and working.
What I need to figure out next is:
  • if I can integrate the existing alarm provided by the RTC with minimal changes (mostly a transistor if needed) to the RUN pin of the PI; or
  • probably it would be safer (as I do not have an oscilloscope to visualize the alarm) to load a new library on the DS3231, creating the program to do the: time maintenance, alarm setting and the alarm puls format that will fit the PI RUN pin expected behaviour needed to restart the OS. This is the longer path as it involves an Arduino and testing the new code. Most of this functionality is already created and shared on the net.
I will start with experimenting the first option and keep you posted; I hope that I will not corrupt my OS card or ruin the PI :( .
That is impossible without external hardware. When it's shutdown there's nothing left running on your RPi to read any signal from any RTC.

http://www.uugear.com/product/wittypi2/
Languages using left-hand whitespace for syntax are ridiculous

DMs sent on Twitter/LinkedIn will be answered next month.
Fake doctors - are all on my foes list.

The use of crystal balls and mind reading is prohibited.

henni2
Posts: 1
Joined: Sun Sep 16, 2018 10:11 pm

Re: rtcwake: /dev/rtc0 not enabled for wakeup events

Sun Sep 16, 2018 10:22 pm

The kernel overlay "ds3107.ko" (?), instantiated by "/boot/config.txt" entry "dtoverlay=i2c-rtc,ds3231,wakeup-source", doesn't create the right paths for rtcwake.
You have "/sys/class/rtc/rtc0/wakeup" file where you can set (echo | sudo tee) or read (cat) the next event by an ASCII integer epoch time (seconds since 1970-1-1). Easier to use in conjunction with date command.
However, rtcwake refers to /sys/class/rtc/rtc0/device/power/wakeup which is not available.
This seems to be one more bug in Raspbian distribution we have to deal with.

epoch1970
Posts: 7262
Joined: Thu May 05, 2016 9:33 am
Location: France

Re: rtcwake: /dev/rtc0 not enabled for wakeup events

Mon Sep 17, 2018 6:40 pm

henni2 wrote:
Sun Sep 16, 2018 10:22 pm
However, rtcwake refers to /sys/class/rtc/rtc0/device/power/wakeup which is not available.
This seems to be one more bug in Raspbian distribution we have to deal with.
Perhaps you could read the thread before posting...
The platform (the Pi) provides no "sleep" power mode. No driver can implement sleep or wake on this machine. So there can be no "wakeup" entry in /sys/class/rtc/ (Sysfs)

If you want to shut down and power up your Pi, you need an externally powered, independent device.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

danjperron
Posts: 3890
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: rtcwake: /dev/rtc0 not enabled for wakeup events

Mon Sep 17, 2018 10:56 pm

I did used a RTC to power UP and shutting down and Raspberry PI. I had to used an DC/DC converter to fully power down the Pi. But the RTC wake up the PI when it enables the power on the DC/DC converter.

https://www.raspberrypi.org/forums/view ... 5#p1074313

bablokb
Posts: 27
Joined: Fri Nov 07, 2014 7:45 am

Re: rtcwake: /dev/rtc0 not enabled for wakeup events

Sat May 23, 2020 12:31 pm

Hi,

I know this is an old thread, but wake from rtc is possible (tested on a pi-zero with raspbian-buster 02-2020):

Add the following line to /boot/config.txt (choose your pins):

Code: Select all

dtoverlay=i2c-rtc-gpio,ds3231,i2c_gpio_sda=17,i2c_gpio_scl=27,wakeup-source
Then connect your DS3231 with 3V3, GND, SDA->GPIO17, SCL->GPIO27 and the INT/SQW-pin of the RTC with GP03. Reboot.

Add an alarm (as root):

Code: Select all

echo "$(date -d 'now + 5 minutes' +%s)" > /sys/class/rtc/rtc0/wakealarm
and check it:

Code: Select all

cat /proc/driver/rtc
rtc_time        : 11:42:35
rtc_date        : 2020-05-23
alrm_time       : 11:47:33
alrm_date       : 2020-05-23
alarm_IRQ       : yes
alrm_pending    : no
update IRQ enabled      : no
periodic IRQ enabled    : no
periodic IRQ frequency  : 1
max user IRQ frequency  : 64
24hr            : yes
Halt your system and wait for five minutes. The system will happily boot :D After the reboot the alarm is removed automatically. Note that the time-horizon of the DS3231 is about a month. Also note that not every cheap DS3231 breakout will provide the INT/SQW pin.

The magic is that GP03 will always start the system when pulled to GND. And the DS3231 will pull the INT to GND when the alarm fires. I have found no way to change the pin to something else, but there is a "run"-pin which is not populated which should also work (but I did not test that). GP03 is hardware I2C, if you need that, you could activate some alternate function for some other i2cX bus.

You don't even need a backup battery for this, because after shutting down your Pi it will still provide power on the 3V3 and 5V rails. So this is not a solution for battery based systems. If you really need to bring current consumption down to zero, you need a different solution, for example you can connect the INT of the rtc to a MCU which uses a mosfet to turn power on.

Bernhard

danjperron
Posts: 3890
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: rtcwake: /dev/rtc0 not enabled for wakeup events

Sat May 23, 2020 1:26 pm

Yes two year old.

How much current the Pi uses on shutdown compare to my system (the post just before)?

I think the avantage of my system is that I could use a 12V battery and don't care about the 5V regulator since I controlled de regulator.

Daniel

bablokb
Posts: 27
Joined: Fri Nov 07, 2014 7:45 am

Re: rtcwake: /dev/rtc0 not enabled for wakeup events

Mon May 25, 2020 9:54 am

danjperron wrote:
Sat May 23, 2020 1:26 pm
How much current the Pi uses on shutdown compare to my system (the post just before)?
Power consumption mainly depends on peripherals. My post was not so much about bringing power consumption to zero, but to show that you can wake-up a Pi with a RTC and no additional circuits. To quote myself:
If you really need to bring current consumption down to zero, you need a different solution
I think your solution is fine, you can find a different solution here: https://github.com/bablokb/pi-wake-on-rtc which doesn't even need a DC/DC converter. A more generic solution, where you can use any external signal (not just a wake-alarm of a RTC) to start a Pi, is a special hat we designed (https://github.com/bablokb/pi-pic-proto-hat). The example given for this hat just uses buttons, but it also works fine with a RTC (or a motion sensor, see https://github.com/bablokb/pi-infoscreen/).

Bernhard

tahunasky
Posts: 20
Joined: Tue Jan 12, 2021 3:41 am

Re: rtcwake: /dev/rtc0 not enabled for wakeup events

Tue Jan 12, 2021 4:18 am

bablokb wrote:
Sat May 23, 2020 12:31 pm

Code: Select all

cat /proc/driver/rtc
rtc_time        : 11:42:35
rtc_date        : 2020-05-23
alrm_time       : 11:47:33
alrm_date       : 2020-05-23
alarm_IRQ       : yes
alrm_pending    : no
update IRQ enabled      : no
periodic IRQ enabled    : no
periodic IRQ frequency  : 1
max user IRQ frequency  : 64
24hr            : yes
Bernhard

I am wanting to use wakealarm (I have a raspberry pi 4B downloading data from a solar inverter once a day), and have followed @Bernhard instructions above. I am using a DS3231 rtc with battery that I got off aliexpress.

When I "cat /proc/driver/rtc" shows alarm is set similar to output above with correct alarm time... however it hasn't started the pi 4B.
The rtc is setting the pi's time on boot and if i disconnect from wifi and unplug from electricity for 12 hours, when I start the pi without internet/network connection time if correct.
I have removed fake hwclock software, nothing is being loaded in /etc/modules

lsmod | grep rtc shows

rtc_ds1307 35864 0
regmap_i2c 16384 1 rtc_ds1370

dmesg | grep rtc shows

[ 12.883978] i2c-gpio i2c-gpio-rtc@0: using lines 17 (SDA) and 27 (SCL)
[ 13.848581] rtc-ds1307 11-0068: 'wakeup-source' is set, request for an IRQ is disabled!
[ 13.855110] rtc-ds1307 11-0068: registered as rtc0


And if I run sensors to show temp, it correctly picks up temp from the rtc board temp sensor:

ds3231-i2c-11-68
Adapter: i2c-gpio-rtc@0
temp1: +32.5°C

cpu_thermal-virtual-0
Adapter: Virtual device
temp1: +39.9°C

rpi_volt-isa-0000
Adapter: ISA adapter
in0: N/A

Is there anything I can check or any advice ?

thanks

tahunasky
Posts: 20
Joined: Tue Jan 12, 2021 3:41 am

Re: rtcwake: /dev/rtc0 not enabled for wakeup events

Thu Jan 14, 2021 4:28 am

I can confirm that @bablokb post works on a PI 4B with a DS3231 rtc.

The reason I was having problems is due to the case I am using. It is a Deskpi Pro case, which has a add-on board that the power is plugged into, and then from there it is passed to the PI. So when the Pi is shut down, power is stopped from going to the PI.
To check this there is a RED LED near the USB C plug, and if this is not lite it means no power to the PI so it wont turn on.

I removed the add-on board and everything worked as @bablokb described, so am now able to wake the PI and get the data off the solar inverter every evening.

Return to “General discussion”