NAS326 - Set wakealarm at shutdown fails - on reboot fine
Fusel
Posts: 6 Freshman Member
I want to start my NAS every day at 08:00.
When i set the wakealarm for rtc on reboot it works fine.
I use the script below to set wakealarm
When i use the script above to wakeup e.g. at 03:00, i set START_TIME to "03:00" and run it the same way like on reboot. But this doesn't work.
(I also prefer to set the next default start time at shutdown instead of reboot, but even this fails.)
On shutdown i tried to save the wakealarm file and it contains the right wakeup timestamp. But the NAS doesn't start.
Short: On reboot works, on shutdown doesn't.
Why?
#NAS_Mar_2019
When i set the wakealarm for rtc on reboot it works fine.
I use the script below to set wakealarm
START_TIME="08:00" START_TIME=$(date -d "$(date "+%Y-%m-%d") $START_TIME:00" "+%s") sh -c "echo 0 > /sys/class/rtc/rtc0/wakealarm" sh -c "echo $START_TIME > /sys/class/rtc/rtc0/wakealarm"On shutdown i check some parameters and sometimes i want to wakeup the NAS before 08:00.
When i use the script above to wakeup e.g. at 03:00, i set START_TIME to "03:00" and run it the same way like on reboot. But this doesn't work.
(I also prefer to set the next default start time at shutdown instead of reboot, but even this fails.)
On shutdown i tried to save the wakealarm file and it contains the right wakeup timestamp. But the NAS doesn't start.
Short: On reboot works, on shutdown doesn't.
Why?
#NAS_Mar_2019
0
All Replies
-
I think your script interferes with the firmware timed wakeup implementation. At reboot it's not necessary to set the rtc, so in that case your script has 'the last word', but at shutdown the firmware sneaks in and overwrites your action.Having said that, I have no idea how the firmware sneaks in. /etc/init.d/rc.shutdown doesn't seem to do anything significant in this respect, and AFAIK 'poweroff' and 'reboot' don't call any firmware scripts, just cause init to shutdown/reboot.Maybe you can disable the possibility of the firmware to access the rtc. Try to delete /sbin/i2cset. (Don't worry, it's in the initramfs, and will be back on reboot). A possible problem here is that /etc/init.d/rc.shutdown also calls i2cset. I 'think' to tell the MCU what to do on power loss.If that doesn't help, you can remove the rtc from the /sys/class/ tree. On my 520 that is done with
<div>echo c2k-rtc >/sys/bus/platform/drivers/c2k-rtc/unbind</div><div></div>
BTW, how do you know your scripts works at reboot? Just pull the plug?
0 -
Thanks a lot for your answer!
I forgot some details...
I wanted to install Tvheadend, so i installed ffp using your package.
On ffp you can use the /ffp/start/ directory to call scripts after start ffp - my autorun on reboot
In this script i set the wakeup (i rather prefer on shutdown instead) and add a script-call to /etc/init.d/rc.shutdown on first position.
This script is running on shutdown/reboot (checking by buzzerc -t 2).
Wakeup at defined time works well but setting different wakeup by using shutdown-call fails.
Copy wakealarm to hdd using my shutdown-script shows the right time, but wake on initial wakeup and not on the wakeup defined in my shutdown-script.
Setting wakeup at shutdown instead of reboot also fails.
So i think you are right, "default" firmware overrides my changes with my previous setting.
But only at shutdown/reboot.
When i delete i2cset, wakealarm still runing?
When i unbind rtc, wakealarm still possible?0 -
When i delete i2cset, wakealarm still runing?
When i unbind rtc, wakealarm still possible?The RTC is an independent chip which is connected to the SoC by the I2C bus. And it has a copper line to some logic which is able to powerup the bus. By progamming a wakeup time you actually tell the clock to pulse that copper line at a certain time.Deleting i2cset or unbinding the rtc has the same purpose, virtually cutting the i2c wire. If you do that after programming the chip, it should prevent the firmware (and you) from accessing the chip, but the chip itself is autonomous, and doesn't care.So yes, wakealarm should still occur.But if the firmware programs the rtc using another way (a direct link to libi2c) it doesn't help.
0 -
I think it's an other problem.
When i useST=1553675595 // (e.g.) echo 0 > /sys/class/rtc/rtc0/wakealarm echo $ST > /sys/class/rtc/rtc0/wakealarm
it work.
When usingST=$(date -d '+ 2 minutes' +%s) echo 0 > /sys/class/rtc/rtc0/wakealarm echo $ST > /sys/class/rtc/rtc0/wakealarm
it fails.
Maybe an problem with the date-function and/or the result of it and not with the rtc himself0 -
I suppose you have looked at the output of
date -d '+ 2 minutes' +%s
But did you also look at/bin/date -d '+ 2 minutes' +%s
When using FFP, by default /ffp/bin/date is used, which is much more powerful than the firmware busybox applet./etc/init.d/rc-shutdown runs in a different environment, and so it will default to /bin/date. I don't think you can use /ffp/bin/date here, as FFP is already cleaned up.0 -
</code>/bin/date -d '+ 2 minutes' +%s</pre>Fails - invalid date '+ 2 minutes'<br><br><pre class="CodeBlock"><code>ST=$(/bin/date +%s) ST=$(($ST + 180))
works0
Categories
- All Categories
- 415 Beta Program
- 2.4K Nebula
- 151 Nebula Ideas
- 98 Nebula Status and Incidents
- 5.7K Security
- 277 USG FLEX H Series
- 277 Security Ideas
- 1.4K Switch
- 74 Switch Ideas
- 1.1K Wireless
- 42 Wireless Ideas
- 6.4K Consumer Product
- 250 Service & License
- 395 News and Release
- 85 Security Advisories
- 29 Education Center
- 10 [Campaign] Zyxel Network Detective
- 3.6K FAQ
- 34 Documents
- 34 Nebula Monthly Express
- 85 About Community
- 75 Security Highlight