obarthelemy
Posts: 1399
Joined: Tue Aug 09, 2011 10:53 pm

Re: [issue: host vs device] sshing into *and* powering the Pi with a single USB cable.

Tue Oct 25, 2011 12:19 pm

(I can feel the trample of indignant geeks "No, No, Nooooooo !!" 8-) )

Let me explain.

I'm thinking at least one of my future Pis will be living next to my PC, headless and SSHed into. I was planning, of course, of powering it from a PC USB port, with an A to microUSB cable. That takes care of power, what about ssh ? I could lay a network cable across the room to my ethernet switch, or add a Wifi dongle for the 10 cm trip from my PC to the Pi, but that's damn inelegant. What about using USB to SSH into the Pi ?

I turns out, USB can do full networking, not just serial emulation. But we need a special cable, not only A-to-A, but also Bridge to avoid the power sources on both sides doing nasty things to each other. Those cables seem to be unconscionably expensive, we might as well make our own.

Hence a nice little hardware+software project: since on the PC side we have a USB port with power and data lines, and on the Pi side we need Power (but not data) to go to microUSB, and data (but not power) to go to USB-A, why not make our own custom Y cable ?

And then it's just a matter of finding USB networking drivers for the PC and the Pi. Those seem to be around. Also, the Pi will be able to connect to the wider TCP/IP world (LAN, Internet), we just need to setup the host PC as a network bridge.

To-do:
- cable schematics
- locate source for components > cheapest = probably just cannibalize an A to microUSB cable, and any other cable with a A connector.
- locate source of Linux USB networking drivers
- locate Windows USB networking drivers (XP and 7)
- tutorial

http://www.usb.org/about/faq/ans5
http://www.hardwaresecrets.com.....-Cable/248
http://wiki.openmoko.org/wiki/.....Networking
http://wiki.maemo.org/N900_USB.....networking
http://www.windowsnetworking.c.....instl.html

User avatar
abishur
Posts: 4477
Joined: Thu Jul 28, 2011 4:10 am
Location: USA
Contact: Website

Re: [issue: host vs device] sshing into *and* powering the Pi with a single USB cable.

Tue Oct 25, 2011 2:05 pm

Hmm... usb 2.0 uses 4 wires, 1 power, 1 ground, and 2 data. The bridge in the middle lets the two devices communicate in half duplex mode (which since usb is already half duplex, does that make it quarter duplex?). The point being, I don't think you could send power down the cable without damaging the bridge in the middle, nor would you be able to make your own usb bridge cable, it's not like ethernet where all you have to do is swap the wires ;) . Maybe if you used a usb 3.0 cable? You could use 4 wires for the bridge and the other ground/power wires for the power... but that would probably be pretty expensive (usb 3.0 isn't the cheapest thing around right now).

Since you're keeping it so close to your PC why not use a single bit of ethernet cable? Take 4 wires of the ethernet cable and wirer it to your USB port for power (well really you only need to do 2 wires, for power) and use the other 4 for the ethernet? That way you'd still only use one cable keeping everything spiffy and still have full and native ethernet.
Dear forum: Play nice ;-)

User avatar
jojopi
Posts: 3079
Joined: Tue Oct 11, 2011 8:38 pm

Re: [issue: host vs device] sshing into *and* powering the Pi with a single USB cable.

Tue Oct 25, 2011 2:39 pm

Quote from obarthelemy on October 25, 2011, 13:19
Those cables seem to be unconscionably expensive, we might as well make our own.


They are expensive because they have got chips in them. You can not (simply and cheaply) make your own.

USB connects hosts (with A plugs) to devices (with B plugs). You want to connect two hosts together. To do this you need a bridge, which is logically two separate USB network interface devices (one for each host) permanently wired to each other.

obarthelemy
Posts: 1399
Joined: Tue Aug 09, 2011 10:53 pm

Re: [issue: host vs device] sshing into *and* powering the Pi with a single USB cable.

Tue Oct 25, 2011 10:01 pm

