Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix path to config.txt for bookworm support #2298

Merged
merged 3 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion ci/Dockerfile.debian
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ FROM debian:${DEBIAN_CODENAME}-slim as base
ARG DEBIAN_CODENAME

ENV DOCKER_RUNNING=true
RUN touch /boot/cmdlinetxt

RUN export DEBIAN_FRONTEND=noninteractive \
&& echo "--- install packages (1) ---" \
Expand Down
9 changes: 5 additions & 4 deletions components/audio/PirateAudioHAT/README.md
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my point of view we could remove the manual description of the steps, which are done by the script.
Users should use the script and we would avoid duplication

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reworked the Readme

Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ NOTE: changes to the installation should find their way into the script `setup_p

1. Connect Pirate Audio Hat to your Raspberry Pi
2. Install Phoniebox (develop branch!)
3. Stop and disable the GPIO button service:
`sudo systemctl stop phoniebox-gpio-buttons.service`
`sudo systemctl disable phoniebox-gpio-buttons.service`
4. Add the following two lines to /boot/config.txt
3. Stop and disable the GPIO control service:
`sudo systemctl stop phoniebox-gpio-control.service`
`sudo systemctl disable phoniebox-gpio-control.service`
4. Add the following two lines to `config.txt`.
(Up to Bullseye, the `config.txt` file is located at `/boot/`. Since Bookworm, the location changed to `/boot/firmware/`, [see here](https://www.raspberrypi.com/documentation/computers/config_txt.html)).
`gpio=25=op,dh`
`dtoverlay=hifiberry-dac`
5. Add settings to /etc/asound.conf (create it, if it does not exist yet)
Expand Down
26 changes: 15 additions & 11 deletions components/audio/PirateAudioHAT/setup_pirateAudioHAT.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
HOME_DIR="/home/pi"
JUKEBOX_HOME_DIR="${HOME_DIR}/RPi-Jukebox-RFID"

source "${JUKEBOX_HOME_DIR}"/scripts/helperscripts/inc.systemHelper.sh

question() {
local question=$1
read -p "${question} (y/n)? " choice
Expand All @@ -16,22 +18,24 @@ question() {
printf "Please make sure that the Pirate Audio HAT is connected...\n"
question "Continue"

printf "Stopping and disabling GPIO button service...\n"
printf "Stopping and disabling GPIO control service...\n"
#TODO this might not be necessary
sudo systemctl stop phoniebox-gpio-buttons.service
s-martin marked this conversation as resolved.
Show resolved Hide resolved
sudo systemctl disable phoniebox-gpio-buttons.service

printf "Adding settings to /boot/config.txt...\n"
if [[ ! -f /boot/config.txt.bak ]]; then
sudo cp /boot/config.txt /boot/config.txt.bak
sudo systemctl stop phoniebox-gpio-control.service
sudo systemctl disable phoniebox-gpio-control.service

boot_config_path=$(get_boot_config_path)
boot_config_path_backup="${boot_config_path}.bak"
printf "Adding settings to ${boot_config_path}...\n"
if [[ ! -f "${boot_config_path_backup}" ]]; then
sudo cp "${boot_config_path}" "${boot_config_path_backup}"
fi

# Only add the two lines, if they do not exist already
if ! sudo grep -qe "gpio=25=op,dh" /boot/config.txt; then
echo "gpio=25=op,dh" | sudo tee -a /boot/config.txt > /dev/null
if ! sudo grep -qe "gpio=25=op,dh" "${boot_config_path}"; then
echo "gpio=25=op,dh" | sudo tee -a "${boot_config_path}" > /dev/null
fi
if ! sudo grep -qe "dtoverlay=hifiberry-dac" /boot/config.txt; then
echo "dtoverlay=hifiberry-dac" | sudo tee -a /boot/config.txt > /dev/null
if ! sudo grep -qe "dtoverlay=hifiberry-dac" "${boot_config_path}"; then
echo "dtoverlay=hifiberry-dac" | sudo tee -a "${boot_config_path}" > /dev/null
fi

printf "Adding settings to /etc/asound.conf...\n"
Expand Down
35 changes: 35 additions & 0 deletions scripts/helperscripts/inc.systemHelper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
is_raspbian() {
if [[ $( . /etc/os-release; printf '%s\n' "$ID"; ) == *"raspbian"* ]]; then
echo true
else
echo false
fi
}

get_debian_version_number() {
source /etc/os-release
echo "$VERSION_ID"
}

_get_boot_file_path() {
local filename="$1"
if [ "$(is_raspbian)" = true ]; then
local debian_version_number=$(get_debian_version_number)

# Bullseye and lower
if [ "$debian_version_number" -le 11 ]; then
echo "/boot/${filename}"
# Bookworm and higher
elif [ "$debian_version_number" -ge 12 ]; then
echo "/boot/firmware/${filename}"
else
echo "unknown"
fi
else
echo "unknown"
fi
}

get_boot_config_path() {
echo $(_get_boot_file_path "config.txt")
}
Loading