Serial communication fails when app uses ttyUSB

Hi,

We’ve built a custom board with an FTDI chip FT2232D to create 2 serial ports.
Our IOT slot, our LAN9512 chip and the FTDI chip are connected to an USB3503 USB hub (same one as on the mangOH Green board).
I’ve tested my custom Legato build 18.04 on the custom board with WP8548 and WP7607 targets.

At startup ftdi_sio gets loaded and creates ttyUSB0 and ttyUSB1.
The target console shows ‘usb 1-1.3: Detected FT2232C’ while the board is stuffed with an FT2232D chip.

The serial communication works in both directions without any problem when I use microcom on /dev/ttyUSB0 and /dev/ttyUSB1.
But, when I try to use these devices in my app, the serial communication doesn’t work.

My application uses le_tty API calls to configure the serial port and there is an fdMonitor with a serial port handler function.
None of these le_tty calls return an error in the application log, but, when I run dmesg in the target console,
I get messages like below :
ftdi_set_termios FAILED to set databits/stopbits/parity
ftdi_set_termios urb failed to set baudrate
urb failed to clear flow control
clear tt 3 (0040) error -71

Each time my handler function sends 5 characters to the serial port, I get
clear tt 3 (1042) error -71

I don’t understand why the le_tty calls don’t return errors, while the target console shows a lot of issues.
Any advice on this?

Greetings,
annaertd

dmesg (6.4 KB)

Hi,

Do you have the correct requires/device section in your adef file?
https://docs.legato.io/latest/defFilesAdef.html#defFilesAdef_requiresDevice

Jay

The .adef file contains
requires:
{
device:
{
[rw] /dev/ttyUSB0 /dev/ttyUSB0
}
}

I tried to remove this device for fun, and then I got an error at startup of my application:

le_tty_Open() 231 | Error opening serial device ‘/dev/ttyUSB0’: No such file or directory

From your dmesg log, we can see several errors:
usb 1-1: clear tt 3 (0040) error -71

Error -71 == -EPROTO

From <kernel>/Documentation/usb/error-codes.txt:

-EPROTO (*, **)
a) bitstuff error
b) no response packet received within the prescribed bus turn-around time
c) unknown USB error
( * ) Error codes like -EPROTO, -EILSEQ and -EOVERFLOW normally indicate hardware problems such as bad devices (including firmware) or cables.

Do you try with unsandboxed apps? I use ft232 without any problem.

Francis.

Hi @JayM2M,
we already checked the explanation of -EPROTO, but, we don’t know how to debug this issue.
My le_tty API calls never return errors, and the serial communication works fine via microcom.
Any idea why the legato system and app would behave different than microcom?
Greetings,
annaertd

Hi @FrancisDuhaut,
working with an unsandboxed app didn’t solve the issue.

Are you using le_tty API and the ftdi_sio driver, or, are you using FT_ API calls with the D2XX Direct drivers?

Greetings,
annaertd

Hello

I use standard posix code and ftdi_sio driver.
Send me your email in private I will send you sample code.

Francis.

https://source.sierrawireless.com/resources/legato/howtos/customizeuart/

Did you select your UART to be shared to Legato application?

Issue was caused by a bad reset of the USB hub chip where our FTDI chip was connected to.
We fixed this, and now, my application has serial communication using the le_tty API with /dev/ttyUSB0 and /dev/ttyUSB1 without any problem.

If the USB hub chip got a reset after startup of the application, le_tty API didn’t show errors on /dev/ttyUSB0, although there were plenty of errors in the target console.
Even microcom still worked fine on /dev/ttyUSB0, which is very hard to understand.