Skip to content

Instantly share code, notes, and snippets.

@teuteuguy
Last active February 6, 2025 03:31
Show Gist options
  • Select an option

  • Save teuteuguy/a686eb121127e29681bc63424c3fee5f to your computer and use it in GitHub Desktop.

Select an option

Save teuteuguy/a686eb121127e29681bc63424c3fee5f to your computer and use it in GitHub Desktop.
Plexamp on Raspberry Pi
console=serial0,115200 console=tty1 root=PARTUUID=7173ccd0-02 rootfstype=ext4 fsck.repair=yes rootwait quiet splash plymouth.ignore-serial-consoles cfg80211.ieee80211_regdom=SG
# For more options and information see
# http://rpf.io/configtxt
# Some settings may impact device functionality. See link above for details
# uncomment if you get no picture on HDMI for a default "safe" mode
#hdmi_safe=1
# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border
#overscan_left=16
#overscan_right=16
#overscan_top=16
#overscan_bottom=16
# uncomment to force a console size. By default it will be display's size minus
# overscan.
#framebuffer_width=1280
#framebuffer_height=720
# uncomment if hdmi display is not detected and composite is being output
hdmi_force_hotplug=1
# uncomment to force a specific HDMI mode (this will force VGA)
#hdmi_group=1
#hdmi_mode=1
# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes
hdmi_drive=2
# uncomment to increase signal to HDMI, if you have interference, blanking, or
# no display
config_hdmi_boost=4
# uncomment for composite PAL
#sdtv_mode=2
#uncomment to overclock the arm. 700 MHz is the default.
#arm_freq=800
# Uncomment some or all of these to enable the optional hardware interfaces
#dtparam=i2c_arm=on
#dtparam=i2s=on
#dtparam=spi=on
# Uncomment this to enable infrared communication.
#dtoverlay=gpio-ir,gpio_pin=17
#dtoverlay=gpio-ir-tx,gpio_pin=18
# Additional overlays and parameters are documented /boot/overlays/README
# Enable audio (loads snd_bcm2835)
dtparam=audio=on
# Automatically load overlays for detected cameras
camera_auto_detect=0
# Automatically load overlays for detected DSI displays
display_auto_detect=1
# Enable DRM VC4 V3D driver
dtoverlay=vc4-fkms-v3d
max_framebuffers=2
# Run in 64-bit mode
arm_64bit=1
# Disable compensation for displays with overscan
disable_overscan=1
[cm4]
# Enable host mode on the 2711 built-in XHCI USB controller.
# This line should be removed if the legacy DWC2 controller is required
# (e.g. for USB device mode) or if USB support is not required.
otg_mode=1
[all]
[pi4]
# Run as fast as firmware / board allows
arm_boost=1
[all]
disable_splash=1
gpu_mem=16

Installation of plexamp on a Pi3 (HDMI audio)

First Pre Requisites

curl -o- https://gist.githubusercontent.com/teuteuguy/a686eb121127e29681bc63424c3fee5f/raw/b2cb0f634eb389008136f1e2df775ff4be525258/pi3---pre-install.sh | bash

Then run once to get the token

node plexamp/js/index.js

Then run as a service

Modify the plexamp.service

nano plexamp/plexamp.service

to this:

[Unit]
Description=Plexamp
After=network-online.target
Requires=network-online.target

[Service]
Type=simple
User=pi
WorkingDirectory=/home/pi/plexamp
#ExecStart=/usr/bin/node /home/pi/plexamp/js/index.js
ExecStart=/home/pi/.nvm/versions/node/v16.20.2/bin/node /home/pi/plexamp/js/index.js
Restart=on-failure

[Install]
WantedBy=multi-user.target

Install the service

cd plexamp
sudo cp plexamp.service /lib/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable plexamp
sudo systemctl start plexamp

Auto-update

Go see this: https://howtohifi.com/how-to-enable-updates-for-headless-plexamp-using-raspberry-pi/

But gist is:

Make sure jq is installed. Check with

jq --version

or install with

sudo apt install -y jq

Then simply:

sh plexamp/upgrade.sh

Digi+

Go see this: https://www.hifiberry.com/docs/software/configuring-linux-3-18-x/

Basically

