Raspberry Pi

From Elvanör's Technical Wiki
Jump to navigation Jump to search

Setup & Installation

  • PINN is an easy OS installation tool coupled with a boot loader. With it you can easily install several OSes on a single SD card, which makes it easier to multi boot on different distributions. Each distribution can be used for a different purpose (LibreELEC for Kodi, RetroArch for gaming, Raspberry Pi OS for general purpose, etc).
  • It seems that PINN strangely does not allow you custom configuration of the partition of the SD card. Partitions are created according to the chosen OSes you want to install, but you can not reserve more space for a given OS if you want to. Of course, you can use gparted after installation to change it as you want.
  • Normally the OS boot selection is done via keyboard / mouse when booting. For me, this is not ideal as many RPi systems will not be connected to a mouse or keyboard. However, there is a way to change the boot partition (and thus the selected boot distribution) via a text configuration file. So it's relatively easy to write scripts to change the OS via SSH (it requires SSH support for login in all installed OSes, though).

Boot Configuration File

  • This file in /boot/config.txt can be used to disable internal Wifi and Bluetooth adapters:
dtoverlay=disable-bt
dtoverlay=disable-wifi

Raspberry Pi OS (Official OS)

  • This is based on Debian. You can install very easily Kodi via apt-get. Installing RetroArch is sometimes possible via the Libretro Ubuntu PPA (Personal Package Archives) but not recommended, as an Ubuntu PPA can conflict with a pure Debian system (some packages for current versions of RetroArch won't be up to date, etc). It's better to install RA via flatpak (see RetroArch page for more information).
  • First thing to do after installation is to setup a root passwd (sudo passwd root)! It's very important else you can get locked out of the system if the boot process fails (as it won't be able to drop you to a shell in emergency mode).
  • For Kodi, to play H265 movies (4K) you will probably need the followind added to your config.txt file (located in /boot/):
dtoverlay=vc4-kms-v3d,cma-512
dtoverlay=rpivid-v4l2
  • Update: the dtoverlay=rpivid-v4l2 line is apparently obsolete and no longer needed.
  • For the Catchup TV addon to work, you will also need to install the kodi-inputstream-adaptive via apt-get.
  • Commands to perform the equivalent of a Gentoo emerge --sync && emerge --update world && emerge -a --depclean:
apt update
apt full-upgrade
apt autoremove
  • Other useful apt commands:
apt list
apt list --installed
  • By default Raspberry Pi OS is configured with automatic upgrades. This can be problematic. You can disable this by removing the unattended-upgrades:
sudo apt remove unattended-upgrades
  • With an old LG TV, screen would remain black after a boot into Rasperry Pi OS (the same screen would work on Gentoo or RetroPie, or another screen would work in Raspberry Pi OS). To fix this, I ran raspi-config to setup console boot rather than an X session by default, I added hdmi_safe=1 to config.txt and I wrote the following login script (to place in /etc/profile.d/elvanor.sh):
if pgrep -x "Xorg" >/dev/null
then
       if pgrep -x "kodi" >/dev/null
       then
               echo "All good"
       else
               echo "Starting Kodi"
               sleep 5
               kodi
       fi
else
       echo "Starting Lightdm"
       sleep 5
       sudo systemctl restart lightdm
fi
  • Be careful of the output devices when using PulseAudio. By default the output device might be the wrong one and if the application does not have an interface to change it (such as Kodi or VLC), there will be no sound. It was the case for instance with RetroArch. One way to get rid of that issue is to install pavucontrol, then disable the unused audio output devices so that only the correct one remains.

Boot process

  • If the system will not boot, a recovery option is to edit the cmdline.txt file (present on a FAT32 partition on the SD card), and add init=/bin/bash to the parameters (it's all on a single line). This will drop you to a shell where you can hopefully fix issues.
  • Adding a permanent entry to fstab is risky: if the drive cannot be mounted at boot time, it will make the whole boot process fail. To avoid this, add the "nofail" option to the target /etc/fstab entry (this should honestly be the default but unfortunately this is not the case under Debian, which is stupid).
  • The x-systemd.device-timeout=10s fstab option can also be used, which will make the boot process only wait 10s (rather than the default 90s) before declaring a mount failure. This is a minor improvement over the essential nofail one.

Bluetooth

  • Connecting devices via Bluetooth works. You can pair and connect DualSense PS 5 controllers without any issues, then use them in RetroArch. You must pair the devices on the desktop environment.
  • It's important to Install the blueman package, as the default interface to manage Bluetooth devices is really limited (no way to rename a device for instance).

On screen keyboard

  • Useful if you don't have any physical keyboard connected to the Raspberry. Install the onboard package (you can then launch it Universal Access -> Onboard).

Gentoo on the Raspberry Pi

  • It seems Gentoo would mostly work on the RPi, but I did not invest too much time. One of the default image in PINN is Gentoo and it works. It even comes pre-installed with Kodi (but not Retroarch) which is great, although I don't know if .
  • You will mostly want to reinstall Kodi with the webserver USE flag to include support for remote control via the Kore Android application.