Jarkko's guides
You are here: Home » Raspberry Pi » USB gadget

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

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.
Previous Next

ALL THE TOPICS ON THIS WEBSITE:

Linux

Raspberry Pi

Digital room correction

Web design

By Jarkko Huijts
Jarkko's guides

Table of Contents

Table of Contents

  • USB gadget
    • Pi as USB device
    • Pi as USB audio device
    • Powering the Pi 5

RASPBERRY PI HARDWARE

  • Intro
  • Pinning & interfaces
  • Audio components
  • FLIRC for IR remotes
  • Small displays
  • USB gadget
  • Linux groups

RASPBERRY PI SOFTWARE

  • SD card images
  • CamillaDSP
  • Raspotify

MY DRC SET-UP

  • Overview
  • Spectrum analyzer

AVAILABLE TOPICS

  • Linux
  • Raspberry Pi
  • Digital room correction
  • Web design