# dtparam=audio=on
dtoverlay=vc4-fkms-v3d,audio=off
or
dtoverlay=vc4-kms-v3d,noaudio

dtoverlay=hifiberry-digi

Then in plexamp, use this snd_rpi_hifiberry_digi: HifiBerry Digi HiFi wm8804-spdif-0

Nanosound one

Go see this: https://nanomesher.com/using-the-nanosound-dac-one-in-any-os/

Basically

dtoverlay=hifiberry-dacplus

But also, the raspberry system audio needs to be set to pulse-audio.

#!/bin/bash
echo "First update and upgrade"
sudo apt update
sudo apt upgrade -y
echo "First install node 16 via nvm"
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
# nvm install 16.20.2
nvm install 20
node --version
# curl https://plexamp.plex.tv/headless/Plexamp-Linux-headless-v4.9.3.tar.bz2 > plexamp.tar.bz2
curl https://plexamp.plex.tv/headless/Plexamp-Linux-headless-v4.10.1.tar.bz2 > plexamp.tar.bz2
tar -xvf plexamp.tar.bz2
# node plexamp/js/index.js
# For more options and information see
# http://rpf.io/configtxt
# Some settings may impact device functionality. See link above for details
# uncomment if you get no picture on HDMI for a default "safe" mode
#hdmi_safe=1
# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border
#overscan_left=16
#overscan_right=16
#overscan_top=16
#overscan_bottom=16
# uncomment to force a console size. By default it will be display's size minus
# overscan.
#framebuffer_width=1280
#framebuffer_height=720
# uncomment if hdmi display is not detected and composite is being output
# Tim uncommented
hdmi_force_hotplug=1
# uncomment to force a specific HDMI mode (this will force VGA)
#hdmi_group=1
#hdmi_mode=1
# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes
# Tim uncommented this
hdmi_drive=2
# uncomment to increase signal to HDMI, if you have interference, blanking, or
# no display
#config_hdmi_boost=4
# uncomment for composite PAL
#sdtv_mode=2
#uncomment to overclock the arm. 700 MHz is the default.
#arm_freq=800
# Uncomment some or all of these to enable the optional hardware interfaces
#dtparam=i2c_arm=on
#dtparam=i2s=on
#dtparam=spi=on
# Uncomment this to enable infrared communication.
#dtoverlay=gpio-ir,gpio_pin=17
#dtoverlay=gpio-ir-tx,gpio_pin=18
# Additional overlays and parameters are documented /boot/overlays/README
# Enable audio (loads snd_bcm2835)
dtparam=audio=on
# Automatically load overlays for detected cameras
camera_auto_detect=1
# Automatically load overlays for detected DSI displays
display_auto_detect=1
# Enable DRM VC4 V3D driver
# Tim modif from dtoverlay=vc4-kms-v3d to dtoverlay=vc4-fkms-v3d
#dtoverlay=vc4-kms-v3d
dtoverlay=vc4-fkms-v3d
max_framebuffers=2
# Disable compensation for displays with overscan
disable_overscan=1
[cm4]
# Enable host mode on the 2711 built-in XHCI USB controller.
# This line should be removed if the legacy DWC2 controller is required
# (e.g. for USB device mode) or if USB support is not required.
otg_mode=1
[all]
[pi4]
# Run as fast as firmware / board allows
arm_boost=1
[all]
disable_splash=1

Test audio on raspberry pi

speaker-test -c2 -twav -l7

Turn the HDMI output on and off

If you are connected to Raspberry Pi via SSH, then you can switch the HDMI interface and thus the HDMI monitor on and off.

Turn off the HDMI monitor:

vcgencmd display_power 0

Turn on the HDMI monitor:

vcgencmd display_power 1

Switch on the HDMI output afterward

If Raspberry Pi is started without a connected monitor (without Plug and Play), the HDMI output will remain off. You can subsequently use the HDMI output during operation.

/opt/vc/bin/tvservice -p

It then goes to the monitor, but the picture remains black. But it should be displayed on the screen again something.

For the GUI display:

/opt/vc/bin/tvservice -p; sudo /bin/chvt 6; sudo/bin/chvt 7

For the console:

/opt/vc/bin/tvservice -p; sudo /bin/chvt 2; sudo /bin/chvt 1

Disable HDMI output:

/opt/vc/bin/tvservice -o

