News for hackers. Stuff that matters.
Re:Tried to charge my phone (with USB-C), but my laptop star... by dntrkv on Sunday March 13, 2022 @11:57AM (#30662421)
Slightly related, but you can also charge MacBook to MacBook. The first device plugged in is the chargee.
Re:Tried to charge my phone (with USB-C), but my laptop star... by ssivark on Sunday March 13, 2022 @01:26PM (#30663552)
WTH — the cable is stateful? :O
Re:Tried to charge my phone (with USB-C), but my laptop star... by dangrie158 on Sunday March 13, 2022 @02:11PM (#30664096)
There are cables with an IC connected to the CC pins. However this is AFAIK only used to determine if the cable can handle higher charging currents, still the MacBook could detect if the cable was plugged in before the device in the other side https://www.inviolabs.com/blogs/news/what-is-e-marker-and-wh...
Re:Tried to charge my phone (with USB-C), but my laptop star... by primax on Sunday March 13, 2022 @05:00PM (#30665653)
If you think that's cool you should check out the OMG cable.

https://fossbytes.com/charging-cables-used-to-hack-devices/

Re:Tried to charge my phone (with USB-C), but my laptop star... by crote on Sunday March 13, 2022 @01:42PM (#30663734)
No, it is entirely a device thing.
Re:Tried to charge my phone (with USB-C), but my laptop star... by slim on Sunday March 13, 2022 @02:00PM (#30663956)
it can't be. the cable has to be stateful for this to work. even if it's one bit that simply tells the device it is connected.
Re:Tried to charge my phone (with USB-C), but my laptop star... by technobabbler on Sunday March 13, 2022 @02:47PM (#30664457)
Not necessarily. It can just test the resistance of the port/cable to see if anything is there. The first device (power provider) to detect the cable can say "ok, I got plugged in first" and then tell the other device (the consumer) that when they try to negotiate power delivery. That doesn't require maintaining state in the cable itself, just that the devices be able to detect the cable when it's plugged in (even without the other end connected).

Cable detection: http://blog.teledynelecroy.com/2016/02/usb-type-c-cable-dete...

Overview of USB power delivery negotiation: https://www.embedded.com/usb-type-c-and-power-delivery-101-p...

And then after the initial connection, the devices can renegotiate their roles if you want to reverse the charge.

It's great when it actually works. In the real world there are so many incompatible implementations that USB-C is a real clusterfuck.

Re:Tried to charge my phone (with USB-C), but my laptop star... by ultrarunner on Sunday March 13, 2022 @03:27PM (#30664840)
The cable has a few wires dedicated to directionality (CC1 & CC2) lines as well as sideband channels. My guess would be that the first device to be plugged in sees nothing on the other side, decides it's going to ask for power, and configures itself (and thus the cable) as such. The second device sees a USB-PD device requesting power and begins to provide it.

While I don't doubt the foresight of Apple HW engineers, the possibility strikes me that this is entirely accidental and derived from the design of the USBPD spec. If so, these "stars align (but only because the spec was functionally designed)" moments are some of my favorites.

Re:Tried to charge my phone (with USB-C), but my laptop star... by ohuf on Sunday March 13, 2022 @12:28PM (#30662794)
What do you mean by "first device plugged in"? If I connect two devices with an USB-C cable, which one is the "first device" then?
Re:Tried to charge my phone (with USB-C), but my laptop star... by technobabbler on Sunday March 13, 2022 @02:59PM (#30664576)
A device can tell when one end of the cable is plugged in by testing the cable's control channel, even without the other end connected yet. It sees that a cable is connected, but there's nothing on the other end, and presumes it's first and should act as the provider. A second later, you connect the other end of the cable to a consumer, and the first device will try to negotiate its role with the second. It's up to the devices to respect each other's role requests.

http://blog.teledynelecroy.com/2016/02/usb-type-c-cable-dete...

Different device types (like a powered hub or desktop monitor) can request different roles, and they'll have to sort it out during negotiation if there's a conflict. Sometimes a user-facing popup will ask you if you want to provide or take power from the other device.

Re:Tried to charge my phone (with USB-C), but my laptop star... by andrei_says_ on Sunday March 13, 2022 @12:38PM (#30662926)
I imagine you’d plug the cable into one of them and then the other. I assume the author means first and second as in temporal order.
Re:Tried to charge my phone (with USB-C), but my laptop star... by technobabbler on Sunday March 13, 2022 @11:45AM (#30662262)
It's supposed to be able to do that.

In Android there is a "Charge connected device" setting that you can turn on or off. Mine is off by default.

Re:Tried to charge my phone (with USB-C), but my laptop star... by russellbeattie on Sunday March 13, 2022 @04:13PM (#30665258)
You know in scifi movies and novels where the protagonists tap at their keyboard and "route power to needed systems"? It looks like we're going to actually need the capability to dynamically choose where power comes from and goes to sooner than later.
Re:Tried to charge my phone (with USB-C), but my laptop star... by kbelder on Sunday March 13, 2022 @01:25PM (#30663516)
Turn the cable around, obviously.
Re:Tried to charge my phone (with USB-C), but my laptop star... by v8xi on Sunday March 13, 2022 @01:48PM (#30663799)
left-right, or up-down?
Re:Tried to charge my phone (with USB-C), but my laptop star... by dangrie158 on Sunday March 13, 2022 @02:18PM (#30664175)
This is really weird, most laptops require 20V PD to charge since the internal cells are typically at ~17V. So if true one of the decices (probably the laptop) has a boost converter. Still probably really inefficient
Re:Tried to charge my phone (with USB-C), but my laptop star... by BlueTemplar on Sunday March 13, 2022 @03:24PM (#30664820)
I mean it's not strange, charge naturally flows from higher to lower voltage...
Re:Tried to charge my phone (with USB-C), but my laptop star... by technobabbler on Monday March 14, 2022 @08:15AM (#30671487)
Then you'd never be able to fully deplete one battery to charge another,no? They'd just reach equilibrium at some point?
Re:Tried to charge my phone (with USB-C), but my laptop star... by BlueTemplar on Monday March 14, 2022 @12:43PM (#30674639)
Indeed, that's how it works (without additional logic blocking charge flow, artificial voltage increase, or extra power sources).

Well, assuming batteries with similar % charge <-> voltage correspondence.