Serial over USB

I am looking for more information on running “Serial over USB” from a linux desktop host to the BBB device. Some information on the web seems out of date, at least on debian 7.7. other information is very helpful. I am summarizing here some of what I have learned myself first:

a sending desktop linux can send information to the BBB over /dev/ttyACM0.
a recipient BBB linux can receive information on /dev/ttyGS0 .
this is part of the g_multi kernel module and thus works out of the box on debian 7.7.

this can be tested as

bbb# cat /dev/ttyGS0

desktop# echo “hello” > /dev/ttyACM0

and the bbb should now echo “hello”. the comm is buffered, although I am not sure on which side (desktop or bbb). this is obvious from looking at the desktop immediately after a fresh boot:

desktop# cat /dev/ttyACM0

which will still return the log in information from the boot on the first use. after the buffer is full, the device blocks and waits.

information about the port settings can be found (and potentially set, though I don’t think anything is needed) with

stty -F /dev/ttyGS0 -a

however, I believe that some of this are just “pretend you are rs232” wrong. this is because I just wrote a little perl program that sends 1Mbyte into the device and then closes. this takes about 1.5 seconds. This would suggest a raw speed of about 7 Mbaud, a little bit faster than the 9.6 Kbaud that stty tells me. I am guessing that the “serial port over USB” uses the USB 1.1 “full-speed” protocol that caps out at 12 Mbaud. I believe hi-speed 480 Mbaud connections require block operations.

the serial comm speed is interesting to compare to the usb mass storage speed. A dd from the desktop host to the mounted BBB mass-storage device partition over USB produces 21 Mbaud. so, the serial connection is about 1/3 of what the BBB is capable of over hi-speed USB mass storage. the eMMC limits out at about 70Mbaud local, which is itself about three times the speed of the mass storage driver over the USB 2.0 connection. (and remember that USB 2.0 is itself limited to 480Mbaud. I also tried to measure the speed over the usb0 ethernet with dd and netcat [nc] to see how close this could get, but I failed.)

hope this helps.

  • one question: I have lost some information sent forth and back, which I believe is due to the bbb issuing (from /var/log/syslog) a
    serial-getty@ttyGS0.service.holdoff time over, scheduling restart
    is it possible to force ttyGS0 to always be available, and never to want to restart?

  • I may write a different driver that sits on top of the mass storage driver and communicates over a small shared storage area. it’s a crazy idea, but it could be faster than serial-over-usb if I know that I will be dealing in blocks of 512 bytes and relatively easy to debug and synchronize.

Never really tested g_serial speeds myself, but I can tell you that g_ether is better than 100Mbit. Somewhere around 170Mbit and even better for some people. So long as you use a real Linux host. Anyhow, my point is the hardware is fast enough.

I will say is that if your Linux desktop is actually in a Windows virtual machine, your performance issues have nothing to do with the BBB + software, and everything thing to do with the virtual machine + Windows.

USB 2.0 is actually 480Mbit

Nope. It’s linux on metal. An i3 HP Notebook.

I need to figure out how to benchmark throughput on usb0 network speed.

I used iperf, which is a package in debian

$ apt-cache search iperf

You can find realy simplified instructions on how to use it on youtube. Windows instructions but the commands should be exactly the same ( minus the *.exe bit ).

So my memory is not always that great with stuff like this ( that i hardly use )

Host side you would do somethign like “sudo iperf -s” - this starts a listening server - default port.

client side ( BBB ) you’d use “sudo iperf -C 192.168.7.x”

Once that test is done, you swap server to the BBB, and client to the host, etc . . . Anyway not sure sudo is necessary, i think it was for me but . . .memory fails. Just watch the video or find some decent text instructions to make sure what im saying here is correct . . .as I barely ever use this tool.

thanks, william. I first went an easier route. I did create a 16MB random file on the host desktop, and rcp’ed it to a ramdisk on the BBB over usb. I am getting about 4MB/sec. then I went the iperf route. your memory was excellent, except the -C switch for the client is -c. this also reports a bandwidth of about 30 Mbaud.

so, on my simple experiments (linux metal desktop, bbb rev c usb), here are my transfer speed comparisons (all in MBaud = MBit/s):

serial over usb : < 10
mass storage over usb : ~ 20
ethernet over usb : ~ 30-40

theoretical usb speed : ~ 480

local eMMC speed : ~ 70

I wonder if I can figure out how to send raw messages over USB with usb_bulk_msg() on the host without a higher level protocol (ethernet, usb mass storage, serial). has anyone written already a simple “echo” script for the BBB that just responds to usb_bulk_msg requests and prints summary info on the console?

is that part of the HID protocol ? I’ve read somewhere that is a bad idea . . . No hands on with it personally, but i do some reading from time to time because its an interest.

Anyways that’s really interesting you’re getting way worse speeds than mine. Also, I’ve noticed that most of the time even just sata / pata <-> usb 2.0 bridge chips rarely get above ~23MB/s average total throughput. Thats about half of theoretical, but we also need to consider the 8/10 bit protocol encoding . . .

Something else you may find interesting. The other USB port host I believe it is does ~20MB/s writes, and around 11MB/s read when connected to a USB HDD . . . thats reverse of what I’d expect, higher reads and lower writes . . .but there ya have it.