Show the status of the HDMI output:

/opt/vc/bin/tvservice -s

Turn on plug-and-play on the HDMI output

When operating Raspberry Pi on a screen, it is important to note that the screen must first be connected to Raspberry Pi and turned on before operating Raspberry Pi with a power adapter. If you forget to connect it before turning on the screen, then you will not get an HDMI signal from Raspberry Pi. The reason is simple. When Raspberry Pi goes into operation, it checks to see if a screen is connected. If not, it turns off the HDMI interface. During operation, it is then no longer checked whether a screen is connected. Therefore, a screen does not receive an HDMI signal when subsequently switching on and connecting. By default, Raspberry Pi does not have plug-and-play, as you would expect with a PC. However, you can turn it on later. Turn on plug-and-play on the HDMI output To do this, open the boot configuration:

sudo nano /boot/config.txt

Then insert the following line here:

hdmi_force_hotplug = 1

Save, close and restart.

Turn off monitor standby on the HDMI output

Normally, when the user is inactive, the monitor will eventually be turned off or put into standby. Most operating systems are set by default to turn off the screen after a set amount of time. If you then move the mouse or operate the keyboard, the display will turn on again. But there are also situations where you do not want the screen to go out.

task

  • Turn off the standby function for the monitor or screen so that the screen always remains on.

solutions

To permanently activate a monitor there are many different solutions. Depending on the requirement, the system and the environment, one or the other solution will not work or will be completely eliminated. If necessary, you have to try several solutions.

  1. Temporarily switch off monitor standby in the desktop
  2. Switch off monitor standby in the desktop permanently
  3. Alternative with lightdm
  4. Alternative that works on the desktop and the command line
  5. Another alternative that works on the desktop and the command line
  6. Alternative for the command line

Note: “Desktop” means the LXDE or PIXEL desktop used by Raspbian.

Solution 1: Temporarily turn off monitor standby in the desktop

To control the power-saving features of the X server, you must first install a package.

sudo apt-get install x11-xserver-utils

The following commands are then entered directly on the command line. But only via screen and keyboard. That does not work over SSH.

xset s off
xset -dpms
xset s noblank

The problem here is that the next time you log in or restart, these settings will be lost.

Solution 2: Permanently turn off monitor standby in the LXDE desktop

To do this, we open the following configuration file, which is automatically executed when the current user logs in.

nano .config /lxsession/lxde-pi/autostart

Here we enter the following lines:

@ xset s noblank
@xset s off
@xset -dpms

Then restart, log in again and check if the settings have been applied.

xset q

The following information must be available:

Screen Saver:
prefer blanking: no ...
...
DPMS is disabled

Solution 3: Alternative with lightdm

Open a configuration file:

sudo nano /etc/lightdm/lightdm.conf

In the section “[SeatDefaults]” enter the following line:

xserver-command = X -s 0 dpms

Solution 4: Alternative that works on the desktop and the command line

To do this, add the following lines to the file “/etc/rc.local” before the “exit”:

xset s off
xset -dpms

Or:

# Disable console blanking
setterm -blank 0 -powerdown 0

Save and close the file and reboot the system for the setting to take effect.

Solution 5: Another alternative that works on the desktop and the command line

Note: It is likely that this boot parameter may eventually be discontinued. Open a configuration file:

sudo nano /boot/cmdline.txt

Add the following parameter at the back:

console blank = 0

Solution 6: Alternative for the command line

Open a configuration file:

sudo nano /etc/kbd/config

Here we enter the following lines:

BLANK_TIME = 0
POWERDOWN_TIME = 0

Set the screen resolution on the HDMI output

In general, the resolution (width and height) of Raspberry Pi’s screen display is based on the native resolution of the HDMI screen. And that usually automatically. That means, actually one does not have to adjust at the dissolution.

Unfortunately, the automatic resolution detection for the HDMI screen has the disadvantage that if no screen is connected at boot, then set a minimum resolution that can not be changed later. This is a problem if you later want to turn on the screen or start a VNC session on the current screen.

In such cases you have to set the resolution on the HDMI interface.

Note: The disadvantage is that if you later connect a screen that does not control this resolution, then the screen display may no longer work. That should be considered.

Task

  • Determine which resolutions the monitor controls.
  • Set the desired resolution.

