trejan
Posts: 715
Joined: Tue Jul 02, 2019 2:28 pm

RPi 4 USB-C socket as host

Sat Jul 20, 2019 7:05 pm

This is probably useless for the vast majority of people.

The USB-C socket on the RPi 4 is officially meant to be device only but you can still use it as a host port if you have a USB-A to USB-C adapter. Add "dtoverlay=dwc2,dr_mode=host" to /boot/config.txt to force the internal USB controller to host mode. You'll need to use an alternate method of powering the RPi 4 such as PoE or via the expansion header.

Plugging in an actual USB-C device may not work as the RPi 4 doesn't implement the CC1/CC2 signalling needed. A USB-A to USB-C adapter does work but you need to force it into host mode.

I did it because of some issues with a specific USB device and using any other bulk device at the same time would cause problems with timing. Swapped one of them over to the DWC controller and both work fine together.
Last edited by trejan on Sun Jul 21, 2019 12:13 am, edited 1 time in total.

andrum99
Posts: 843
Joined: Fri Jul 20, 2012 2:41 pm

Re: RPi 4 USB-C socket as host

Sat Jul 20, 2019 9:51 pm

trejan wrote:
Sat Jul 20, 2019 7:05 pm
The USB-C socket on the RPi 4 is officially meant to be device only
No its not. It officially supports both device mode and host mode, as it is the same USB controller on the BCM283x SoC used on all previous models of Raspberry Pi. The type A USB ports on the Pi use the new VLI controller, which was added in addition to the USB controller built into the SoC.

trejan
Posts: 715
Joined: Tue Jul 02, 2019 2:28 pm

Re: RPi 4 USB-C socket as host

Sat Jul 20, 2019 10:16 pm

andrum99 wrote:
Sat Jul 20, 2019 9:51 pm
No its not. It officially supports both device mode and host mode, as it is the same USB controller on the BCM283x SoC used on all previous models of Raspberry Pi. The type A USB ports on the Pi use the new VLI controller, which was added in addition to the USB controller built into the SoC.
Yes. It is. I know it has the same DWC controller as before and it does do both hence the dtoverlay line to force it into host mode. However, the documentation specifically says it is meant to be used in the USB device mode only.

https://www.raspberrypi.org/documentati ... erview_pi4
The OTG hardware present on previous models of Pi is still available and it has moved to a single connection on the USB-C port. The OTG hardware is intended to be used in device-only mode on Pi 4.
It doesn't automatically switch between host and device mode so you have to add the dtoverlay line if you want host mode.

drgeoff
Posts: 9885
Joined: Wed Jan 25, 2012 6:39 pm

Re: RPi 4 USB-C socket as host

Sat Jul 20, 2019 11:13 pm

It that is what the documentation is really meant to say it is badly written.

"The OTG hardware is intended to be used in device-only mode on Pi 4." would be "The OTG hardware is intended to be used only in device mode on Pi 4."

But if that was what the documentation should say then the means to operate in host mode (via the dtoverlay) would not be provided.

plugwash
Forum Moderator
Forum Moderator
Posts: 3462
Joined: Wed Dec 28, 2011 11:45 pm

Re: RPi 4 USB-C socket as host

Sat Jul 20, 2019 11:32 pm

As I understand it the issue is that the USB C detection wiring is not set up for dual role, this means two things.

1. You have to force the mode to use the port in host mode because the Pi can't detect that what is plugged in is a device and not a host.
2. You may have problems if you use a C to C cable because the device may think it's connected to another device. Using a C plug to A socket adapter along with an A plug to C plug lead should avoid this.

trejan
Posts: 715
Joined: Tue Jul 02, 2019 2:28 pm

Re: RPi 4 USB-C socket as host

Sun Jul 21, 2019 12:11 am

What plugwash said.

It can't automatically switch between host and device mode on a RPi 4 because of the USB-C connector. USB OTG determines which end is what role by the ID pin in a micro USB connector but that doesn't exist in a USB-C connector. USB-C Dual Role does the detection with the CC1/CC2 pins and toggles those between pull up and pull down. The RPi 4 doesn't implement any of that.

