30

Came across some doubts:

  1. What exactly are the differences between a USB host and device? Is it just that who powers the bus?
  2. When two devices connect how the device say "hey I will be the host and you be the device?"
  3. Can one device acts as a host as well as a device. For example, "A" should act as a device when a USB host is connected, and "A" should act as host when a USB device is connected?
Melebius
  • 109
  • 5
Kozlov
  • 421
  • 1
  • 4
  • 4
  • 2
    This is directly and clearly answered right where you'd expect to find it, which is the USB spec, or even most introductory information on USB. -1 – Olin Lathrop Nov 18 '12 at 15:24
  • 2
    I would recommend that you read Jan Axelson's "USB Complete". It is a true gem on this subject matter. – quantum231 Jun 10 '13 at 10:55
  • 6
    @OlinLathrop Your comment is not helpful. The USB spec is 75 MiB in size and is composed of 43 PDF files with a total of 2984 pages. – Stéphane Jun 19 '16 at 13:12
  • 2
    @Stép: The USB spec also has a table of contents, and even the earlier and smaller specs answer these questions. These questions are *very basic* and show a complete lack of even attempting to find the answers. – Olin Lathrop Jun 19 '16 at 23:23
  • 7
    @OlinLathrop My attempt to use Google to find the answer to these exact questions is what took me to this question. This was the top Google search result. Came here and saw the recommendation to read/search through nearly 3000 pages! That's why I said the comment wasn't very helpful. – Stéphane Jun 21 '16 at 03:21
  • 1
    I just wanted to thank @quantum231 for referring me to the book by Jan Axelson. I read an excerpt on her site and immediately decided to buy it, until I found out the latest edition costs ~$40... But I didn't really need the latest specs with 3.1 and USB-C, so I just got a used fourth edition paperback for 14 bucks, it's up to date enough for me, includes USB 3.0, and, USB OTG, which stipulates the protocol when a host can also be a device, and vice versa, which would answer this question. I know the OP was years ago, but just wanted to mention that I found the reference material to be useful. – kumowoon1025 Dec 19 '17 at 17:35
  • A good article worth reading: https://cdn-learn.adafruit.com/downloads/pdf/turning-your-raspberry-pi-zero-into-a-usb-gadget.pdf – user197942 Sep 08 '18 at 04:40

2 Answers2

33

What exactly are the differences between a USB host and device?

The host initiates all communication on the bus, the device only responds when asked by the host. For Details see the specs on usb.org.

When two devices connect [...]

One must behave as the host and the other as the device. Details can be found in the USB OTG Specs.

Can one device acts as a host as well as a device?

For example, many Android phones and tablets can (requires Android 3+). The "magic" is in the On-the-Go cable/adapter, which switches the phone into host mode by pulling the ID pin to GND.

Turbo J
  • 9,969
  • 1
  • 20
  • 28
11

Just like Stéphane, I came here for the answer. Which I did not find here! With a little research this is what I found.

With a host controller you will be able to communicate with all USB devices, and with a USB device controller you can just communicate with a host controller.

USB host is the USB on the PC side in most cases and USB Device is the USB in your mouse ,keyboard, flash memory and so on.

All USB transactions are managed by the Host. and the Device only responses to the Host transactions.

Hope that helps.

Grumpy
  • 137
  • 1
  • 2
  • 5
    It's not clear what you are adding that has not already been said years ago. – Chris Stratton Apr 25 '17 at 03:09
  • 6
    He gave a slightly more thorough answer with concrete examples rather than sending you to the first page of a long and complex document. The selected answer is could have at least boil it down better – user148298 Aug 03 '18 at 23:28
  • From another point of view, it's unclear if an MCU can present two or more devices, i.e. a keyboard with a built-in trackpad. Is the MCU a host connected to two devices, or merely two separate devices with the PC as their host? – user148298 Mar 17 '23 at 17:37