9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] usb serial on raspberry pi (again)
@ 2016-10-27 10:40 Steve Simon
  2016-12-12 20:33 ` Richard Miller
  0 siblings, 1 reply; 6+ messages in thread
From: Steve Simon @ 2016-10-27 10:40 UTC (permalink / raw)
  To: 9fans

Hi,

I have upgraded my pi desktop to a 3 which is noticable faster.

I am using Richard's pi image which as usual works perfectly, but for one wrinkle.
I cannot get the usb serial interfaces we use to work. I have never managed to get
usb serial adapters to work with the raspberry pi, though never had problems on x86 boxen.

The device I have to use (it is integrated into our gear) identifies itself as:
	255 csp 0x0000ff vid 0x10c4 did 0xea60 'Silicon Labs' 'CP2102 USB to UART Bridge Controller' dwcotg
	ep6.1 enabled bulk rw speed full maxpkt 64 pollival 0 samplesz 0 hz 0 hub 2 port 4 busy

and is set up with:

	b115200 c0 d0 e0 l8 m0 pn r0 s1 i0
	dev(0) type(0)  framing(0) overruns(0) berr(0)  serr(0)

Text into the pi works fine, but outgoing text seems stalled until text is received,
I can type ahead and when I receive data the queued outgoing data is sent.

does this ring any bells with anyone?
any suggestions where to look in the usb serial code?

-Steve



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

* Re: [9fans] usb serial on raspberry pi (again)
  2016-10-27 10:40 [9fans] usb serial on raspberry pi (again) Steve Simon
@ 2016-12-12 20:33 ` Richard Miller
  2016-12-12 20:39   ` Richard Miller
  0 siblings, 1 reply; 6+ messages in thread
From: Richard Miller @ 2016-12-12 20:33 UTC (permalink / raw)
  To: 9fans

> I cannot get the usb serial interfaces we use to work. I have never managed to get
> usb serial adapters to work with the raspberry pi, though never had problems on x86 boxen.
> ...
>
> Text into the pi works fine, but outgoing text seems stalled until text is received,
> I can type ahead and when I receive data the queued outgoing data is sent.

Hi Steve -

I just had a look at this (as a bit of displacement activity from more
stressful tasks...).  First of all I dug out an old silabs usbserial
adapter and quickly confirmed that I see the same symptoms as you.
(I had never thought of using a serial dongle on a pi, since the
uart gpio pins have always served my purposes - I always connect
to FPGAs or other microprocessors which are happy with 3.3V)

By watching changes in the file descriptor r/w count in the 'ps' output
for the usbd subprocess, I could see that the first byte of data was
being written to the usb ep, but the write was hanging in the kernel
till the next read completion.  I noted that this particular dongle
uses the same ep number for both input and output, which is unusual
(and was never properly allowed for in the original design of plan 9 usb).

Next I looked in the bcm usb adapter driver (usbdwc.c) for possible
interference between reads and writes on the same ep number, and
the answer was glaringly obvious.  Each ep has a single Epio structure,
shared by read and write sides, with a QLock in it.  My failure of vision.

The fix isn't as obvious (to me) as the diagnosis.  Maybe it's as simple
as having separate read and write QLocks.  I need to study the code for
a while to assure myself that it's safe to do that.  I wrote it so long
ago that I frankly can't recall why there's a lock at all.

You're welcome to have a look too and offer suggestions!

-- Richard




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

* Re: [9fans] usb serial on raspberry pi (again)
  2016-12-12 20:33 ` Richard Miller
@ 2016-12-12 20:39   ` Richard Miller
  2016-12-13 10:06     ` Gorka Guardiola
  0 siblings, 1 reply; 6+ messages in thread
From: Richard Miller @ 2016-12-12 20:39 UTC (permalink / raw)
  To: 9fans

Oops, pressed the wrong button - that reply was intended for
Steve Simon and not the whole of 9fans.  Oh well, if anybody
else wants to rummage through the usbdwc driver too, they
are welcome.




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

