Powering a Pi4 while using USB OTG

for all subjects/topics not covered by the other forum categories
Post Reply
User avatar
sweh
Posts: 2363
Joined: Sat Mar 10, 2012 12:05 pm
Location: New York, New York
Contact:

Powering a Pi4 while using USB OTG

Post by sweh »

So a Pi 4 allows for the USB-C port to be used as USB On The Go. So, for example, if can be used as a HID device to send keystrokes or mouse movement.

The problem is the USB-C port is also how the Pi4 is powered, and most PC USB ports can't provide the 2A or so required. So the machine keeps crying about under-voltage

e.g.

Code: Select all

Oct 21 18:11:04 raspberrypi kernel: [  768.149000] Under-voltage detected! (0x00050005)
Oct 21 18:11:20 raspberrypi kernel: [  784.789281] Voltage normalised (0x00000000)
Oct 21 18:11:26 raspberrypi kernel: [  791.029440] Under-voltage detected! (0x00050005)
Oct 21 18:11:31 raspberrypi kernel: [  795.189462] Voltage normalised (0x00000000)
Oct 21 18:11:43 raspberrypi kernel: [  807.669649] Under-voltage detected! (0x00050005)
Oct 21 18:11:53 raspberrypi kernel: [  818.069758] Voltage normalised (0x00000000)
Now I could try powering the device by the GPIO pins. But now I'm wondering if that might cause issues with the PC also providing power and whether the Pi might cause the PC to break. I don't know enough USB nor the Pi internals.

So I thought I'd make a franken-cable. Took a USB-C cable and cut it in half. On the Pi side I reconnected the 5V and Gnd lines to the other half of the cable. Then for the data+/- lines I connect a second USB cable, but made sure the power lines weren't connected. The connections were made by wrapping the two half cables around each other and soldering them together with lots of solder.

So the resulting cable looks a bit like this.

Code: Select all

          -------Power + ------- USB power brick
          -------Gnd     -------
    USB C  
          -------Data + --------
          -------Data - -------- PC USB port
This works to power up the rPi.

The problem happens when I plug it into the PC port... I get a

Code: Select all

   hub 2-1:1.0: connect-debounce failed
I'm _guessing_ the connection needs to be better than a simple solder and that I'm getting some signal bounce at the junctions, but I'm out
of my depth.

Has anyone tried to make a cable like this?
Rgds
Stephen
cmorley
Posts: 1430
Joined: Sat Jul 30, 2016 8:11 pm
Location: Oxford
Contact:

Re: Powering a Pi4 while using USB OTG

Post by cmorley »

You'd need to connect the ground to the PC and the power brick. The data lines need ground as a reference. See if that fixes it..
User avatar
sweh
Posts: 2363
Joined: Sat Mar 10, 2012 12:05 pm
Location: New York, New York
Contact:

Re: Powering a Pi4 while using USB OTG

Post by sweh »

cmorley wrote:
Mon Nov 09, 2020 6:18 am
You'd need to connect the ground to the PC and the power brick. The data lines need ground as a reference. See if that fixes it..
Oh, I thought the +/- nature of the lines meant they were balanced so didn't need a common ground. I'll try that; thanks!
Rgds
Stephen
guesser
Posts: 549
Joined: Mon Jun 26, 2006 10:21 pm
Contact:

Re: Powering a Pi4 while using USB OTG

Post by guesser »

The data lines do use differential signalling, however there is also DC signalling to detect when devices are plugged in. The host wants to see the D+ line pulled up to Vbus iirc. No doubt it's more complicated for OTG mode :)
Various teletext things including a web based teletext editor which can export as mode 7 screens.
Join the Teletext Discord for teletext chat.
User avatar
BeebMaster
Posts: 3972
Joined: Sun Aug 02, 2009 5:59 pm
Location: Lost in the BeebVault!
Contact:

Re: Powering a Pi4 while using USB OTG

Post by BeebMaster »

I thought there was some driver or hardware problem in the Pi4 with the USB-C that meant it didn't work properly?
Image
User avatar
sweh
Posts: 2363
Joined: Sat Mar 10, 2012 12:05 pm
Location: New York, New York
Contact:

Re: Powering a Pi4 while using USB OTG

Post by sweh »

sweh wrote:
Mon Nov 09, 2020 3:47 pm
cmorley wrote:
Mon Nov 09, 2020 6:18 am
You'd need to connect the ground to the PC and the power brick. The data lines need ground as a reference. See if that fixes it..
Oh, I thought the +/- nature of the lines meant they were balanced so didn't need a common ground. I'll try that; thanks!
And, indeed when I connected the ground it just worked

Code: Select all

[Wed Apr 15 19:48:55 2020] usb 2-2: new high-speed USB device number 18 using ehci-pci
[Wed Apr 15 19:48:55 2020] usb 2-2: New USB device found, idVendor=1d6b, idProduct=0104
[Wed Apr 15 19:48:55 2020] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[Wed Apr 15 19:48:55 2020] usb 2-2: Product: Multifunction USB Device
[Wed Apr 15 19:48:55 2020] usb 2-2: Manufacturer: tinypilot
[Wed Apr 15 19:48:55 2020] usb 2-2: SerialNumber: 6b65796d696d6570690
[Wed Apr 15 19:48:55 2020] input: tinypilot Multifunction USB Device as /devices/pci0000:00/0000:00:13.2/usb2/2-2/2-2:1.0/0003:1D6B:0104.0006/input/input169
[Wed Apr 15 19:48:55 2020] hid-generic 0003:1D6B:0104.0006: input,hidraw2: USB HID v1.01 Keyboard [tinypilot Multifunction USB Device] on usb-0000:00:13.2-2/input0
[Wed Apr 15 19:48:55 2020] input: tinypilot Multifunction USB Device as /devices/pci0000:00/0000:00:13.2/usb2/2-2/2-2:1.1/0003:1D6B:0104.0007/input/input170
[Wed Apr 15 19:48:55 2020] hid-generic 0003:1D6B:0104.0007: input,hidraw3: USB HID v1.01 Mouse [tinypilot Multifunction USB Device] on usb-0000:00:13.2-2/input1
Thanks!
Rgds
Stephen
User avatar
sweh
Posts: 2363
Joined: Sat Mar 10, 2012 12:05 pm
Location: New York, New York
Contact:

Re: Powering a Pi4 while using USB OTG

Post by sweh »

BeebMaster wrote:
Mon Nov 09, 2020 8:31 pm
I thought there was some driver or hardware problem in the Pi4 with the USB-C that meant it didn't work properly?
With some "special" cables (primarily those designed for USB-C Thunderbolt) the Pi is misidentified as an audio adapter and won't attempt to send power. That's 'cos those cables have chips in them to perform "magic". A dumb cable doesn't care and will send power anyway.
Rgds
Stephen
Post Reply

Return to “off-topic”