linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* USB multi-serial using few endpoints?
@ 2020-11-13 13:07 Geert Uytterhoeven
  2020-11-13 14:37 ` Johan Hovold
  0 siblings, 1 reply; 3+ messages in thread
From: Geert Uytterhoeven @ 2020-11-13 13:07 UTC (permalink / raw)
  To: Johan Hovold, Bin Liu, Felipe Balbi
  Cc: Kevin Hilman, Kieran Bingham, USB list

Hi all,

TL;DR: I'm looking for a USB-to-multi-serial solution that uses as few
USB endpoints as possible.  Anyone with a good suggestion?

Full description:

I have a board farm that is controlled by a single BeagleBone Black.
Serial consoles are connected to the boneblack using USB: most
contemporary boards have on-board USB serial console (cp210x/ftdi_sio/
cdc_acm), some still rely on external USB-to-serial convertors.
I also have a USB webcam, to keep an eye on a board's display.
For power control, I use BayLibre ACME[1].
As I ran out of channels on the ACME, I designed my own board[2] to add
more power channels, including two serial ports and opto-isolated
outputs.  Each bcu2 board has a Teensy 3.2, which connects to the
boneblack using USB, providing 3 USB-serial ports (one interactive
control channel, two for the two physical serial ports, using cdc_acm).

Unfortunately the musb USB host controller on am335x is limited to 16
endpoints.  If no free endpoint is available, the dreaded

    musb-hdrc musb-hdrc.1: int hwep alloc failed for 1x1

message is printed (only on v4.13 and newer).
As I understand EP0 and EP1 are reserved, and one extra endpoint is
reserved for multiplexing bulk transfers, this means 13 endpoints are
available for "locked" use by drivers.

By looking at bNumEndpoints in the lsusb output, and by adding debug
code to the musb_host driver, I derived the following endpoint use by
various usb drivers:
  - cp210x: 2 endpoints per serial port (1 locked when in use),
  - ftdi_sio: 2 endpoints per serial port (1 locked when in use),
  - cdc_acm: 3 endpoints per serial port (2 locked when in use),
  - mos7840: 9 endpoints for 4 serial ports (up to 4 locked when in use),
  - spca561: 1 endpoint per camera (1 locked when in use).

As you see, cdc_acm seems to be the worst way to provide a USB serial
port, as each port needs 2 "locked" endpoints.  That means each bcu2
board needs 6 locked endpoints, and I cannot use (at the same time) more
than 2 bcu2 boards connected to a single boneblack.

While I cannot replace USB-serial convertors on development boards, I
can replace the USB serial implementation on the Teensy.  Hence I'm
looking for a more efficient USB-multi-serial protocol (preferably one
that has a Linux driver), using as few endpoints as possible.
I'm not a USB expert, but If I'm not mistaken, an N-port
USB-multi-serial adapter could be implemented using only 2 or 3
endpoints (one "locked" input endpoint for signalling, and one (TX/RX
combined) or two (TX and RX separated) multiplexed endpoints for data)?

If no such thing exists, I guess I can use the mos7840 protocol instead?
Or is there a better solution?

Thanks for your comments!

[1] https://baylibre.com/acme/
[2] https://github.com/geertu/pcb-bcu2

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: USB multi-serial using few endpoints?
  2020-11-13 13:07 USB multi-serial using few endpoints? Geert Uytterhoeven
@ 2020-11-13 14:37 ` Johan Hovold
  2022-12-16 15:05   ` Geert Uytterhoeven
  0 siblings, 1 reply; 3+ messages in thread
From: Johan Hovold @ 2020-11-13 14:37 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Johan Hovold, Bin Liu, Felipe Balbi, Kevin Hilman,
	Kieran Bingham, USB list

On Fri, Nov 13, 2020 at 02:07:41PM +0100, Geert Uytterhoeven wrote:
> Hi all,
> 
> TL;DR: I'm looking for a USB-to-multi-serial solution that uses as few
> USB endpoints as possible.  Anyone with a good suggestion?

Moxa has a device with 16 ports that only use three endpoints; see the
mxuport driver.

> While I cannot replace USB-serial convertors on development boards, I
> can replace the USB serial implementation on the Teensy.  Hence I'm
> looking for a more efficient USB-multi-serial protocol (preferably one
> that has a Linux driver), using as few endpoints as possible.
> I'm not a USB expert, but If I'm not mistaken, an N-port
> USB-multi-serial adapter could be implemented using only 2 or 3
> endpoints (one "locked" input endpoint for signalling, and one (TX/RX
> combined) or two (TX and RX separated) multiplexed endpoints for data)?

Right, you'd (typically) need two bulk endpoints for tx and rx. The Moxa
protocol use a third for signalling events. (And USB devices always have
a control endpoint, which I don't count here).

> If no such thing exists, I guess I can use the mos7840 protocol instead?
> Or is there a better solution?

You can always roll your own minimal mux protocol in case the moxa one
is too complex (and we may want to keep an alternative implementation
separate for other reasons).

And then there's the n_gsm line discipline...

Johan

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: USB multi-serial using few endpoints?
  2020-11-13 14:37 ` Johan Hovold