Oh, OK, I missed the host vs device issue, so it's more complicated than RJ45's and serial's straight vs crossed cables. Bummer.

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

Re: [issue: host vs device] sshing into *and* powering the Pi with a single USB cable.

Tue Oct 25, 2011 10:05 pm

Quote from obarthelemy on October 25, 2011, 13:19
I turns out, USB can do full networking, not just serial emulation. But we need a special cable, not only A-to-A, but also Bridge to avoid the power sources on both sides doing nasty things to each other.

And also to facilitate connecting two USB hosts to each other - That's what's in the special cable which creates its cost. They aren't that expensive and I've seen cheaper -

http://www.amazon.co.uk/Networ.....B000Q6I23K

If someone works out how to get R-Pi operating as a USB slave device rather than host then it could be easy, then it just would need a cable.

obarthelemy
Posts: 1399
Joined: Tue Aug 09, 2011 10:53 pm

Re: [issue: host vs device] sshing into *and* powering the Pi with a single USB cable.

Tue Oct 25, 2011 10:52 pm

Ok, let's reopen the discussion.
1- The special cable is still as expensive as a wifi dongle, so probably not worth the bother except for fun, or if you don't have wifi.
2- indeed, switching one of the Pi's USB ports from host to device (but just one, not the other one) would seem to work. No clue about how to do it though. I'm thinking it must be doable, because some Android devices can use one single USB port as either host or device. My eCafe has a separate device port (and 3 host ones), I'm not sure if it's just a regular port with a different driver /setup or a whole different circuit.

What do you make of: A peripheral side Linux-USB gadget API is now standard with 2.4 and 2.6 kernels. That framework currently supports at least a dozen different types of USB peripheral controller hardware under Linux. While it resembles the original host-side programming interfaces (at least in terms of submitting asynchronous requests, and in terms of shared core data structures), it must treat USB busses very differently from a host side API. That's because implementing the target function only involves responding to a single USB Host (like a web server only responding to one client at a time). Also, target side drivers can never initiate control requests, they can only respond to them.
(from http://www.linux-usb.org/usb2.html )

OK. It seems dual-mode ports use the OTG (for on-the-go) monicker. Are the Pi's ports OTG ? I would assume the Model A single direct port and the B's 9512-multiplied ports are different cases ?

Edit: My eCafe's Freescale iMX 515 data sheet specifically lists 1xUSB OTG (HS+PHY) and 3x USB HS host, so this one is not a validation of anything. Anyone got a datasheet for the Pi's Broadcom CPU ? Didn't see any hint of OTG in the 9512's: http://www.smsc.com/media/Down.....s/9512.pdf

http://en.wikipedia.org/wiki/U....._On-The-Go
side note: USB OTG is incompatible with USB hubs.

User avatar
abishur
Posts: 4477
Joined: Thu Jul 28, 2011 4:10 am
Location: USA
Contact: Website

Re: [issue: host vs device] sshing into *and* powering the Pi with a single USB cable.

Wed Oct 26, 2011 12:09 am

So.. not a fan of my 1 ethernet cable two connectors on either end idea huh? :P
Dear forum: Play nice ;-)

obarthelemy
Posts: 1399
Joined: Tue Aug 09, 2011 10:53 pm

Re: [issue: host vs device] sshing into *and* powering the Pi with a single USB cable.

Wed Oct 26, 2011 12:23 am

@Abishur: Actually, that works as well, but I see it as a 2-cable solution( thus deemed "inelegant" ^^)
- an A to microUSB cable for power
- a straight (or is it cross-over... whatever... the *other* kind) Ethernet cable from the Pi to my Pc's unused Ethernet port (my PC uses Wifi).
I actually might do that if the full-USB way doesn't pan out, which I think it won't.

Or just get a wifi dongle and stop pretending I can hack ^^ I'd rather use the Ethernet port, and keep a USB port available though. Will probably save a hub.

