• Welcome to ASR. There are many reviews of audio hardware and expert members to help answer your questions. Click here to have your audio equipment measured for free!

RPi + CamillaDSP Tutorial

Does anyone know or have tried adding a Toslink connector to the HiFiBerry Digi B+ so it can receive a signal via optical? There's space for it on the board, but it's unclear whether it works.
 
Anyone upgrade Pi OS bookworm to trixie?
I have a RPi 5 dedicated to running CamillaDSP and a RPi 3+ dedicated to running Klipper/Mainsail for my 3D printer. Both still are running on Bookworm, and everything works. With Bookworm receiving security support until June, and then another 2 years of LTS support, I'm coming up blank when searching for a compelling reason to upgrade right now.
 
I haven't tried Trixie yet. Nothing major usually changes between releases, but sometimes they change what is installed by default which may require additional installation of dependencies. The most painful thing was when they finally killed rpi-gpio (which was used for the OLED display), but that is the only major change I recall.

Good to hear that the existing instructions seem to work.

Michael
 
I haven't tried Trixie yet. Nothing major usually changes between releases, but sometimes they change what is installed by default which may require additional installation of dependencies. The most painful thing was when they finally killed rpi-gpio (which was used for the OLED display), but that is the only major change I recall.

Good to hear that the existing instructions seem to work.

Michael
I used this to upgrade in place. For some reason I had to do "sudo apt install python3-lgpio" to get my display working again but that was the only issue.
 
I used this to upgrade in place.

Partially out of curiosity, partially out of boredom, I gave upgrading to Trixie a shot. CamillaDSP continued working as normal, which means it will be fine for most people.

However, the upgrade broke both USB Gadget and camilladsp-setrate. camilladsp-setrate was the easiest to fix. I made sure git, build-essential and libasound2-dev all were installed, and did a clean re-install/rebuild of camilladsp-setrate. Then I did a daemon-reload, and enabled and started the new installation of camilladsp-setrate.

USB Gadget was a little more involved. Apparently Trixie handles USB Gadget a bit differently. (EDIT: This only is an issue if upgrading, not with a fresh install.) Here is how I got it working:

1. In /boot/firmware/config.txt I changed the dr_mode to peripheral:

[cm5]
dtoverlay=dwc2,dr_mode=peripheral


2. In /boot/firmware/cmdline.txt I changed the "modules-load" statement after "rootwait" to be as follows:

modules-load=dwc2,libcomposite


3. I created a USB Audio Class gadget: /usr/local/sbin/usb-audio-gadget.sh:

#!/bin/bash
G=/sys/kernel/config/usb_gadget/audio

modprobe libcomposite

mkdir -p $G
cd $G

echo 0x1d6b > idVendor # Linux Foundation
echo 0x0104 > idProduct # Multifunction Composite Gadget
echo 0x0100 > bcdDevice
echo 0x0200 > bcdUSB

mkdir -p strings/0x409
echo "123456789" > strings/0x409/serialnumber
echo "Raspberry Pi" > strings/0x409/manufacturer
echo "USB Audio Device" > strings/0x409/product

mkdir -p configs/c.1
mkdir -p configs/c.1/strings/0x409
echo "USB Audio Config" > configs/c.1/strings/0x409/configuration

# Create USB Audio Class Function (UAC2)
mkdir -p functions/uac2.usb0
# Playback: WiiM → Pi
echo 2 > functions/uac2.usb0/c_chmask # 2 channels input to Pi
echo 48000 > functions/uac2.usb0/c_srate # 48 kHz
# If Pi also needs to OUTPUT audio, enable playback:
echo 2 > functions/uac2.usb0/p_chmask
echo 48000 > functions/uac2.usb0/p_srate

ln -s functions/uac2.usb0 configs/c.1/

# Bind to UDC controller
ls /sys/class/udc > UDC


4. I made the new gadget executable:

sudo chmod +x /usr/local/sbin/usb-audio-gadget.sh


5. I created a service for the new gadget as /etc/systemd/system/usb-audio-gadget.service:

[Unit]
Description=USB Audio Gadget
After=multi-user.target

[Service]
Type=oneshot
ExecStart=/usr/local/sbin/usb-audio-gadget.sh
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target


6. I enabled the new service:

sudo systemctl enable usb-audio-gadget


7. I rebooted.

NOTE: I do not know whether creating a new gadget is the simplest, most straight forward way to get gadget mode working with Trixie. There may be a simpler solution. But, after running out of things to try to get it working, I worked with ChatGPT to help me solve the problem. That is the solution ChatGPT recommended that worked.
 
Last edited:
I don't use either of those.
Most people probably don't.

USB Gadget allows the Raspberry Pi to receive a digital audio stream via its USB C connector. I use it to stream from my WiiM Ultra to my Raspberry Pi.

camilladsp-setrate changes the samplerate of CamillaDSP to the samplerate of the music stream. I use it because, when the streaming is set to "Max", Tidal will stream at whatever samplerate the song is recorded; it varies between 44.1k, 48k, 96k and 192k.

EDIT: The reason for the long post was to share the solutions with others that may encounter the same issues.
 
Last edited:
Apparently Trixie handles USB Gadget a bit differently.
Your description is the recommended configfs way which allows to configure all features of the gadget. The g_audio module is a hardcoded composite driver which implements only some options of the gadget. In addition it allows to configure multiple devices along with the audio one - handy e.g. for network control via web browser.

Is the g_audio module not compiled with the trixie kernel? The config in rpi repo looks like that module should be compiled https://github.com/raspberrypi/linux/blob/rpi-6.12.y/arch/arm64/configs/bcm2711_defconfig#L1138
 
I do not have your chain. But the way to go is to troubleshoot your issue. DId you check the possible volume controls and their value?
 
Is the g_audio module not compiled with the trixie kernel? The config in rpi repo looks like that module should be compiled https://github.com/raspberrypi/linux/blob/rpi-6.12.y/arch/arm64/configs/bcm2711_defconfig#L1138

I don't know. Reflecting on the issue and the solution, I would not be surprised if the issue only shows up when upgrading from a previous version, but not with a clean install. Sometimes Linux upgrades leave artifacts hanging around and/or dependency issues that adversely afffect fringe cases not tested by the development team. In that regard, the Raspberry Pi OS team recommends against an upgrade in favor of a clean install, which is what I always have done in the past. I figured I would give upgrading a shot this time to see if it would work.
 
I have confirmed the issue only occurs when upgrading, and not with a fresh install. :)

I have a spare SD card, so I did a fresh install of latest version Raspberry Pi OS Lite, based on Trixie. It went without any hitches whatsoever and USB Gadget works following Michael's activation procedure.
 
Last edited:
Back
Top Bottom