Solution: Detect supported resolutions of the current screen

If you have decided on a screen that can be used later to ensure the screen display, check which resolutions this screen supports.

There are two operating modes: CEA and DMT. We are only interested in DMT.

Supported resolutions of the HDMI screen with CEA:

/opt/vc/bin/tvservice -m CEA

Supported resolutions of the HDMI screen with DMT:

/opt/vc/bin/tvservice -m DMT

And then let’s see the current resolution of the connected screen:

/opt/vc/bin/tvservice -s

As a rule, you will opt for this automatically set resolution.

Solution: Fix the resolution

The resolution can be set in the following configuration file:

sudo nano /boot/config.txt

First, let’s make a meaningful basic configuration. The following lines are simply added in the file below.

# HDMI without monitor in operation (optional)
hdmi_force_hotplug = 1
# Output audio via HDMI (optional)
hdmi_drive = 2
# Enable DMT operation mode
hdmi_group = 2

Then we set the resolution to DMT (only one of them):

# Resolution: 1024x768 / 60 Hz
hdmi_mode = 16
# Resolution: 1280x768 / 60 Hz
hdmi_mode = 23
# Resolution: 1366x768 / 60 Hz
hdmi_mode = 81
# Resolution: 1920x1080 / 60 Hz (1080p)
hdmi_mode = 82

These resolutions are examples that not every screen supports.

There are other resolutions for DMT. You can find a complete list here. If possible, choose a resolution supported by the screen. The best one that automatically adjusts itself when connecting this screen.

solution: Set resolution with “raspi-config”

In the configuration tool “raspi-config” under “Advanced Options / Resolution” there is the possibility to set the resolution.

sudo raspi-config

VGA projector or monitor with an HDMI adapter

For screen output, Raspberry Pi has an HDMI and a composite output. Typically, you will run Raspberry Pi with an HDMI screen. That’s the easiest. Unfortunately, one does not always have an HDMI screen available. Often there are still old VGA screens around, but are just as well suited for the image output. There is only one HDMI adapter needed, which has a VGA output. Such an HDMI adapter converts the digital image signal into an analog VGA signal and provides the necessary signal output at the VGA connection.

Unfortunately, this only works conditionally. An HDMI adapter is quickly purchased, but the VGA screen does not always work on it by “plug and play”. This is not the HDMI adapter or the VGA screen, but simply because Raspberry Pi does not provide the right signal.

Note: When operating a VGA monitor via the HDMI adapter, it is notable that the monitor and HDMI adapter must be connected when turning on Raspberry Pi. If the monitor and adapter are connected to Raspberry Pi during operation, the monitor reports “No Signal”. The HDMI adapter is probably initialized during booting, which is not possible during operation.

Task

  • Set the boot configuration of Raspberry Pi so that you can operate a VGA monitor via an HDMI adapter on Raspberry Pi’s HDMI port.

Solution via SSH

First, open the configuration file that corresponds to the BIOS settings of a modern PC.

sudo nano /boot/config.txt

In the file, look for the following two settings, comment on them and set them to the following values.

hdmi_group = 2
hdmi_mode = 16

This sets HDMI to 1024 x 768 at 60 Hz. Then save and exit with: Ctrl + O, Enter, Ctrl + X

Note: Depending on the manufacturer-specific screen resolution and the HDMI adapter, other values may be necessary ( further display values ).

Then a reboot is necessary.

sudo reboot

If after the restart the image representation is complete and flicker-free, then correct resolution for the screen was selected.

Solution on another computer

Insert the SD card into the memory card reader of any computer. Then open the file “config.txt” in the drive “BOOT” with a text editor.

In the file, look for the following two settings, remove the hash (‘#’) and set it to the following values.

hdmi_group = 2
hdmi_mode = 16

This sets HDMI to 1024 x 768 at 60 Hz. Depending on the manufacturer-defined resolution of the screen, other values may be necessary.

Then you take the SD card with a Raspberry Pi in operation and checks the image display on the VGA screen. If after the restart the image representation is complete and flicker-free, then correct resolution for the screen was selected.

Audio output for the adapter

Some VGA-HDMI adapters also have an audio output, which usually works only with an external power supply. The following setting in the file “config.txt” has already made so many times that sound came from the adapter.

hdmi_drive = 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment