Update the device (kernel should be >= 6.1)
sudo apt update && sudo apt upgrade -yEnable USB Gadget and g_audio
echo "dtoverlay=dwc2" | sudo tee -a /boot/config.txt
echo "dwc2" | sudo tee -a /etc/modules
echo "g_audio" | sudo tee -a /etc/modules
sudo rebootValidate the result
dmesg | grep -iE "g_audio|dwc2"
# Expected output:
[ 2.981896] dwc2 fe980000.usb: supply vusb_d not found, using dummy regulator
[ 2.982209] dwc2 fe980000.usb: supply vusb_a not found, using dummy regulator
[ 3.190674] dwc2 fe980000.usb: EPs: 8, dedicated fifos, 4080 entries in SPRAM
[ 3.191356] dwc2 fe980000.usb: DWC OTG Controller
[ 3.191410] dwc2 fe980000.usb: new USB bus registered, assigned bus number 3
[ 3.191483] dwc2 fe980000.usb: irq 39, io mem 0xfe980000
[ 3.191919] usb usb3: Manufacturer: Linux 6.1.0-rpi7-rpi-v8 dwc2_hsotg
[ 5.661701] g_audio gadget.0: Linux USB Audio Gadget, version: Feb 2, 2012
[ 5.661755] g_audio gadget.0: g_audio ready
[ 5.661785] dwc2 fe980000.usb: bound driver g_audio
[ 5.838324] dwc2 fe980000.usb: new device is high-speed
[ 5.871874] dwc2 fe980000.usb: new address 51
[ 6.045460] dwc2 fe980000.usb: dwc2_hsotg_ep_sethalt(ep 00000000745eb641 ep1in, 0)Set g_audio params on boot
sudo echo "options g_audio c_srate=96000 c_ssize=4 p_srate=96000 p_ssize=4 iManufacturer="Linux Foundation" iProduct="Multifunction Composite Gadget" idProduct=0x0104 idVendor=0x1d6b" > /etc/modprobe.d/g_audio.confInstall pipewire and bluetooth packages
sudo apt install pipewire wireplumber libspa-0.2-bluetoothConnect your bluetooth device
MAC_ADDRESS=<MAC_ADDRESS>
echo "Pairing and connecting to $MAC_ADDRESS"
coproc bluetoothctl
echo -e 'agent on\npair $MAC_ADDRESS\ntrust $MAC_ADDRESS\nconnect $MAC_ADDRESS\nexit' >&p
output=$(cat <&p)
echo $outputList pipewire inputs
pw-link -iList pipewire outputs
pw-link -oConnect an input (USB interface) to an output (bluetooth device)
pw-link alsa_input.platform-fe980000.usb.stereo-fallback:capture_FR bluez_output.$MAC_ADDRESS.1:playback_FR
pw-link alsa_input.platform-fe980000.usb.stereo-fallback:capture_FL bluez_output.$MAC_ADDRESS.1:playback_FLThe same can be done to connect an input (USB mic) to an output (USB interface)
pw-link alsa_input.usb-Microphone-00.mono-fallback:capture_MONO alsa_output.platform-fe980000.usb.stereo-fallback:playback_FL
pw-link alsa_input.usb-Microphone-00.mono-fallback:capture_MONO alsa_output.platform-fe980000.usb.stereo-fallback:playback_FRMake a simple shell script called pw-connect.sh
#!/bin/bash
while true; do
# Send audio from USB to BT
pw-link alsa_input.platform-fe980000.usb.stereo-fallback:capture_FL <YOUR_OUTPUT_DEVICE>
pw-link alsa_input.platform-fe980000.usb.stereo-fallback:capture_FR <YOUR_OUTPUT_DEVICE>
# Send audio from MIC to USB
pw-link <YOUR_INPUT_DEVICE> alsa_output.platform-fe980000.usb.stereo-fallback:playback_FL
pw-link <YOUR_INPUT_DEVICE> alsa_output.platform-fe980000.usb.stereo-fallback:playback_FR
sleep 1
done
Make a user service to run on boot with sudo nano /etx/systemd/user/pw-connect.service
[Unit]
Description=Pipewire auto link audio streams
[Service]
Type=simple
#User=
#Group=
ExecStart=<PATH_TO_FILE>/pw-connect.sh
Restart=on-failure
StandardOutput=file:%h/log_file
[Install]
WantedBy=default.targetEnable and start the user service
systemctl --user daemon-reload
systemctl --user --now enable pw-connect.serviceJust reboot and it should be working!
sudo reboot