* Re: [9fans] usb serial on raspberry pi (again)
  2016-12-12 20:39   ` Richard Miller
@ 2016-12-13 10:06     ` Gorka Guardiola
  0 siblings, 0 replies; 6+ messages in thread
From: Gorka Guardiola @ 2016-12-13 10:06 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

[-- Attachment #1: Type: text/plain, Size: 448 bytes --]

On Mon, Dec 12, 2016 at 9:39 PM, Richard Miller <9fans@hamnavoe.com> wrote:

> Oops, pressed the wrong button - that reply was intended for
> Steve Simon and not the whole of 9fans.  Oh well, if anybody
> else wants to rummage through the usbdwc driver too, they
> are welcome.
>


Thanks, because I had been looking at the silabs code and was puzzled
(I don't own a pi now for different reasons). Good to know you are on it
:-).

G.

[-- Attachment #2: Type: text/html, Size: 810 bytes --]

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

* Re: [9fans] usb serial on raspberry pi (again)
  2016-12-14 10:44 Richard Miller
@ 2016-12-15 11:15 ` Steve Simon
  0 siblings, 0 replies; 6+ messages in thread
From: Steve Simon @ 2016-12-15 11:15 UTC (permalink / raw)
  To: 9fans

Hi,

I have tried the usb->serial adapters I could find lying around the office.

Using the code you sent me, not the very latest from sources.

The FTDI chips we use in our products work fine
	ep13.0 255 csp 0x0000ff vid 0x10c4 did 0xea60 'Silicon Labs' 'CP2102 USB to UART Bridge Controller' dwcotg
These are Silabs cp2102 (https://www.silabs.com/Support%20Documents/TechnicalDocs/CP2102-9.pdf)

A cheap chinese, no-name FTDI adapter also works nicely
	255 csp 0xffffff vid 0x0403 did 0x6001 FTDI 'USB Serial Converter' dwcotg

I have a "Ugreen" branded prolific usb/serial adapter which also works, it is not autodetected
but running usb/serial creates and endpoint which works.
	ep12.0 255 csp 0x0000ff vid 0x067b did 0x2303 none <nil> dwcotg

I also have a dual channel prolific adapter and this doesn't work but I couldn't make it work with
windows either so its either very strange or baybe its just fried.
	ep6.0 hub csp 0x000009 ports 4 none <nil> dwcotg
	ep12.0 hub csp 0x000009 ports 4 none <nil> dwcotg

My USB network adapter is a KY-88772a (https://i.ytimg.com/vi/Hcy5f9c2TXE/maxresdefault.jpg)
which works quite well but seems to get confused somtimes and needs to be reset.

I have not worked out what provokes it but I think (educated guess only) entering
promiscuous mode makes it unhappy.

Thanks very much for all your help,

-Steve



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

* Re: [9fans] usb serial on raspberry pi (again)
@ 2016-12-14 10:44 Richard Miller
  2016-12-15 11:15 ` Steve Simon
  0 siblings, 1 reply; 6+ messages in thread
From: Richard Miller @ 2016-12-14 10:44 UTC (permalink / raw)
  To: 9fans

> Maybe it's as simple
> as having separate read and write QLocks.

For normal endpoints it is that simple.  Control endpoints, however,
are bidirectional but effectively half-duplex, so reads and writes
still need to be locked against each other.

Today's version of /n/sources/contrib/miller/9/bcm/usbdwc.c should
do the right things.




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

end of thread, other threads:[~2016-12-15 11:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-27 10:40 [9fans] usb serial on raspberry pi (again) Steve Simon
2016-12-12 20:33 ` Richard Miller
2016-12-12 20:39   ` Richard Miller
2016-12-13 10:06     ` Gorka Guardiola
2016-12-14 10:44 Richard Miller
2016-12-15 11:15 ` Steve Simon

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).