11

How can I use Raspberry Pi 3 as a USB gadget. Is there any way?

How can I enable the USB gadget mode on Raspberry Pi?

Aurora0001
  • 6,308
  • 3
  • 23
  • 38
Naveen
  • 121
  • 1
  • 1
  • 3
  • 1
    What do you mean by USB gadget? Do you wan't it to act as a slave device like USB flash drive? – Mark Aug 24 '17 at 08:59
  • It might be possible, but I don't know of any exact way to do it. What is it you want to achieve? What kind of device do you want the Pi to behave like? The Raspberry Pi Zero is probably easier to get to work as a gadget since it has the right kind of connection, but the real question is what you want it to do, and what you want to send back and forth between the gadget and the host. – Bex Aug 24 '17 at 11:52
  • 1
    @Mark "gadget" is linux slang for whatever device has the b-type USB connection. – Bex Aug 24 '17 at 11:54
  • 4
  • Here i found this wonderful tutorial http://isticktoit.net/?p=1383 You just need to follow it for the type of gadget you need which you did not specify. –  Aug 25 '17 at 11:44

1 Answers1

14

You cannot use the Raspberry Pi 3 as a USB gadget. At the time of writing this is only possible on the Raspberry Pi 0, 0W, A, A+, and 4. The Pi B, B+, 2, 3, 3A+, and 3B+ lack the required pin for OTG.

If you have a Pi Zero, this gist has some examples that work with minimal configuration like g_serial, g_ether, or g_multi. For example, a minimal way to enable the serial gadget is to add dtoverlay=dwc2 to /boot/config.txt and g_serial to /etc/modules

lukas2005's original answer linked to iSticktoit.net's examples of using the more modern ConfigFS approach. The keyboard HID example is a good one to start with. And when you have only one functional micro-USB port, it becomes particularly valuable to configure multiple gadgets at a time, something that is not as readily available with the old g_* kernel modules.

jdonald
  • 2,904
  • 12
  • 39
  • 1
    About lukas2005's answer: it may have gotten downvoted because the provided link is about the RPi zero (and variants) while the OP asks about RPi 3 (I didn't downvote, and the link is very useful indeed). – calocedrus Jan 24 '18 at 01:55
  • Can you tell how to do USB 3.0 gadget on RPi 4? – Kozuch Sep 06 '19 at 01:12
  • @Kozuch are you having trouble with setting up a gadget on the Pi 4 in the first place? Here is one of the simplest tutorials. Or you mean you're not getting USB 3.0 transfer speeds (which would warrant opening a new question)? – jdonald Sep 06 '19 at 15:31
  • I have not tried anything yet, just asking whether it is possible to do USB 3.0 OTG. It surely is not via the USB-C connector on Pi 4 since according to schematics it only connects to USB 2.0 lanes. So can you tell about USB 3.0 - is it possible via the Type-A connectors? Probably not? – Kozuch Sep 06 '19 at 16:15
  • 1
    I asked a new question here: https://raspberrypi.stackexchange.com/questions/102294/usb-3-0-otg-on-raspberry-pi-4-usb-gadget – Kozuch Sep 06 '19 at 16:24