L.A.S.
Posts: 3
Joined: Sun Nov 15, 2015 12:31 pm

[SOLVED] Issue on UART (via FTDI USB <--> RS-232 adapter)

Sun Nov 15, 2015 1:07 pm

Hi Forum.

I'm trying to establish a high speed UART communication. Since ttyAMA0 is not quite good at 1+ Mbaud, decided to use FTDI adapter (based on FT232RL chip) instead.
I've tested an adapter on my laptop running Debian 8 and reached stable transmission speed at 3 Mbaud (with a cat * >> /dev/ttyUSB0).
Then plugged it to Pi2 doing exactly the same, and noticed this:
Image
(at 3 Mbaud)

Image
(at 1 Mbaud)

There are wide (up to 1 second at 3 Mbaud) gaps in transmission at regular time intervals. Transmitting data is not corrupted, just delayed.
Any suggestion on how to overcome a problem? Thank you.
Last edited by L.A.S. on Fri Nov 20, 2015 8:22 pm, edited 1 time in total.

sprinkmeier
Posts: 410
Joined: Mon Feb 04, 2013 10:48 am
Contact: Website

Re: Strange issue on UART (via FTDI USB <--> RS-232 adapter)

Mon Nov 16, 2015 11:21 am

at that speed, what's wrong with ethernet?

anything interesting from dmesg? top? iotop?

is the bottleneck the UART or the rate at which you can "cat *"
does

Code: Select all

( while true ; do cat /etc/hosts ; done ) >> /dev/ttyUSB0
go any faster (i.e. the same file over and over out of cache rather than new bits puled off disk)

L.A.S.
Posts: 3
Joined: Sun Nov 15, 2015 12:31 pm

Re: Strange issue on UART (via FTDI USB <--> RS-232 adapter)

Mon Nov 16, 2015 7:40 pm

Thanks for your reply.
sprinkmeier wrote:at that speed, what's wrong with ethernet?
Recieving side works with serial signal, that's the reqirement.
sprinkmeier wrote: is the bottleneck the UART or the rate at which you can "cat *"
does

Code: Select all

( while true ; do cat /etc/hosts ; done ) >> /dev/ttyUSB0
go any faster (i.e. the same file over and over out of cache rather than new bits puled off disk)
No, gaps stay the same. Also tried

Code: Select all

dd if=/dev/zero of=/dev/ttyUSB0 bs=1M
line – no difference.
sprinkmeier wrote:anything interesting from dmesg? top? iotop?
Nothing. Almost no load, no disk usage.

jdb
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2164
Joined: Thu Jul 11, 2013 2:37 pm

Re: Strange issue on UART (via FTDI USB <--> RS-232 adapter)

Mon Nov 16, 2015 9:52 pm

Try adding

Code: Select all

dwc_otg.nak_holdoff=2
to /boot/cmdline.txt.

At high baud rates, you may hit the USB NAK packet throttle threshold on outbound data - we have a crude mechanism implemented to stop FTDI devices from causing interrupt storms that lock the CPU out for extended periods of time. You can probably live with the increased interrupt rate on a Pi2 that comes from reducing the throttle interval.

There's an ultimate limit that you reach even with the NAK holdoff disabled - due to the way that we stage USB split transactions, you can stream a maximum of ~5mbit/s per full-speed device.
Rockets are loud.
https://astro-pi.org

L.A.S.
Posts: 3
Joined: Sun Nov 15, 2015 12:31 pm

Re: Strange issue on UART (via FTDI USB <--> RS-232 adapter)

Fri Nov 20, 2015 8:22 pm

After disabling NAK holdoff it works perfect at 3 Mbaud.

Thank you!

Return to “Troubleshooting”