newto
Posts: 6
Joined: Thu Aug 09, 2018 2:28 pm

rPi4 Data over USB C/Power Port?

Fri Jun 28, 2019 12:57 pm

Has anyone tried to do data transfer over the USB C connection on the new rPi4s? From the schematic (https://www.raspberrypi.org/documentati ... educed.pdf), it shows that the UUSB_D_N and UUSB_D_P are connected, where they aren't in previous versions (exception being the "USB" labelled connector on the Zero and Zero W).

On the Zero boards it's possible to use the USB port to have the Pi act as an OTG port, letting you do things like communicate using serial or as a mass storage device (like this: https://gist.github.com/gbaman/50b6cca61dd1c3f88f41). Has anyone tested this on a 4? I unfortunately can't get one for a month...

fruitoftheloom
Posts: 25733
Joined: Tue Mar 25, 2014 12:40 pm
Location: Delightful Dorset

Re: rPi4 Data over USB C/Power Port?

Fri Jun 28, 2019 2:30 pm

newto wrote:
Fri Jun 28, 2019 12:57 pm
Has anyone tried to do data transfer over the USB C connection on the new rPi4s? From the schematic (https://www.raspberrypi.org/documentati ... educed.pdf), it shows that the UUSB_D_N and UUSB_D_P are connected, where they aren't in previous versions (exception being the "USB" labelled connector on the Zero and Zero W).

On the Zero boards it's possible to use the USB port to have the Pi act as an OTG port, letting you do things like communicate using serial or as a mass storage device (like this: https://gist.github.com/gbaman/50b6cca61dd1c3f88f41). Has anyone tested this on a 4? I unfortunately can't get one for a month...

https://www.raspberrypi.org/forums/view ... 3&t=243966
The information is out there....you just have to let it in.

My other Linux machines are a ChromeBox & Intel CoreDuo Desktop

newto
Posts: 6
Joined: Thu Aug 09, 2018 2:28 pm

Re: rPi4 Data over USB C/Power Port?

Fri Jun 28, 2019 3:07 pm

Thanks! I was about to feel dumb for not seeing it in my search, but that was posted an hour and a half after me :P

User avatar
thagrol
Posts: 4221
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: rPi4 Data over USB C/Power Port?

Fri Jun 28, 2019 9:08 pm

Be careful with that. While I've not yet tried with Buster, having the shared storage mounted simultaneously on both sides of the USB link is asking for trouble.

Why?

Both sides use caching and neither side knows what the other is doing.
Arguing with strangers on the internet since 1993.

All advice given is based on my experience. it worked for me, it may not work for you.
All GPIO pin numbers are BCM numbers.

Aardappeltaart
Posts: 162
Joined: Wed Mar 02, 2016 11:32 am

Re: rPi4 Data over USB C/Power Port?

Sat Jun 29, 2019 10:56 am

Yes also Ethernet OTG is working, so you can connect and power the RPI4 with just a USB cable.

Like described here:
https://dev.webonomic.nl/4-ways-to-conn ... e-internet

I do wonder if USBBoot will be supported for the RPI4, so it can be used with just an USB cable, no sd-card and no ethernet needed, like you can do with the Zero.
https://github.com/raspberrypi/usbboot

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

Re: rPi4 Data over USB C/Power Port?

Sat Jun 29, 2019 2:04 pm

Aardappeltaart wrote:
Sat Jun 29, 2019 10:56 am
Yes also Ethernet OTG is working, so you can connect and power the RPI4 with just a USB cable.
If your PC's USB port can deliver 3 Amps, or whatever the Pi and anything attached needs.

User avatar
thagrol
Posts: 4221
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: rPi4 Data over USB C/Power Port?

Sat Jun 29, 2019 3:22 pm

hippy wrote:
Sat Jun 29, 2019 2:04 pm
Aardappeltaart wrote:
Sat Jun 29, 2019 10:56 am
Yes also Ethernet OTG is working, so you can connect and power the RPI4 with just a USB cable.
If your PC's USB port can deliver 3 Amps, or whatever the Pi and anything attached needs.
Or if you power the Pi via its GPIO header.
Arguing with strangers on the internet since 1993.

All advice given is based on my experience. it worked for me, it may not work for you.
All GPIO pin numbers are BCM numbers.

Aardappeltaart
Posts: 162
Joined: Wed Mar 02, 2016 11:32 am

Re: rPi4 Data over USB C/Power Port?

Sat Jun 29, 2019 5:00 pm

hippy wrote:
Sat Jun 29, 2019 2:04 pm
If your PC's USB port can deliver 3 Amps, or whatever the Pi and anything attached needs.
I doubt 3A is needed for a headless RPI4 with all USB ports vacant.

Anyhow I just plugged it into my laptop and powered the RPI4 from an USB port with a USB cable I used to charge my Samsung Note and a small microUSB-USB-C adapter.

It's working.

User avatar
Irrational_Pi
Posts: 7
Joined: Sat Jan 25, 2020 3:40 am

Re: rPi4 Data over USB C/Power Port?

Fri Oct 23, 2020 8:58 pm

Interesting topic. Does this mean that USB-C Power Delivery could power my 4B and send/receive data too? For example: I have been wondering if it would be possible to connect a StarTech 4 Port USB C Hub with 4 USB Type-A Ports (model HB30C4AFPD) to the Pi's power port and also connect externally-powered hard drives to the hub - sending data and power to my 4B simultaneously. Or would this prevent the Pi from reboot commands?
Cheer up! If all else fails, you can set the building on fire.

cleverca22
Posts: 2870
Joined: Sat Aug 18, 2012 2:33 pm

Re: rPi4 Data over USB C/Power Port?

Fri Oct 23, 2020 9:37 pm

Irrational_Pi wrote:
Fri Oct 23, 2020 8:58 pm
Interesting topic. Does this mean that USB-C Power Delivery could power my 4B and send/receive data too? For example: I have been wondering if it would be possible to connect a StarTech 4 Port USB C Hub with 4 USB Type-A Ports (model HB30C4AFPD) to the Pi's power port and also connect externally-powered hard drives to the hub - sending data and power to my 4B simultaneously. Or would this prevent the Pi from reboot commands?
the special power delivery stuff isnt wired up on the rpi4b, so the board is limited to 5v only
the usb 3.0 lanes are also not wired up, so no special alternate modes or 3.0 speeds
the usb-c negotiation stuff is also missing, so no auto-detection on if the usb2.0 stuff should be in host or device mode

but if you put the right lines in config.txt

Code: Select all

dtoverlay=dwc2
you can then force the usb-c port into device mode, and then you can use some relatively simple bash code:
https://github.com/librerpi/rpi-tools/b ... ix#L54-L84

to configure it as a usb device
in my case, i'm creating both a serial port and a mass-storage device, so i can login over the usb, and also access the entire uSD card

ethernet is also an option, but i dont have a powered USB hub, and even with this basic task, the pi4 is stuck with the low voltage warning up, so i didnt want to stress it too much

there is also a different config.txt flag (i forget which one), which forces it into host mode (but only at 2.0 speeds), and then you can use a C->host-A adapter, and plug any usb device you want into it

User avatar
thagrol
Posts: 4221
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: rPi4 Data over USB C/Power Port?

Fri Oct 23, 2020 9:44 pm

Setting aside that you've revived a 16 month old thread the answer to your question is maybe.

If
  • Your USB host supplies enough current without PD (the 4B doesn't support power delivery and needs at least 600mA with no devices attached and when lightly loaded)
  • Your self powered USB devices don't backfeed power to the Pi. If they do and they're switch on before the Pi is powered the Pi won't boot.
  • You have teh time, knowledge, and experience to set up the relevant USB gadget functionality on the Pi
  • Your USB host has the correct drivers.
  • The functionality required over USB between the Pi and the host exists or you're willing and able to write a new driver if it doesn't
then yes, it can be done.
Arguing with strangers on the internet since 1993.

All advice given is based on my experience. it worked for me, it may not work for you.
All GPIO pin numbers are BCM numbers.

User avatar
thagrol
Posts: 4221
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: rPi4 Data over USB C/Power Port?

Fri Oct 23, 2020 9:56 pm

cleverca22 wrote:
Fri Oct 23, 2020 9:37 pm
there is also a different config.txt flag (i forget which one), which forces it into host mode
You're thinking of

Code: Select all

dtoverlay=dwc2,dr_mode=host
See /boot/overlays/README

The ID pin is left floating (I think or maybe is pulled to device mode, I'm not sure) on the 4B as it doesn't exist in the USB C connector. If you don't specify a dr_mode when loading the dwc2 overlay you'll get device/gadget mode.
(but only at 2.0 speeds), and then you can use a C->host-A adapter, and plug any usb device you want into it
It's always USB 2, whether functioning as a host or device. It is, in fact, the same USB 2 controller as on all previous Pi. UNless things have changed (and they may have) you may find you'll get better host mode performance using the dwc overlay. That's host only though.
Arguing with strangers on the internet since 1993.

All advice given is based on my experience. it worked for me, it may not work for you.
All GPIO pin numbers are BCM numbers.

User avatar
Irrational_Pi
Posts: 7
Joined: Sat Jan 25, 2020 3:40 am

Re: rPi4 Data over USB C/Power Port?

Fri Oct 23, 2020 10:19 pm

OK, so there isn't power delivery or USB 3.0 functionality on the Pi via the USB C power port but it should accept and use the power being supplied to it through the hub. As I have been using a VAVA 9-in-1 USB C hub with power delivery to charge my S9+ from an Anker 65W USB C charger while using Samsung DeX, I thought that it might be possible to use the USB PD hub in the same way with my 4B. I would like to test this out but not willing to fry my Pi in the process. From what I understand, the Pi's hardware simply doesn't have the capabilities for it to work, safely.
Cheer up! If all else fails, you can set the building on fire.

cleverca22
Posts: 2870
Joined: Sat Aug 18, 2012 2:33 pm

Re: rPi4 Data over USB C/Power Port?

Fri Oct 23, 2020 10:28 pm

Irrational_Pi wrote:
Fri Oct 23, 2020 10:19 pm
OK, so there isn't power delivery or USB 3.0 functionality on the Pi via the USB C power port but it should accept and use the power being supplied to it through the hub. As I have been using a VAVA 9-in-1 USB C hub with power delivery to charge my S9+ from an Anker 65W USB C charger while using Samsung DeX, I thought that it might be possible to use the USB PD hub in the same way with my 4B. I would like to test this out but not willing to fry my Pi in the process. From what I understand, the Pi's hardware simply doesn't have the capabilities for it to work, safely.
if there is only one power source (powered hub into usb-c port) its unlikely to cause any damage
either it will boot, or it will not get enough amps and the red light goes out, then it resets/crashes randomly

User avatar
davidcoton
Posts: 5850
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK
Contact: Website

Re: rPi4 Data over USB C/Power Port?

Fri Oct 23, 2020 10:35 pm

Irrational_Pi wrote:
Fri Oct 23, 2020 8:58 pm
Interesting topic. Does this mean that USB-C Power Delivery could power my 4B and send/receive data too? For example: I have been wondering if it would be possible to connect a StarTech 4 Port USB C Hub with 4 USB Type-A Ports (model HB30C4AFPD) to the Pi's power port and also connect externally-powered hard drives to the hub - sending data and power to my 4B simultaneously. Or would this prevent the Pi from reboot commands?
Basically, yes. But you may not get the performance you want, either for power or data.

As long as you don't exceed the total power capacity of the USB-C power supply connected to the hub -- since the Pi4 doesn't support PD except at 5V, the input PSU may be limited to the USB-PD limit at 5V of 3A (as with the RPT PSU), so you will not be gaining the extra power that you might expect from a powered hub. (The hub PD is described as "passthough", which I think means the input PSU will match the Pi's requirements, and can't have a greater than 5V input. It also means you need a recent Pi4 with the PD design issue corrected.) There may not be enough power for the Pi, the hub and the devices connected to the hub. If you use separately powered drives, or find a 5V 5A PSU and use low power drives, it might work OK.

As others have said, you will have to configure the Pi's USB-C as a host, and it will be limited to USB-2 speeds on the Pi-to-hub link, where you most want USB3 speed.

All in all you will be better off with a powered hub on one of the Pi's USB-3 ports. (one that does not backpower to the Pi), and the normal RPT PSU for the Pi.
Location: 345th cell on the right of the 210th row of L2 cache

User avatar
rpdom
Posts: 18139
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: rPi4 Data over USB C/Power Port?

Sat Oct 24, 2020 6:52 am

Irrational_Pi wrote:
Fri Oct 23, 2020 10:19 pm
OK, so there isn't power delivery or USB 3.0 functionality on the Pi via the USB C power port but it should accept and use the power being supplied to it through the hub. As I have been using a VAVA 9-in-1 USB C hub with power delivery to charge my S9+ from an Anker 65W USB C charger while using Samsung DeX, I thought that it might be possible to use the USB PD hub in the same way with my 4B. I would like to test this out but not willing to fry my Pi in the process. From what I understand, the Pi's hardware simply doesn't have the capabilities for it to work, safely.
You won't fry your Pi. Not unless your USB C hub breaks the standards badly.

Possible scenarios are
  • The Hub supplies 5V to the Pi at sufficient current. Everything works.
  • The Hub supplies 5V to the Pi at insufficient current. The Pi runs unreliably. Nothing is damaged, but the filesystem on the SD card may get corrupted.
  • The Hub decides the Pi is a pair of headphones and refuses to supply any power. Nothing is damaged. (this can happen on the early Pi 4B where the power ID resistors weren't wired correctly).
Unreadable squiggle

cleverca22
Posts: 2870
Joined: Sat Aug 18, 2012 2:33 pm

Re: rPi4 Data over USB C/Power Port?

Sat Oct 24, 2020 5:17 pm

rpdom wrote:
Sat Oct 24, 2020 6:52 am
  • The Hub decides the Pi is a pair of headphones and refuses to supply any power. Nothing is damaged. (this can happen on the early Pi 4B where the power ID resistors weren't wired correctly).
was thinking that might explain why the pi4 didnt get any power when i plugged it into my cellphone
but that was microb->hosta->usbc, so all of the PD stuff is lost
probably was just some over-current stuff, but i was able to make it work by powering the pi4 via the gpio headers, from a 2nd pi!
and i didnt worry too much about back-feeding power into the cellphone, because thats how you charge it normally!

User avatar
Irrational_Pi
Posts: 7
Joined: Sat Jan 25, 2020 3:40 am

Re: rPi4 Data over USB C/Power Port?

Sat Oct 24, 2020 7:34 pm

A lot of good information in this thread, thanks - I appreciate all of the advice. I am booting from a flash drive, and have the other 3 usb ports used for external drives - so I am curious if setting the Pi's usb-c port to device mode will have any effect on those connections. Honestly I'm surprised this bidirectional data and power delivery hub will actually work without damaging my 4B, and hopefully without corrupting any of my drives.
Cheer up! If all else fails, you can set the building on fire.

User avatar
thagrol
Posts: 4221
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: rPi4 Data over USB C/Power Port?

Sat Oct 24, 2020 11:40 pm

Irrational_Pi wrote:
Sat Oct 24, 2020 7:34 pm
A lot of good information in this thread, thanks - I appreciate all of the advice. I am booting from a flash drive, and have the other 3 usb ports used for external drives - so I am curious if setting the Pi's usb-c port to device mode will have any effect on those connections.
It'll work. It won't affect the USB A ports as they're on a completely different controller.
Honestly I'm surprised this bidirectional data and power delivery hub will actually work without damaging my 4B, and hopefully without corrupting any of my drives.
Can't promise that it will. There is a know issue with hubs that break the spec and backfeed power to the USB A ports. The PMIC can't handle it and your Pi won't boot with the offending device(s) connected and powered on.
Arguing with strangers on the internet since 1993.

All advice given is based on my experience. it worked for me, it may not work for you.
All GPIO pin numbers are BCM numbers.

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

Re: rPi4 Data over USB C/Power Port?

Sat Oct 24, 2020 11:53 pm

thagrol wrote:
Sat Oct 24, 2020 11:40 pm
There is a know issue with hubs that break the spec and backfeed power to the USB A ports. The PMIC can't handle it and your Pi won't boot with the offending device(s) connected and powered on.
It is actually a feature. The PMIC checks that all outputs at 0V before starting up to guarantee correct power sequencing. You can damage things if you don't turn on the various voltage rails in the correct order.

AFAIK the main issue with backfeeding is on the data lines. The powered device isn't supposed to drive the data lines unless it detects 5V from upstream but some do it anyway. This leaks out through the ESD diodes and the PMIC sees that tiny voltage so will refuse to start.

User avatar
davidcoton
Posts: 5850
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK
Contact: Website

Re: rPi4 Data over USB C/Power Port?

Sun Oct 25, 2020 9:37 am

trejan wrote:
Sat Oct 24, 2020 11:53 pm
thagrol wrote:
Sat Oct 24, 2020 11:40 pm
There is a know issue with hubs that break the spec and backfeed power to the USB A ports. The PMIC can't handle it and your Pi won't boot with the offending device(s) connected and powered on.
It is actually a feature. The PMIC checks that all outputs at 0V before starting up to guarantee correct power sequencing. You can damage things if you don't turn on the various voltage rails in the correct order.

AFAIK the main issue with backfeeding is on the data lines. The powered device isn't supposed to drive the data lines unless it detects 5V from upstream but some do it anyway. This leaks out through the ESD diodes and the PMIC sees that tiny voltage so will refuse to start.
None of this is relevant to a hub connected to the USB-C port.
Location: 345th cell on the right of the 210th row of L2 cache

Return to “Advanced users”