@ 2022-12-16 15:05   ` Geert Uytterhoeven
  0 siblings, 0 replies; 3+ messages in thread
From: Geert Uytterhoeven @ 2022-12-16 15:05 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Bin Liu, Felipe Balbi, Kevin Hilman, Kieran Bingham, USB list,
	Andrew Lunn, Paul Stoffregen

Hi Johan,

CC Andrew (mxuport), Paul (Teensy)

On Fri, Nov 13, 2020 at 3:37 PM Johan Hovold <johan@kernel.org> wrote:
> On Fri, Nov 13, 2020 at 02:07:41PM +0100, Geert Uytterhoeven wrote:
> > TL;DR: I'm looking for a USB-to-multi-serial solution that uses as few
> > USB endpoints as possible.  Anyone with a good suggestion?
>
> Moxa has a device with 16 ports that only use three endpoints; see the
> mxuport driver.

Thank you, that was exactly what I was looking for!

> > While I cannot replace USB-serial convertors on development boards, I
> > can replace the USB serial implementation on the Teensy.  Hence I'm
> > looking for a more efficient USB-multi-serial protocol (preferably one
> > that has a Linux driver), using as few endpoints as possible.
> > I'm not a USB expert, but If I'm not mistaken, an N-port
> > USB-multi-serial adapter could be implemented using only 2 or 3
> > endpoints (one "locked" input endpoint for signalling, and one (TX/RX
> > combined) or two (TX and RX separated) multiplexed endpoints for data)?
>
> Right, you'd (typically) need two bulk endpoints for tx and rx. The Moxa
> protocol use a third for signalling events. (And USB devices always have
> a control endpoint, which I don't count here).
>
> > If no such thing exists, I guess I can use the mos7840 protocol instead?
> > Or is there a better solution?
>
> You can always roll your own minimal mux protocol in case the moxa one
> is too complex (and we may want to keep an alternative implementation
> separate for other reasons).

That's what Kevin suggested at last ELCE, too.  The main disadvantage
is that it needs its own driver, and thus doesn't work with any existing
(old) kernel.

Finally I managed to find to time to implement and deploy this, and
it's been working fine in my board farm for the last 2 months.
As this is not Linux-specific, but Teensy-specific, I like to direct
the interested people to the Teensy forum:
https://forum.pjrc.com/threads/71684-A-better-multi-serial

Thanks again!



Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-12-16 15:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-13 13:07 USB multi-serial using few endpoints? Geert Uytterhoeven
2020-11-13 14:37 ` Johan Hovold
2022-12-16 15:05   ` Geert Uytterhoeven

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).