If you wanted to make the USB-C socket into a dual role port then you'll need to add something like a TI TUSB320 which implements all of the CC signalling internally and generates an ID output for the USB OTG controller. It'll use up valuable PCB space and be an additional cost for a feature that most people will never use.

I'll update my initial post to say this is with a USB-A to USB-C adapter. YMMV for everything else.
drgeoff wrote:
Sat Jul 20, 2019 11:13 pm
But if that was what the documentation should say then the means to operate in host mode (via the dtoverlay) would not be provided.
That overlay was added back in 2016 so it isn't something specific to the RPi 4.

jdb
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2116
Joined: Thu Jul 11, 2013 2:37 pm

Re: RPi 4 USB-C socket as host

Sun Jul 21, 2019 10:30 am

Can someone try the config.txt parameter "otg_mode=1"?

This swaps the DWC controller out for an xhci host-only controller on the USBC USB2.0 pins. No guarantees about which configurations this will work with, though.

drgeoff wrote:
Sat Jul 20, 2019 11:13 pm
It that is what the documentation is really meant to say it is badly written.

"The OTG hardware is intended to be used in device-only mode on Pi 4." would be "The OTG hardware is intended to be used only in device mode on Pi 4."

But if that was what the documentation should say then the means to operate in host mode (via the dtoverlay) would not be provided.
As plugwash said, the OTG ID pin is not connected to anything inside the USBC port so device operation is assumed. There is no hardware mechanism available to say that the port *should* operate in host mode. Cable hacks or forcing via devicetree will work, but is not a generally supported use case.
Rockets are loud.
https://astro-pi.org

trejan
Posts: 715
Joined: Tue Jul 02, 2019 2:28 pm

Re: RPi 4 USB-C socket as host

Sun Jul 21, 2019 10:57 am

jdb wrote:
Sun Jul 21, 2019 10:30 am
Can someone try the config.txt parameter "otg_mode=1"?

This swaps the DWC controller out for an xhci host-only controller on the USBC USB2.0 pins. No guarantees about which configurations this will work with, though.
Didn't work for me. The XHCI controller does appear but doesn't see my device. dmesg doesn't say anything.

I was wondering how to enable the internal XHCI controller in the devicetree. Changing the status from disabled to okay didn't do anything when I tried it the other day.

hippy
Posts: 6071
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: RPi 4 USB-C socket as host

Sun Jul 21, 2019 1:50 pm

andrum99 wrote:
Sat Jul 20, 2019 9:51 pm
trejan wrote:
Sat Jul 20, 2019 7:05 pm
The USB-C socket on the RPi 4 is officially meant to be device only
No its not. It officially supports both device mode and host mode, as it is the same USB controller on the BCM283x SoC used on all previous models of Raspberry Pi.
The best way to describe the situation is probably "the Pi 4B USB-C socket allows it to be a USB-C device or limited capability USB-C host but the Pi 4B is only officially a USB-C device due to its hardware configuration".

This was a timely topic as I was this morning buying bits to build a USB-C to USB-A socket 'OTG cable' - It answers the questions I had.

andrum99
Posts: 843
Joined: Fri Jul 20, 2012 2:41 pm

Re: RPi 4 USB-C socket as host

Sun Jul 21, 2019 9:00 pm

trejan wrote:
Sat Jul 20, 2019 10:16 pm
andrum99 wrote:
Sat Jul 20, 2019 9:51 pm
No its not. It officially supports both device mode and host mode, as it is the same USB controller on the BCM283x SoC used on all previous models of Raspberry Pi. The type A USB ports on the Pi use the new VLI controller, which was added in addition to the USB controller built into the SoC.
Yes. It is. I know it has the same DWC controller as before and it does do both hence the dtoverlay line to force it into host mode. However, the documentation specifically says it is meant to be used in the USB device mode only.

https://www.raspberrypi.org/documentati ... erview_pi4
The OTG hardware present on previous models of Pi is still available and it has moved to a single connection on the USB-C port. The OTG hardware is intended to be used in device-only mode on Pi 4.
It doesn't automatically switch between host and device mode so you have to add the dtoverlay line if you want host mode.
I didn't know the documentation said that. I was going on what James Hughes posted on one of the forums.

Return to “Advanced users”