Some time ago, I created the wiki page https://www.linuxtv.org/vdrwiki/index.php/Systemd that describes much of my VDR installation.
On my Raspberry Pi, there is no real-time-clock. My low-tech solution for waking up VDR for recordings is that I set an alarm on my phone, to remind me to turn on VDR when needed. Today, I refined that a little by implementing an idle timeout shutdown when no further recording timers exist, or when they are in the distant enough future.
I learned that there is a portable Linux tool "rtcwake" that should support whatever is needed by VDR. It is much simpler than the "nvram-wakeup" that I used almost 20 years ago. On my Raspberry Pi, basically any "rtcwake" commands will fail. That provided a good way of testing the fallback mechanisms of my shutdown script.
I think that it could be useful to include some Systemd integration scripts in the VDR distribution. My systemd integration consists of 4 parts that are documented in the https://www.linuxtv.org/vdrwiki/index.php/Systemd wiki page:
* /etc/systemd/system/vdr-keep-alive.sh to control system shutdown * /var/lib/vdr/vdr-shutdown.sh to handle VDR shutdown (vdr -s) * some configuration to have a VDR service in Systemd * optional: additional configuration to have the video directory on USB storage, to have VDR auto-start when the storage is plugged in.
Because rtcwake does not work on my VDR system, it would be nice to get some feedback from users of wake-on-timer capable systems. It is possible that the "rtcwake -m disk -s $2" and "rtcwake -m mem -s $2" require that "vdr-keep-alive.sh stop" be invoked first and "vdr-keep-alive.sh start" be invoked once rtcwake successfully returns (at the wake-up time). It is also possible that the VDR process would need to be restarted.
Best regards,
Marko
Why don't you make life easy and just add a $5-10 rtc module and be done with it?
On Mon, Apr 10, 2023 at 6:08 AM Marko Mäkelä marko.makela@iki.fi wrote:
Some time ago, I created the wiki page https://www.linuxtv.org/vdrwiki/index.php/Systemd that describes much of my VDR installation.
On my Raspberry Pi, there is no real-time-clock. My low-tech solution for waking up VDR for recordings is that I set an alarm on my phone, to remind me to turn on VDR when needed. Today, I refined that a little by implementing an idle timeout shutdown when no further recording timers exist, or when they are in the distant enough future.
I learned that there is a portable Linux tool "rtcwake" that should support whatever is needed by VDR. It is much simpler than the "nvram-wakeup" that I used almost 20 years ago. On my Raspberry Pi, basically any "rtcwake" commands will fail. That provided a good way of testing the fallback mechanisms of my shutdown script.
I think that it could be useful to include some Systemd integration scripts in the VDR distribution. My systemd integration consists of 4 parts that are documented in the https://www.linuxtv.org/vdrwiki/index.php/Systemd wiki page:
- /etc/systemd/system/vdr-keep-alive.sh to control system shutdown
- /var/lib/vdr/vdr-shutdown.sh to handle VDR shutdown (vdr -s)
- some configuration to have a VDR service in Systemd
- optional: additional configuration to have the video directory on USB
storage, to have VDR auto-start when the storage is plugged in.
Because rtcwake does not work on my VDR system, it would be nice to get some feedback from users of wake-on-timer capable systems. It is possible that the "rtcwake -m disk -s $2" and "rtcwake -m mem -s $2" require that "vdr-keep-alive.sh stop" be invoked first and "vdr-keep-alive.sh start" be invoked once rtcwake successfully returns (at the wake-up time). It is also possible that the VDR process would need to be restarted.
Best regards,
Marko
vdr mailing list vdr@linuxtv.org https://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr
Mon, Apr 10, 2023 at 07:08:29AM -0700, VDRU VDRU wrote:
Why don't you make life easy and just add a $5-10 rtc module and be done with it?
Based on this discussion https://forums.raspberrypi.com/viewtopic.php?t=210662 one would need more than that. "Shutting down" the Raspberry Pi will actually reboot it into the bootloader in a special mode that will cause the firwmare to wait for a "power on" GPIO signal.
The only way to actually power off the Raspberry Pi is to cut the power supply. At https://github.com/bablokb/pi-wake-on-rtc you can find a schematic diagram and board layout of such a solution (incompatible with rtcwake). I don't think that the hardware part can be done by extending the Pi TV HAT with some 3D soldering, like I did to mount an IR receiver.
I was actually looking feedback for the systemd integration, which is not specific to the Raspberry Pi.
Marko
Am 11.04.2023 um 07:41 schrieb Marko Mäkelä:
Mon, Apr 10, 2023 at 07:08:29AM -0700, VDRU VDRU wrote:
Why don't you make life easy and just add a $5-10 rtc module and be done with it?
Based on this discussion https://forums.raspberrypi.com/viewtopic.php?t=210662 one would need more than that. "Shutting down" the Raspberry Pi will actually reboot it into the bootloader in a special mode that will cause the firwmare to wait for a "power on" GPIO signal.
The only way to actually power off the Raspberry Pi is to cut the power supply. At https://github.com/bablokb/pi-wake-on-rtc you can find a schematic diagram and board layout of such a solution (incompatible with rtcwake). I don't think that the hardware part can be done by extending the Pi TV HAT with some 3D soldering, like I did to mount an IR receiver.
I was actually looking feedback for the systemd integration, which is not specific to the Raspberry Pi.
Marko
Maybe still not what you want, but how other guys do it: https://www.vdr-portal.de/forum/index.php?thread/133092-ein-weiterer-ir-eins... https://www.vdr-portal.de/forum/index.php?thread/133332-arduino-nano-mit-neo... (german, you might need google translate, but you can post in english) * wakeup done by STM32 microcontroller board (either by timer set from vdr or by remote control) * power switched by MOSFET * full systemd and vdr integration * very cheap
Joerg
Tue, Apr 11, 2023 at 12:23:44PM +0200, Joerg Riechardt wrote:
Maybe still not what you want, but how other guys do it: https://www.vdr-portal.de/forum/index.php?thread/133092-ein-weiterer-ir-eins... https://www.vdr-portal.de/forum/index.php?thread/133332-arduino-nano-mit-neo... (german, you might need google translate, but you can post in english)
- wakeup done by STM32 microcontroller board (either by timer set from
vdr or by remote control)
- power switched by MOSFET
- full systemd and vdr integration
- very cheap
Nice. For my old PC setup I built something simpler, using an ATtiny12 that would generate a wake-on-LAN or a PCI PME# signal: https://www.iki.fi/~msmakela/electronics/worc5/index.en.html It would even provide a signal to tell VDR if the computer was powered on by the remote control, or due to some other reason.
With a quick read (ich spreche Deutsch), I did not find a mention of systemd or VDR configuration. Can you point to an example?
I think that in any case, I will test my systemd integration scripts on an old Thinkpad laptop and a USB DVB-T stick.
I am happy with my current low-tech solution, at least for now. The power consumption would be acceptable even if I left the system running 24×7, say, if I were away for a week or two. The consumption could be reduced further by patching VDR so that it will shut down all tuners when it is idle (instead of constantly parsing the EPG).
Marko
Am 11.04.2023 um 16:36 schrieb Marko Mäkelä:
Can you point to an example?
https://github.com/j1rie/IRMP_STM32/blob/master/irmplircd/vdrshutdown writes the time of the next vdr timer start into the alarm of the STM32 https://github.com/j1rie/IRMP_STM32/tree/master/stm32IRalarm/Linux. That alarm gets decreased by the systick of the STM32 and finally starts the system. https://github.com/j1rie/IRMP_STM32/blob/master/STM32F103x8/src/main.c#L382 https://github.com/j1rie/IRMP_STM32/blob/master/STM32F103x8/src/main.c#L416 That's not as precise as a RTC, but good enough. As a side effect you have an IR receiver for many protocols https://github.com/j1rie/IRMP_STM32
Joerg
Tue, Apr 11, 2023 at 05:41:24PM +0200, Joerg Riechardt wrote:
Thank you. This is a user space solution, with the benefit that it is not limited to Linux. I think that it would be good to mention this at https://www.linuxtv.org/vdrwiki/index.php/Raspberry_Pi and perhaps also add some pictures.
That page currently mentions a minimal IR receiver for the Raspberry Pi: a 3-pin IR receiver module connected to the GPIO header. Because the Linux kernel already includes a number of IR protocol drivers, there is no need to install any user-space lircd driver (or input plugin) if you are using a recent enough version of VDR.
Marko
Let me put my unsolicited €0.02 in. My mindset is pretty hackerish as well, but I'm also an engineer thinking in efficiency terms. The raspi is what it is, and it is a nice building block for many jobs. If I wanted to build a vdr, I'd either let the raspi run permanently (given its low energy demand) or get a Pico PSU powered mini itx board with an embedded CPU, like one of the low-power (4.3-10W) celerons, and let it wake up and shut down when needed.
But that's just me.
Am 12. April 2023 08:00:27 MESZ schrieb "Marko Mäkelä" marko.makela@iki.fi:
Tue, Apr 11, 2023 at 05:41:24PM +0200, Joerg Riechardt wrote:
Thank you. This is a user space solution, with the benefit that it is not limited to Linux. I think that it would be good to mention this at https://www.linuxtv.org/vdrwiki/index.php/Raspberry_Pi and perhaps also add some pictures.
That page currently mentions a minimal IR receiver for the Raspberry Pi: a 3-pin IR receiver module connected to the GPIO header. Because the Linux kernel already includes a number of IR protocol drivers, there is no need to install any user-space lircd driver (or input plugin) if you are using a recent enough version of VDR.
Marko
vdr mailing list vdr@linuxtv.org https://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr
Wed, Apr 12, 2023 at 08:29:48AM +0200, Harald Milz wrote:
Let me put my unsolicited €0.02 in. My mindset is pretty hackerish as well, but I'm also an engineer thinking in efficiency terms. The raspi is what it is, and it is a nice building block for many jobs. If I wanted to build a vdr, I'd either let the raspi run permanently (given its low energy demand) or get a Pico PSU powered mini itx board with an embedded CPU, like one of the low-power (4.3-10W) celerons, and let it wake up and shut down when needed.
That sounds reasonable. On any x86 or x86-64 hardware from the past 15 to 20 years, you can expect "rtcwake" to work. I will try to get around to testing that part of my script soon.
One thing that I am somewhat proud of is the Systemd configuration to have VDR start up automatically when a USB video storage drive is plugged in. It is in a sense turning a deficiency into a virtue. Yes, the video storage is a discrete component, but you can easily swap drives, with no extra user interface needed beyond the USB cable and the power button on the remote control unit. Such pluggable storage might also be useful in a small form factor PC setup, if you want a quiet system and need access to more storage than a single SSD can offer.
I just updated https://www.linuxtv.org/vdrwiki/index.php/Raspberry_Pi with a few more options for each category, as well as some pictures of my setup.
I also uploaded pictures of a disassembled Hauppauge remote control unit at https://www.linuxtv.org/vdrwiki/index.php/Remote_control in case someone might find it useful, for taking apart and fixing theirs.
Marko
Am 10.04.2023 um 15:07 schrieb Marko Mäkelä:
Some time ago, I created the wiki page https://www.linuxtv.org/vdrwiki/index.php/Systemd that describes much of my VDR installation.
On my Raspberry Pi, there is no real-time-clock. My low-tech solution for waking up VDR for recordings is that I set an alarm on my phone, to remind me to turn on VDR when needed. Today, I refined that a little by implementing an idle timeout shutdown when no further recording timers exist, or when they are in the distant enough future.
I learned that there is a portable Linux tool "rtcwake" that should support whatever is needed by VDR. It is much simpler than the "nvram-wakeup" that I used almost 20 years ago. On my Raspberry Pi, basically any "rtcwake" commands will fail. That provided a good way of testing the fallback mechanisms of my shutdown script.
I think that it could be useful to include some Systemd integration scripts in the VDR distribution. My systemd integration consists of 4 parts that are documented in the https://www.linuxtv.org/vdrwiki/index.php/Systemd wiki page:
- /etc/systemd/system/vdr-keep-alive.sh to control system shutdown
- /var/lib/vdr/vdr-shutdown.sh to handle VDR shutdown (vdr -s)
- some configuration to have a VDR service in Systemd
- optional: additional configuration to have the video directory on USB
storage, to have VDR auto-start when the storage is plugged in.
Because rtcwake does not work on my VDR system, it would be nice to get some feedback from users of wake-on-timer capable systems. It is possible that the "rtcwake -m disk -s $2" and "rtcwake -m mem -s $2" require that "vdr-keep-alive.sh stop" be invoked first and "vdr-keep-alive.sh start" be invoked once rtcwake successfully returns (at the wake-up time). It is also possible that the VDR process would need to be restarted.
Best regards,
Marko
vdr mailing list vdr@linuxtv.org https://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr
How about https://www.berrybase.de/ds3231-real-time-clock-modul-fuer-raspberry-pi? Joerg