

A set of such functionalities is called a configuration. And here comes what USB standard says: a USB device can provide more than one functionality over a single USB cable at a time. What is missing is actual functionality, for example mass storage or Ethernet over USB. But merely being able to drive a UDC is not enough to fully implement a USB device. The Linux kernel provides drivers for various UDCs. For the purpose of this post we will be using the term UDC. Oh, and one more thing: you can often come across the term OTG, which stands for on-the-go device and refers to chips which are capable of being either a host, or a device. More on dummy_hcd will be in another blogpost which I'm going to write soon.

The dummy_hcd combines an emulated host controller with an emulated device controller, so your machine acts as both a USB host and a device. If you don't have access to any hardware of this kind, fear not! You still can play (to some extent) with USB gadgets using an emulated UDC which is a part of the dummy_hcd kernel module. Other examples of suitably equipped boards are Odroid U3 and XU3, or Beagle Bone Black.

In the embedded world a UDC is very often a part of your system-on-chip (SoC), but beware: merely having a UDC inside SoC does not mean that it is actually connected to anything on the board.įor example Raspberry Pi Zero's SoC does contain a UDC and it is connected to one of the micro USB sockets on the board. The hardware supported by the Linux kernel can be found in drivers/usb/gadget/udc/Kconfig (line 306 in v5.0-rc6). In case of desktop PCs you most probably need a dedicated add-on card, which is not a very popular thing: there are not so many users who might want to convert their desktop PC into a USB device. The question you likely ask yourself is whether your machine has a UDC. It is exactly this case we will be talking about in this post.

One way of implementing a USB device is to have a machine running Linux, equipped with a special piece of hardware called USB Device Controller (UDC), and appropriate software running on it. The bus is host-centric, which means that all the activities happening on it are decided and directed by the host. On a given USB bus there can be only one host and many (up to 127) devices. The purpose of USB is to extend the host with some functionalities provided by devices: be it a mass storage device, an Ethernet card on USB, a sound card or the like. In USB there are two distinct roles: a host and a device. In order to understand what is a USB gadget we need to have a look at a broader picture. A look at how to implement USB gadget devices on Linux machines which have the necessary UDC hardware, automate the manual configfs process via declarative gadget "schemes", and use systemd for gadget composition at boot time.
