Closed SCiunczyk closed 5 years ago
That sounds like a novel application, but a bit niche, so I probably won't be including it as standard.
But I think you could achieve it using the pinn_init.sh
script.
If this script exists on the PINN recovery drive (i.e. the drive where you will find recovery.rfs), it will be executed on boot up before PINN runs.
You can use it to detect the presence of HDMI (see BootSelectionDialog::updateConfig4dsi() for how to use tvservice for this) and alter either the default_partition_to_boot
or sticky_boot
parameters in /settings/noobs.conf according to your desires.
@procount thanks for your suggestions I will try that. Currently I'm using Volumio with Kodi plug-in but there are lot of problems - eg it's hard to update Kodi in my installation. The system is installed on my boat where I mostly listen to music using Volumio, But time to time I like watch some movies or Netflix so I like to run Kodi with my TV.
I will check and publish my investigation results.
Hi, @procount I'm afraid that I need a little more help. I can't get pinn_init.sh
running on my PINN boot.
My steps are:
mount RECOVERY drive:
mkdir /tmp/RECOVERY
mount -t auto /dev/mmcblk0p1 /tmp/RECOVERY
check if there is recovery.rfs
cd /tmp/RECOVERY
ls recovery.rfs
exists - OK
create pinn_init.sh
nano pinn_init.sh
enter just two test lines:
#!/usr/bin/bash
echo Hello >/tmp/tv_test.txt
save, exit nano
run for test
./pinn_init.sh
delete test output
rm /tmp/tv_test.txt
reboot RPi
reboot now
and nothing happens. What I'm missing to have pinn_init.sh
executed on RPi(PINN) boot ?
Happy New Year
So close, yet so far....
In step 4, you need to change the shebang to
#!/bin/sh
because you are in a buildroot environment, not Raspbian. It uses the ash shell, not bash.
It looks like you are trying to do this in Raspbian (or kodi). If you are willing to use VI instead of Nano, you could edit and test this within PINN where you can see what it is doing more easily:
mount -o remount,rw /mnt
cd /mnt
vi pinn_init.sh
:wq
./pinn_init.sh
and see the output.sync
to make sure your files are safe before you rebootp
So close no matter how far... but ... with a little help from my friends ... I have it running now.
Many thanks. I'm very close...
Tomorrow last steps: parsing tvservice output and setting noobs.conf to boot Volumio or Libreelec.
Hi @procount finally I have two news. One is good and one is bad.
The good: script working as expected! The bad: only when I plug/unplug HDMI cable from RPi
So I'm in dead end now :-(
The tvservice -n report a HDMI TV connected even if the TV is physically disconnected from power (unplugged from the wall). By definition HDMI transmitter (RPi) is sourcing +5V 55mA. And that power is used to detect the connected device. For now I have no idea how to check the actual power status TV (on/off) on boot stage.
Maybe you can use cec-client to query the status of the tv? E.g https://blog.gordonturner.com/2016/12/14/using-cec-client-on-a-raspberry-pi/
That was my first idea. Is the cec-client available in buildroot environment on boot time ?
Unfortunately my quite modern yacht TV (the target one, with CEC) is currently broken. Have to send it to service. I have only 20 year old Sony Bravia probably without CEC support.
The whole system is for my boat where I usually listen to music with Volumio and only occasionally I watch movies on Kodi. The TV is closed in cabinet and power off. So this is why I want to have such feature. 99% Volumio and only when cabinet is open and TV is on - Kodi.
Tomorrow I will also check if my ASUS AIO is supporting CEC in HDMI monitor mode.
BTW I think that your function BootSelectionDialog::updateConfig4dsi(QByteArray partition) is also susceptible on that problem. Isn't it?
You would have to add cec-client yourself.
Yes, my bootselection dialog would suffer the same, but it wasn't intended to detect the on/off state, but rather connected or not.
The TV is closed in cabinet and power off. So this is why I want to have such feature. 99% Volumio and only when cabinet is open and TV is on - Kodi.
As a workaround hack, instead of detecting whether the TV is on or off, perhaps you could instead detect whether the cabinet door is open or closed, using e.g. a 'switch' made from a couple of bits of tinfoil, connected (by wires) to the RPi's GPIO pins? :slightly_smiling_face:
Hi hi hi @lurch great idea - if everything will fail - I'll try this for sure.
Here is my TV cabinet. Doors are opened to down. TV is mounted up, below is my HTPC (yacht HTPC) - bundle of RPi 3B+ with HiFi Berry with simple NAS based on NanoPI2 Plus (1TB HDD) in one 3D printed box.
The Reed switch inside the RPi box plus strong magnet glued on the internal part of doors will do the job I think.
...just make sure that the strong magnet doesn't get too close to your HDD! :wink: :skull_and_crossbones:
... hi hi hi ... or use SSD 😉
Finally I make the switch to cabinet door as @lurch suggest.
Here is my pinn_init.sh:
#!/bin/sh
#
# pinn_init.sh
#
# Fayka yHTPC bash script to change default boot image between
# Volumio and LibreELEC
#
# value of RPi GPIO18 pin (input) is used to detect TV cabinet
# door opening state:
# 1 - doors are open - user wants to watch multimedia on LibreELEC
# 0 - doors are open - user wants to listen music on Volumio
#
# depend on pin state script is replacing default noobs.conf file
# with Volumio or LibreELEC version: noobs.conf.vol or noobs.conf.lbe
#
# Script is simple and assume that NOOBS is aviable on /dev/mmcblk0p5
# partition - should be changed to more "inteligent" version.
# For example seeking for noobs.conf file - like PINN itself.
#
# The content of noobs.conf.vol or noobs.conf.lbe could be adjusted
# to particular setup.
# - the important line is default_partition_to_boot=
# (5 - Volumio, 9 - LibreELEC)
#
# if the user will touch the keyboard or CEC remote - PINN will
# wait for decision as usual.
#
# Wiring - GPIO18 - pin #12 on RPi header - is used as input.
# As detector the simple Reed switch was used. Plus small magnet
# glued to the cabinet door. Reed switch is pulled-up to 3.3V
# via 47kOhm resitor. There are no possibility to set pull-up/down
# RPi internal resistors via linux shell.
# we try to avoid installing additional libraries on buildroot
# environment. There are no GPIO libraries by default on buildroot
# (RPi.GPIO, WiringPi or similar).
#
# 2019.01.02 by Slawomir Ciunczyk http://www.fayka.pl
#
echo off
dir=$(PWD)
cd /sys/class/gpio
echo 18 > export
echo in > gpio18/direction
cabinetopen=$(cat gpio18/value)
mkdir /tmp/NOOBS
mount -t auto /dev/mmcblk0p5 /tmp/NOOBS
cd /tmp/NOOBS
if [ "$cabinetopen" = "1" ]
then
echo "TV cabinet open - lets play with LibreELEC"
rm noobs.conf.bak
cp noobs.conf noobs.conf.bak
rm noobs.conf
cp noobs.conf.lbe noobs.conf
else
echo "TV cabinet closed - lets play with Volumio"
rm noobs.conf.bak
cp noobs.conf noobs.conf.bak
rm noobs.conf
cp noobs.conf.vol noobs.conf
fi
cd $dir
sync
umount /tmp/NOOBS
rmdir /tmp/NOOBS
echo on
and my hardware (hope that magnet is small and far enough):
Many thanks for Your help.
Hi,
I would like to have dual boot system on my RP3 - Kodi/Volumio. But I will be happy to have automatic scenario:
Do you think that will be possible with PINN ? If yes could you please "push me" in correct direction to build by boot scripts?
best regards Slawek