NoSuchNick
Posts: 42
Joined: Tue Sep 20, 2011 1:38 pm

Re: [issue: host vs device] sshing into *and* powering the Pi with a single USB cable.

Wed Oct 26, 2011 1:07 am

I'm probably going with my own version.
On top of my pi i will have a shield with an atmega 8u4 or something similiar, that atmega will provide a mini USB socket to the outside world and an UART connection to the pi. If electronically and physically feasible it will also be connected to the 5V and 3V3 circuits of the pi. The main idea is to be able to controll additional hardware from the pi with the atmega. However with a simple jumper i could also switch the mega into a bridge mode and just have it act as a USB<-> Serial converter. If there are multiple UARTs or ready made drivers for the SPI pins, it could have one UART dedicated solely for the USB interface.

If we can inject power into the pi over the headers, this should work quite nicely. It won't be ssh, but for my purposes it should work just the same and will only be one USB cable and one USB socket at each side.

User avatar
abishur
Posts: 4477
Joined: Thu Jul 28, 2011 4:10 am
Location: USA
Contact: Website

Re: [issue: host vs device] sshing into *and* powering the Pi with a single USB cable.

Wed Oct 26, 2011 2:15 am

I kinda get the feeling that the micro USB power slot won't have any data lines attached to it. That they're just using that form factor to get power.... :?
Dear forum: Play nice ;-)

obarthelemy
Posts: 1399
Joined: Tue Aug 09, 2011 10:53 pm

Re: [issue: host vs device] sshing into *and* powering the Pi with a single USB cable.

Wed Oct 26, 2011 4:40 am

mm mm, that's confirmed: the Pi's micro USB only does power, not data. if it did do data, my wonderful plan wouldn't even require.. any hacking at all.
Should we start loudly complaining about the microUSB port no working as a device port ?
3,2,1
Ethernet crossover cable pinouts: http://www.homenethelp.com/web.....ssover.asp

User avatar
abishur
Posts: 4477
Joined: Thu Jul 28, 2011 4:10 am
Location: USA
Contact: Website

Re: [issue: host vs device] sshing into *and* powering the Pi with a single USB cable.

Sun Oct 30, 2011 7:10 pm

I was thinking of some way you might be able to still get away with one cable and I think I've come up with two possibilities (well really one with a slight variance)

For both ways, the r-pi side is the same. Send power down the ethernet cable. Cut the power pins off at the PCB on the r-pi. Solder a jumper cable from the power pins of the ethernet jack (no longer connected to the PCB) to the power pins on the micro usb jack.

Now for the PC side

First there's the easy way. Since it's going to be hidden anyway, use an in-line power adapter to hook a 5V coax jack power adapter and send power down the ethernet cable

Then there's the much more fun way! Since you're using a second ethernet port (presumably a whole PCI card) cut the lines used for power off of the ethernet jack just like you did on the r-pi. Then solder the 5 volt power off the computer PSU (or other external adapter if you want the r-pi on even when the PC isn't... though since it wouldn't get network connectivity I'm not sure why you'd want it on) to the power pins of the ethernet adapter.

Voila! You now have a single cable powering the r-pi and providing network connectivity! For added protection, you could even throw a cheap voltage regulator in the mix to make sure the computer PSU doesn't spike and send more than 5V... but it should already have that kind of protection built in, or else you'd have to worry about every device in your computer that used 5V.
Dear forum: Play nice ;-)

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

Re: [issue: host vs device] sshing into *and* powering the Pi with a single USB cable.

Sun Oct 30, 2011 8:25 pm

Quote from abishur on October 30, 2011, 19:10
Send power down the ethernet cable. Cut the power pins off at the PCB on the r-pi. Solder a jumper cable from the power pins of the ethernet jack (no longer connected to the PCB) to the power pins on the micro usb jack.

It could be even easier than that; if not all signals of the RJ45 are used then they should be pins with no tracking to them, so no cutting required, just jumpering the correct pins to the micro-USB or elsewhere.

