Mason Fleck
Published © GPL3+

RPi Zero 2 W Audio Gadget

The basics of turning a Raspberry Pi Zero 2 W into a USB OTG audio interface using the Linux gadget g_audio driver.

IntermediateProtip4 hours17,505
RPi Zero 2 W Audio Gadget

Things used in this project

Hardware components

Raspberry Pi Zero 2 W
Any Pi (or really any Linux-compatible ARM board) with USB OTG capability should work.
×1
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
Data cable for streaming audio.
×1
Micro SD Card
×1
5V Power Supply (Micro USB)
×1

Software apps and online services

Raspberry Pi OS Lite
Raspberry Pi Imager

Story

Read more

Schematics

Wiring Schematic

Code

Enable USB OTG, g_audio, Kernel Build on RPi Zero 2 W

SH
A (mostly) copy/paste-able version of the guide. Note: this leaves out a few configuration and verification steps that technically aren't required, but they are recommended.
sudo apt update && sudo apt upgrade -y
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 apt install screen git bc bison flex libssl-dev make libncurses5-dev -y
git clone --depth=1 --branch rpi-5.18.y https://github.com/raspberrypi/linux
cd linux
KERNEL=kernel7
make bcm2709_defconfig
make -j4 zImage modules dtbs
sudo make modules_install
sudo cp arch/arm/boot/dts/*.dtb /boot/
sudo cp arch/arm/boot/dts/overlays/*.dtb* /boot/overlays/
sudo cp arch/arm/boot/dts/overlays/README /boot/overlays/
sudo cp arch/arm/boot/zImage /boot/$KERNEL.img
sudo reboot

Credits

Mason Fleck

Mason Fleck

4 projects • 9 followers
I enjoy building electronics such as computers, audio amps/systems, and some random projects.

Comments