wardx
Posts: 6
Joined: Sun May 24, 2020 12:51 am

show pictures on restart and shutdown screens

Sun May 24, 2020 1:26 am

Hello there,

I want to show users specific images when restarting and shutting down the Raspbian operating system. I prepared some services with the resources I found on the internet regarding these transactions. Despite the fact that the services were working, I could not see the pictures on the screen during the restart and shutdown processes. But when I said create any file, I saw that it occurred. I wonder where is the wrong place? I would be glad if you could help.

Shutdown Service

Code: Select all

[Unit]
Description=show image on starting shutdown
DefaultDependencies=no
Before=shutdown.target

[Service]
#ExecStart=/usr/bin/python3 /home/pi/payclient/os_custom_data/framebuffer-pythonscript.py -img /home/pi/os_custom_data/powerdownimage.jpg
ExecStop=/usr/bin/python3 /home/pi/payclient/os_custom_data/framebuffer-pythonscript.py -img /home/pi/os_custom_data/powerdownimage.jpg
Type=oneshot

[Install]
WantedBy=multi-user.target
Reboot Service

Code: Select all


[Unit]
Description=show image on reboot
DefaultDependencies=no
Before=reboot.target

[Service]
Type=oneshot
ExecStart=/usr/bin/python3 /home/pi/payclient/os_custom_data/framebuffer-pythonscript.py -img /home/pi/os_custom_data/reboot.jpg
ExecStart=touch /home/pi/reboot2.txt

[Install]
#WantedBy=reboot.target
WantedBy=graphical.target



Unplug Service

Code: Select all

[Unit]
Description=safe-to-power-off image
DefaultDependencies=no
After=umount.target
Before=final.target

[Service]
ExecStart=/usr/bin/python3 /home/pi/payclient/os_custom_data/framebuffer-pythonscript.py -img /home/pi/os_custom_data/unplugimage.jpg
Type=oneshot

[Install]
WantedBy=shutdown.target

DarkElvenAngel
Posts: 614
Joined: Tue Mar 20, 2018 9:53 pm

Re: show pictures on restart and shutdown screens

Sun May 24, 2020 4:06 am