I'm not entirely sure what the consequences are if the R-Pi is powered by an external PSU ( direct to micro-USB ) and then the RJ45 is plugged into a PC or router etc with 0V/5V on those LAN lines. In most cases it seems it will be okay ( more so if 0V and 5V are not combined on the same twisted pair, and possibly better if only one line of each pair is used ), but plugging into anything which uses all four pairs ( PoE, Gigabit Ethernet ) could be a disaster in the making.

Powering via LAN and via micro-USB at the same time could also be a problem. One could always unsolder the micro-USB socket.

As long as people are aware of the risks and potential consequences of damage if they don't take care then I don't see a problem. If not prepared to accept those risks; simply don't do it!

Quote from abishur on October 30, 2011, 19:10
For added protection, you could even throw a cheap voltage regulator in the mix to make sure the computer PSU doesn't spike and send more than 5V... but it should already have that kind of protection built in, or else you'd have to worry about every device in your computer that used 5V.

The main advantage of going via a regulator is that any accidental short on the R-Pi 0V/5V should shut down the regulator, rather than short the PC's PSU 0V/5V, which can be a bit catastrophic as well as producing a lot of smoke!

User avatar
abishur
Posts: 4477
Joined: Thu Jul 28, 2011 4:10 am
Location: USA
Contact: Website

Re: [issue: host vs device] sshing into *and* powering the Pi with a single USB cable.

Mon Oct 31, 2011 12:01 am

My main concern with leaving the pins touching the PCB is that it might be used as a universal ground and it's just good practice ;)

You're concerns are 100% valid, I was definitely addressing just the OP situation, for all other situations you would need to use some common sense! In his case it's a crossover cable going from the PC directly to the r-pi so cutting the pins would be sufficient to isolate it. And I suppose since the r-pi has voltage protection you wouldn't really have to worry about over voltage now that I think about it.

Since PoE isn't possible with the first revision the r-pi, you shouldn't be able to power via the LAN and the power port that looks like a micro usb port, the point is to "hack" the ethernet to send power down the unused lines and then jump them over the power port internally so you only visibly see one cable ;)
Dear forum: Play nice ;-)

tufty
Posts: 1456
Joined: Sun Sep 11, 2011 2:32 pm

Re: [issue: host vs device] sshing into *and* powering the Pi with a single USB cable.

Mon Oct 31, 2011 8:30 am

Not to mention that an Ethernet cable is locked, so there's less chance of "Ram Pack Wobble" occurring on a teensy-tiny not-locked power connector.

Simon

obarthelemy
Posts: 1399
Joined: Tue Aug 09, 2011 10:53 pm

Re: [issue: host vs device] sshing into *and* powering the Pi with a single USB cable.

Mon Oct 31, 2011 8:45 am

My take on it is, why bother hacking a single cable if, inside, it turns out to really be 2 very distinct sets of cables, set 1 going from A to B (in this case, from ethernet data on the PC to ethernet data on the Pi), and set 2 going from an entirely different C to an entirely different D (in this case, from USB power on the PC or power brick to microUSB power on the Pi).
My initial proposal tried to have the PC side in common for both sets. Can't work... I will get 2 separate cable and knot them together. With red ribbons and nice bow ties.
But you guys *can* have your fun ^^

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

Re: [issue: host vs device] sshing into *and* powering the Pi with a single USB cable.

Mon Oct 31, 2011 1:54 pm

Quote from obarthelemy on October 31, 2011, 08:45
My take on it is, why bother hacking a single cable if, inside, it turns out to really be 2 very distinct sets of cables

It really depends on how one is using the R-Pi. I flood-wired my house for RJ45 connections so it's very handy to have the R-Pi next to the TV with a one cable connection to the wall socket and the PSU in the other room where the patching is done. Especially as that saves having to find a spare socket near the TV to plug a PSU in.

It is more aesthetics and convenience than anything else, so nothing wrong with two or more cables tie-wrapped or gaffer-taped together.

Return to “Other projects”