USB gadget
Pi as USB device
A computer (and therefore also the Raspberry Pi) is normally a USB host. Most Raspberry Pi generations (the Pi 4 and Pi 5, among others) can also behave as USB device. This is quite a hidden feature. I couldn't find information about in the official documentation, but some people figured this out and it is known now.
In the Raspberry Pi 5:
- This is only possible via the USB-C port, which can act as USB OTG (on-the-go)
- The USB controller is located inside the main chip (from Broadcom)
- It is the “DesignWare High-Speed USB 2.0 On-The-Go Controller” from Synopsys
- That explains the name “dwc2” for the kernel driver and overlay you need to use
Pi as USB audio device
The Pi can become a USB audio device (equivalent to e.g. a USB DAC or audio interface) that receives audio from a USB host:
%%{init: {'themeVariables': {'edgeLabelBackground':'white'}}}%%
flowchart LR
%% Custom styling
%%classDef analog fill:#EACCB9
%% Blocks
streamer(["USB host
(sends audio)"]) pi(["Pi
(USB device)"]) %% arrows streamer --> pi
(sends audio)"]) pi(["Pi
(USB device)"]) %% arrows streamer --> pi
Some devices that can be a USB host (that sends audio):
- PC
- Some streamers
- Nvidia Shield TV (2019) or Shield Pro
Guide to set this up on the Pi: https://github.com/mdsimon2/RPi-CamillaDS
Powering the Pi 5
Since the USB-C port is what you normally use to power the Pi, you need some way to connect data and power at the same time. Options include:
- It gets powered from the connected USB host (like a PC). What is awkward about this situation is that the Pi would suddenly lose power if you disconnect it. You should not let that happen, because it can corrupt the SD card.
- Use a USB-C data/power splitter, e.g. for sale on thepihut.com and tindie.com
- Connect a USB-C hub with PD passthrough (power delivery). Just like with the previous option you can then let the power come from a power adapter plugged into a wall socket.
- The Pi can be powered from the Ethernet connection if you use Power over Ethernet (PoE). See the documentation.
- It is possible to provide power towards the GPIO header (instead of using it as a power source), but this is hacky and can cause damage.