Your close.
These are my services I use. Do you have the logging switch to a different terminal otherwise the images will be overwritten very quickly. (That's taken care of during boot if you have a boot splash I assume you have done that.) Python is slow to load and these screens are only viewable for a few seconds if at all. I use mine on a Pi Zero, and I use a C program to show images. Another method is if the screen will always be the same resolution is to just copy the raw image to the framebuffer.


Reboot target

Code: Select all

[Unit] 
Description=show reboot image
DefaultDependencies=no 
Before=halt.target 
[Service] 
ExecStart=/bin/fbsplash /etc/splash/reboot.png
Type=oneshot 
[Install]
WantedBy=halt.target reboot.target
Shutdown target

Code: Select all

[Unit] 
Description=show image shutdown (poweroff command)
DefaultDependencies=no 
Before=halt.target 
[Service] 
ExecStart=/bin/fbsplash /etc/splash/shutdown.png
Type=oneshot 
[Install]
WantedBy=halt.target poweroff.target
Unplug target

Code: Select all

[Unit] 
Description=Show unplug image (full power off)
DefaultDependencies=no 
After=umount.target 
Before=final.target 
[Service] 
ExecStart=/bin/fbsplash /etc/splash/unplug.png
Type=oneshot 
[Install]
WantedBy=shutdown.target
There's also fbv it's not available in the raspbian repository but you can build it from a GitHub repo.

Try editing the services and see if it works for you. If not I'll dig up some links for you if you need them.

wardx
Posts: 6
Joined: Sun May 24, 2020 12:51 am

Re: show pictures on restart and shutdown screens

Sun May 24, 2020 9:37 pm

Thank you for your answer, but my problems continue.
unfortunately i couldn't install fbsplash. so I couldn't try the commands you wrote. Just like there should be a more practical way to add images to the restart and shutdown screens. I tried to show it with an app like fbi instead of fpsplash, but the result is unsuccessful. I will be very happy if you help me.

DarkElvenAngel
Posts: 614
Joined: Tue Mar 20, 2018 9:53 pm

Re: show pictures on restart and shutdown screens

Sun May 24, 2020 10:35 pm

wardx wrote:
Sun May 24, 2020 9:37 pm
Thank you for your answer, but my problems continue.
unfortunately i couldn't install fbsplash. so I couldn't try the commands you wrote. Just like there should be a more practical way to add images to the restart and shutdown screens. I tried to show it with an app like fbi instead of fpsplash, but the result is unsuccessful. I will be very happy if you help me.
So I think you got the idea from this link
https://www.madebymany.com/stories/fun- ... spberry-pi

I have used their method the services I tweaked a bit to get slightly better results. If you're doing this on a fast RPI it might be too quick. I never got the unplug image to show because the system turns off the display. It's also an old tutorial my pi is running Stretch I will transfer the services to my pi 4 and let you know if I have success.

Hmm can you post your cmdline.txt.

Fbsplash is a program I wrote but this
should work https://github.com/dimkr/fbim

What type of RPI are you trying this on?

wardx
Posts: 6
Joined: Sun May 24, 2020 12:51 am

Re: show pictures on restart and shutdown screens

Sun May 24, 2020 11:01 pm

Yes, I saw that page while doing research on this subject. I bought it from Python for example, but when I couldn't get the result I wanted, I looked for other solutions.

I probably cannot see images on the screen due to the fast shutdown, but can such a situation be for reboot?

I test with Raspberry pi 3 model B + and Raspberry pi 4 model B.

I use Raspberry Pi Official Touch Screen. I use the latest version of Raspbian Buster as the operating system.

How can I perform these operations with fbim. Or should I give up this search for a solution?

cmdline.txt

Code: Select all

console=serial0,115200 console=tty1 root=PARTUUID=ea7d04d6-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait logo.nologo

DarkElvenAngel
Posts: 614
Joined: Tue Mar 20, 2018 9:53 pm

Re: show pictures on restart and shutdown screens

Sun May 24, 2020 11:26 pm

wardx wrote:
Sun May 24, 2020 11:01 pm
Yes, I saw that page while doing research on this subject. I bought it from Python for example, but when I couldn't get the result I wanted, I looked for other solutions.

I probably cannot see images on the screen due to the fast shutdown, but can such a situation be for reboot?

I test with Raspberry pi 3 model B + and Raspberry pi 4 model B.

I use Raspberry Pi Official Touch Screen. I use the latest version of Raspbian Buster as the operating system.

How can I perform these operations with fbim. Or should I give up this search for a solution?

cmdline.txt

Code: Select all

console=serial0,115200 console=tty1 root=PARTUUID=ea7d04d6-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait logo.nologo
Change your cmdline.txt to

Code: Select all

console=serial0,115200 console=tty2 root=PARTUUID=ea7d04d6-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait logo.nologo silent quiet loglevel=0 splash
That will make your boot up dark unless you have some sort of boot splash setup. But it might help on shutdown.

Do you know how to use git and make?

I would not give up. Try that and see what

DarkElvenAngel
Posts: 614
Joined: Tue Mar 20, 2018 9:53 pm

Re: show pictures on restart and shutdown screens

Sun May 24, 2020 11:40 pm

Just incase you don't now how it works.

Code: Select all

[~]$ sudo apt install make git build-essential
[~]$ git clone https://github.com/dimkr/fbim.git
[~]$ cd fbim
[~/fbim]$ make
[~/fbim]$ sudo make install
Then you can set your scripts to run /bin/fbim (image file)

wardx
Posts: 6
Joined: Sun May 24, 2020 12:51 am

Re: show pictures on restart and shutdown screens

Mon May 25, 2020 12:04 am

The reason for asking the installation was that I had an addiction problem in the previous project, now my system is running in the system. Your answer will definitely be useful for other users.

I updated the cmdline.txt file as you sent it. I restarted and shut down the system, but the result was black. The system showed the raspian splash screen for about 1 ~ 2 seconds at first boot, then waited on the black screen until x started. Thank you for your help.

DarkElvenAngel
Posts: 614
Joined: Tue Mar 20, 2018 9:53 pm

Re: show pictures on restart and shutdown screens

Mon May 25, 2020 12:23 am

wardx wrote:
Mon May 25, 2020 12:04 am
The reason for asking the installation was that I had an addiction problem in the previous project, now my system is running in the system. Your answer will definitely be useful for other users.

I updated the cmdline.txt file as you sent it. I restarted and shut down the system, but the result was black. The system showed the raspian splash screen for about 1 ~ 2 seconds at first boot, then waited on the black screen until x started. Thank you for your help.
Your welcome, is this current setup suitable for your needs?

I will look into the shutdown splashes tomorrow and test with the official touchscreen. I have a Pi 3B+ setup

wardx
Posts: 6
Joined: Sun May 24, 2020 12:51 am

Re: show pictures on restart and shutdown screens

Mon May 25, 2020 12:36 am

seems to be appropriate at the moment. I hope I will make progress with your help in this regard. I will be waiting for your reply with excitement.

DarkElvenAngel
Posts: 614
Joined: Tue Mar 20, 2018 9:53 pm

Re: show pictures on restart and shutdown screens

Mon May 25, 2020 5:06 pm

Bad news,

I have set everything up and gone through the some tests and troubleshooting.
[*] rpi-display-backlight.service as soon as you start either shutdown or reboot it turns off the display
[*] poweroff.target is disabled by default in Buster
[*] reboot.target is disabled by default in Buster

These are the services as I tried them
Reboot target Doesn't work

Code: Select all

[Unit] 
Description=show reboot image
DefaultDependencies=no 
Before=halt.target 
[Service] 
ExecStart=/bin/fbsplash /etc/splash/reboot.png
Type=oneshot 
[Install]
WantedBy=halt.target reboot.target
Shutdown target Doesn't work

Code: Select all

[Unit] 
Description=show image shutdown (poweroff command)
DefaultDependencies=no 
Before=halt.target 
[Service] 
ExecStart=/bin/fbsplash /etc/splash/shutdown.png
Type=oneshot 
[Install]
WantedBy=halt.target poweroff.target
Unplug target Works*

Code: Select all

[Unit] 
Description=Show unplug image (full power off)
DefaultDependencies=no 
After=umount.target 
Before=final.target 
[Service] 
ExecStart=/bin/fbsplash /etc/splash/unplug.png
Type=oneshot 
[Install]
WantedBy=shutdown.target
* only if you disable the rpi-display-backlight.service and then the display goes random because the input signal is lost.

Here are somethings I tried
$ systemctl list-unit-files --type=target

Code: Select all

UNIT FILE                     STATE   
basic.target                  static  
bluetooth.target              static  
boot-complete.target          static  
cryptsetup-pre.target         static  
cryptsetup.target             static  
ctrl-alt-del.target           disabled
default.target                indirect
emergency.target              static  
exit.target                   disabled
final.target                  static  
getty-pre.target              static  
getty.target                  static  
graphical.target              indirect
halt.target                   disabled
hibernate.target              static  
hybrid-sleep.target           static  
initrd-fs.target              static  
initrd-root-device.target     static  
initrd-root-fs.target         static  
initrd-switch-root.target     static  
initrd.target                 static  
kexec.target                  disabled
local-fs-pre.target           static  
local-fs.target               static  
multi-user.target             static  
network-online.target         static  
network-pre.target            static  
network.target                static  
nfs-client.target             enabled 
nss-lookup.target             static  
nss-user-lookup.target        static  
paths.target                  static  
poweroff.target               disabled
printer.target                static  
reboot.target                 disabled
remote-cryptsetup.target      disabled
remote-fs-pre.target          static  
remote-fs.target              enabled 
rescue-ssh.target             static  
rescue.target                 static  
rpcbind.target                static  
runlevel0.target              disabled
runlevel1.target              static  
runlevel2.target              static  
runlevel3.target              static  
runlevel4.target              static  
runlevel5.target              indirect
runlevel6.target              disabled
shutdown.target               static  
sigpwr.target                 static  
sleep.target                  static  
slices.target                 static  
smartcard.target              static  
sockets.target                static  
sound.target                  static  
suspend-then-hibernate.target static  
suspend.target                static  
swap.target                   static  
sysinit.target                static  
system-update-pre.target      static  
system-update.target          static  
time-sync.target              static  
timers.target                 static  
umount.target                 static  

64 unit files listed.
I tried to enable the two targets this doesn't work, my guess is that they don't get triggered.
I tried this with HDMI and it doesn't work.
It seems to work on a Pi Zero running Stretch.
Just to add salt to it all I ran systemctl list-unit-files --type=target on Stretch to see and now it's very confusing!

Code: Select all

UNIT FILE                 STATE   
basic.target              static  
bluetooth.target          static  
busnames.target           static  
cryptsetup-pre.target     static  
cryptsetup.target         static  
ctrl-alt-del.target       disabled
default.target            static  
emergency.target          static  
exit.target               disabled
final.target              static  
getty.target              static  
graphical.target          static  
halt.target               disabled
hibernate.target          static  
hybrid-sleep.target       static  
initrd-fs.target          static  
initrd-root-device.target static  
initrd-root-fs.target     static  
initrd-switch-root.target static  
initrd.target             static  
kexec.target              disabled
local-fs-pre.target       static  
local-fs.target           static  
multi-user.target         static  
network-online.target     static  
network-pre.target        static  
network.target            static  
nfs-client.target         enabled 
nss-lookup.target         static  
nss-user-lookup.target    static  
paths.target              static  
poweroff.target           disabled
printer.target            static  
reboot.target             disabled
remote-fs-pre.target      static  
remote-fs.target          enabled 
rescue.target             disabled
rpcbind.target            static  
runlevel0.target          disabled
runlevel1.target          disabled
runlevel2.target          static  
runlevel3.target          static  
runlevel4.target          static  
runlevel5.target          static  
runlevel6.target          disabled
shutdown.target           static  
sigpwr.target             static  
sleep.target              static  
slices.target             static  
smartcard.target          static  
sockets.target            static  
sound.target              static  
suspend.target            static  
swap.target               static  
sysinit.target            static  
system-update.target      static  
time-sync.target          static  
timers.target             static  
umount.target             static  

59 unit files listed.

I don't want to give up but I've done all I can think of. If someone with a better grasp of systemd can help us out here that's what we need.

Sorry it's not better news for you hopefully some else can pick this up and we can figure it out.

wardx
Posts: 6
Joined: Sun May 24, 2020 12:51 am

Re: show pictures on restart and shutdown screens

Mon May 25, 2020 9:10 pm

Thank you very much. I looked at it too, but things are getting clogged. I will continue researching on systemd. I hope I can find a solution, if I find I will write it here. Thanks again for your efforts.

DarkElvenAngel
Posts: 614
Joined: Tue Mar 20, 2018 9:53 pm

Re: show pictures on restart and shutdown screens

Mon May 25, 2020 10:41 pm

wardx wrote:
Mon May 25, 2020 9:10 pm
Thank you very much. I looked at it too, but things are getting clogged. I will continue researching on systemd. I hope I can find a solution, if I find I will write it here. Thanks again for your efforts.
Your welcome, please do keep this up to date it might help others as well.

This seems to be one of those things that broke with Buster or it could be user error.

From what I tried and could see, it would be a good place to start looking at the shutdown/restart order of targets. On my Pi zero with Stretch I call a script not just putting up the image. The script I use on my system is to complex to post here and wouldn't be of any use really.

Good luck, if I find anything I will update here as well.

DarkElvenAngel
Posts: 614
Joined: Tue Mar 20, 2018 9:53 pm

Re: show pictures on restart and shutdown screens

Thu May 28, 2020 12:03 am

Update,

I haven't had much luck sorting out the order systemd uses during shutdown, I asked in this thread for help.

What I did figure out is something during shutdown clears the terminal! I saw my splash image pop up ever so briefly. So I went to my original thought that my old approach was introducing enough delay to make the image come up.

This is my service I tested with

Code: Select all

[Unit] 
Description=Show unplug image (full power off)
DefaultDependencies=no  
Before=umount.target 
[Service] 
ExecStart=/home/pi/splash
Type=oneshot 
[Install]
WantedBy=shutdown.target reboot.target halt.target kexec.target
now the splash script is as follows

Code: Select all

#!/bin/bash
# turn off cursor
echo -e "\e[?25l" > /dev/tty1
# very important sleep maybe less time is ok?
sleep 1
# display the splash image
/home/pi/Projects/fbim/fbsplash /home/pi/Splash/shutdown.jpg
# this sleep is not needed
# sleep 2
# mount usbkey and capture the closing system logs for systemd
mount /dev/disk/by-path/platform-fd500000.pcie-pci-0000:01:00.0-usb-0:1.3.3:1.0-scsi-0:0:0:0-part1 /mnt
#systemd-analyze plot > /mnt/systemd.svg
journalctl | grep systemd > /mnt/system.log
sync
umount /mnt
exit 0
I haven't done full tests yet with each type of shutdown but I thought this progress update would be helpful.

This was tested on a PI4 B 4GB with HDMI screen attached I will test on a PI3 B+ with the official touch screen tomorrow.

DarkElvenAngel
Posts: 614
Joined: Tue Mar 20, 2018 9:53 pm

Re: show pictures on restart and shutdown screens

Thu May 28, 2020 9:19 pm

Update,

I now get my shutdown restart and unplug images.
This is working on the most up to date Raspberry Pi OS

My final services are as follows
splash-shutdown.service

Code: Select all

[Unit] 
Description=show shutdown image
DefaultDependencies=no 
Before=umount.target 
[Service] 
ExecStart=/home/pi/splash /home/pi/Splash/Pi4B-poweroff.jpg
Type=oneshot 
[Install]
WantedBy=halt.target shutdown.target
splash-reboot.service

Code: Select all

[Unit] 
Description=show reboot image
DefaultDependencies=no 
Before=umount.target 
[Service] 
ExecStart=/home/pi/splash /home/pi/Splash/Pi4B-rebooting.jpg
Type=oneshot 
[Install]
WantedBy=halt.target reboot.target
splash-unplug.service

Code: Select all

[Unit] 
Description=Show unplug image (full power off)
DefaultDependencies=no 
After=umount.target 
Before=final.target 
[Service] 
ExecStart=/home/pi/splash /home/pi/Splash/Pi4B-unplug.jpg
Type=oneshot 
[Install]
WantedBy=shutdown.target
splash script

Code: Select all

#!/bin/bash
sleep .5
echo 'q' | fbv -cike "$1"
exit 0
fbv is not in the RaspberryPi OS repos so you have to get it from github.

The rpi-display-backlight.service will conflict with these and it must be modified the problem is the display will turn off just after the system starts to reboot or restart.

Here is the service as seen from github

Code: Select all

[Unit]
Description=Turns off Raspberry Pi display backlight on shutdown/reboot
ConditionPathIsDirectory=/proc/device-tree/rpi_backlight
DefaultDependencies=no
Before=umount.target

[Service]
Type=oneshot
ExecStart=/bin/sh -c '/bin/echo 1 > /sys/class/backlight/rpi_backlight/bl_power'

[Install]
WantedBy=reboot.target halt.target poweroff.target
disabling this service is one way to do things but then the display will remain on until you remove power. changing the script would be the next best thing.

Code: Select all

#!/bin/bash
sleep .5
echo 'q' | fbv -cike "$1"
if [ -n $2 ] && [ -d /sys/class/backlight/rpi_backlight ] ; then
  sleep 2
  echo 1 > /sys/class/backlight/rpi_backlight/bl_power
exit 0

and just change the splash-unplug.service line to

Code: Select all

ExecStart=/home/pi/splash /home/pi/Splash/Pi4B-unplug.jpg off
This should display the unplug image for two seconds and then turn the screen off.

OR change the splash-unplug.service to

Code: Select all

[Unit]
Description= Turn of RPI Display but show no image
ConditionPathIsDirectory=/proc/device-tree/rpi_backlight
DefaultDependencies=no
After=umount.target 
Before=final.target 

[Service]
Type=oneshot
ExecStart=/bin/sh -c '/bin/echo 1 > /sys/class/backlight/rpi_backlight/bl_power'

[Install]
WantedBy=shutdown.target
That's all I have for this update, hope it helps.

ToxicTrev
Posts: 9
Joined: Sun May 03, 2020 1:54 am

Re: show pictures on restart and shutdown screens

Fri May 29, 2020 12:01 pm

hey guys, I have been working on a custom jukebox using the fruitbox software, which I realise is a differet topic, but my question here is I want to put in a custom loading / splash screen for the raspberry pi. I was doing some research and it looks like the directory to the splash image is in the usr/plymoth/themes/pix or something along those lines, which the version of the fruitbox image disk doesnt seem to have that file.

how would I go about putting in a custom splash / loading screen for this ?

DarkElvenAngel
Posts: 614
Joined: Tue Mar 20, 2018 9:53 pm

Re: show pictures on restart and shutdown screens

Fri May 29, 2020 2:38 pm

No problem please post in this thread as this thread deals with shutdown splashes.

page five is the best place to start.

Return to “Raspberry Pi OS”