0

I’m trying to create a custom boot screen for my Raspberry Pi by following the instructions here.

This involves installing fbi and running it in an init.d script.

This works fine on the default HDMI output. The thing is, I need the image to be displayed on the Adafruit PiTFT which is on /dev/fb1. Running fbi from the command prompt with the -d /dev/fb1 switch works and displays the image on the PiTFT.

The issue is that the PiTFT is loaded using a Kernel Module which, according to the Debian boot process, are loaded after the init.d scripts run. This means that the -d switch won’t work because /dev/fb1 doesn't exist yet.

Is there a way I can set a startup script to run after the kernel modules load, so I can display the image on the PiTFT?

0

I'm assuming here that Raspbian is similar to regular Debian GNU/Linux, and that you are using dependency based booting (not systemd; though this can probably be adapted for systemd as well). That is, that your environment is similar to Debian Wheezy (which is the current stable release at the time of writing this answer).

During the boot process, /etc/init.d/kmod is started to load all modules listed in /etc/modules. By ensuring that your script has kmod as a dependency, you can take advantage of this to ensure that the required kernel module(s) are loaded before your script executes.

To do that, you should add a INIT INFO header to your script (this can be copied from another script) which lists kmod as Required-Start (required while starting the service provided by the script) and Required-Stop (required while stopping the service). You will also need to set Default-Start and possibly Default-Stop appropriately.

A good init script header might be something like:

#! /bin/sh
### BEGIN INIT INFO
# Provides:          mybootdisplay
# Required-Start:    kmod
# Required-Stop:     kmod
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: 
# Description:       
### END INIT INFO
# ... your magic goes down here ...

See man 8 insserv for more details on the different info stanzas, and look at different existing init scripts for inspiration.

After creating your init script with an appropriate init info block, run sudo update-rc.d mybootdisplay defaults to add /etc/init.d/mybootdisplay to the boot sequence.


As an alternative to the above, you could make your script specifically load the kernel module(s) needed by calling modprobe or insmod itself before running fbi. That said, I'd personally prefer deferring to the normal init script for that, which means the above solution is likely better.

| improve this answer | |
  • Brilliant! It worked perfectly, exactly what I was looking for. Thanks! – Kayleigh Swift Feb 5 '15 at 20:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.