# Connect Via USB Cable



## jcw (Nov 17, 2021)

I have been reading through Chapters 26 and 27 on serial connections. I must be missing something. I'll ask what seems like a very basic question.

Can I connect one FreeBSD computer to another via a USB ports and a plain jane USB cable and obtain shell access? Do I need a special adapter or a "null modem" USB cable if there is such a thing?

Sounds like a serial console to me. Seems like I am reading the right docs. When I attempt cu(1) on the I get "link down".  /dev/cuaU0 is not created automagically as I expect.

Regards,
Jason C. Wells


----------



## Geezer (Nov 17, 2021)

/boot/loader.conf
`boot_serial="YES"
comconsole_speed="whatever"
comconsole_port="whatever"
console="comconsole"`

You can use the serial console, but if you merely want shell access, why not connect the two boxes with a network cable?


----------



## jcw (Nov 17, 2021)

I don't want shell access. That is just a side effect.  What I want is a terminal connection via USB for its own sake. I plan to use the knowledge gained for other things.

The above settings apply on the destination/remote system and are in place.

On the source/local system the system  doesn't even spawn the special device /dev/cuaU0.


----------



## ralphbsz (Nov 17, 2021)

No, in most cases you can not.

What happens with USB is that that there are USB "computers" and USB "peripherals", I think officially they're called "host" and "device"; the nomenclature "master" and "slave" is today considered offensive, but is still found in the literature. A peripheral may be a memory stick (disk), or a keyboard, or a USB -> serial adapter. The whole USB protocol is built around being terribly one-sided, connecting one or more peripherals to a computer. Remember, in the early days of USB, there were even different connectors: the longer and flatter A connector and computers, and the more square B connector (which today you can only find on old-fashioned USB printers). Today many cables are still asymmetric (there is mini-A and mini-B and micro-A and micro-B), but most devices have dual connectors that can take both cables. Only with USB-C has the cable become symmetric.

Highly correlated with this asymmetry is power delivery: The computer sends power to the peripheral; that's so things like USB mice and keyboards and hubs work.

But fear not, today there is something that fixes this. It's called USB on-the-go, also known as OTG. It allows a "computer" device to pretend to be a "perhipheral". Cell phones use it all the time: most of the time, they pretend to be a peripheral, getting power (usually from a wall adapter). But if you plug a USB stick (disk) into a cell phone, it switches roles and starts being the computer. And conversely, if you plug the cell phone into a computer it may pretend to be a mass storage device (disk) itself, so you can browse the pictures stored on the cell phone as if it were a camera.

Now the question is: Are normal computers (with normal BIOSes) capable of performing OTG, and can they pretend to be a serial port (really a serial-to-USB adapter) and use that serial port as the console? No, most are not.

There is a rare exception I know of: The Raspberry Pi 0 is capable of being booted into being either a Ethernet or serial converter. This can be used to download code onto it or debug it. I think it's called "gadget mode" in Raspberry Pi land.

I know of no other common computer that can turn its USB ports into devices. And I don't know whether the Pi zero is capable of doing "gadget mode" when running FreeBSD (it involves some magic interaction between the BIOS and Linux drivers).


----------



## oOiOo (Nov 17, 2021)

jcw said:


> Can I connect one FreeBSD computer to another via a USB ports and a plain jane USB cable and obtain shell access? Do I need a special adapter or a "null modem" USB cable if there is such a thing?



As far I know, it does not exist. You can use two USB to Serial adapter (one per computer) with a standard "null modem" cable in beetween  or two USB to uart adapter (aka USB TTL adapter ) connected as follow:


```
tx ------------------------> rx
        rx <------------------------ tx
        gnd ----------------------- gnd
```


----------



## covacat (Nov 17, 2021)

console and ethernet over usb work on freebsd on pi zero
but the pi zero has otg capabilities, can act as host / device


----------

