More Pi4 Type-C issues (linux usb gadgets might not work when powered over gpio)

By | July 16, 2019

Since my previous post on they issues with the pi I have been doing some more experimenting with the USB-C port on the pi as a Linux gadget interface. As the pi4 has both host and client USB simultaneously (unlike previous versions) it makes it much easier alter the gadget code between tests. In doing so I discovered that my laptop wont enumerate the gadget in some situations due to more spec in-compliance.

A note on the pi’s “OTG” interface: An OTG USB interface supports both host and client modes, the newer term used for a Type C interface with this capability is a dual role device. While the pi’s SOC’S inbuilt USB interface supports both host and client mode the USB-C connector interface on the pi is only designed to support client mode (UFP in type C terminology).

This new issue occurs when the pi is powered over the 5V gpio pins as these are directly linked to the USB-C power pins, this causes the pi to emit power from the USB-C port (the USB-C spec prohibits this for clients (section 4.5.2.2.3.1 of the spec for anyone interested)). This causes some USB-C hosts to not enumerate the gadget when used with a C-C cable as it detects Vbus and fails to enter host mode. If the pi is powered by the USB host it will detect as there is no reverse Vbus to cause confusion during the port configuration phase.

Testing on some more devices my phone and the 3.0 USB-C port on my laptop detect the pi, these ports just use the CC resistors and ignore the presence of Vbus. The USB 3.1 on my laptop however doesn’t. As a test I also tried using some USB-A adaptors to rule out any CC issues, I Used a USB A-C cable attached to the pi and either a USB C-A adaptor or a USB hub with a C connector to the laptop and A ports at the laptop end. With this setup the order that things are plugged in generates different results, if the pi is plugged in first it wont detect but if the laptop is plugged in first it will. This makes logical sense as if the laptop is plugged in first it goes into host mode before it sees the Vbus from the pi. The oddest combination is to plug the C-A-C cable adaptor in with the pi being the host and the laptop as the client as the laptop enumerates the pi as a client in this configuration, the fact that this works is partly the fault of the laptop as it connects up its USB host pins in when connected in either host or client configuration.

There are some workarounds to this issue if you are encountering it. The first is to try a different USB-C port on the device you are connecting with as they might behave differently, alternatively a USB-A port with an A-C cable. Using a C-A then an A-C cable will also work if you plug the non pi end in first. in the longer term hopefully this will be fixed when the CC resistor issue is fixed.

2 thoughts on “More Pi4 Type-C issues (linux usb gadgets might not work when powered over gpio)

  1. George Jardine

    Thanks for the great articles, Tyler.

    I’m trying to figure out a way to connect a pi4 to my iPad Pro via usb-c for DATA, but not for power, because I am powering the pi from an 18650 powered UPS board.

    Is there such a thing as a “data only” usb-c cable that will work? Or am I barking up the wrong tree?

    Thanks in advance,
    George

    Reply
    1. Tyler Post author

      Hi George

      I havent come across a data only cable for USB-C atall, there is also no part of the spec that would cover such a cable. If you are having trouble getting the ipad do detect the pi you might have some success by using a USB-C to USB-A female adapter then a usb-A to usb-C cable to connect to the pi (plug the adapter in to the host device before connecting to the pi) as this works arround the port on the non pi end failing to enter client mode by making it do so before connecting the pi, Im not sure how the ipad will handle recieving voltage through its USB port when in client mode however. The other option is to modify a cable yourself to cut the vcc line.

      Thanks
      Tyler

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *