Page 1 of 1

USART with DMA pauses after receiving 2048 bytes

Posted: Fri Dec 16, 2016 8:40 pm
by cajjed
I have a samda5d36 running debian linux kernel 4.1.10 which is running two serial ports, bluetooth low energy, and several other peripherals so I was occasionally missing a byte on my serial lines. Thus I have tried implementing DMA by turning off i2c and SPI DMA so that I would have room for the USARTs:

Code: Select all

			usart1: serial@f0020000 {
				pinctrl-0 = <&pinctrl_usart1 &pinctrl_usart1_rts_cts>;
				atmel,use-dma-rx;
				atmel,use-dma-tx;
				status = "okay";
			};

			usart2: serial@f8020000 {
				pinctrl-0 = <&pinctrl_usart2 &pinctrl_usart2_rts_cts>;
				atmel,use-dma-rx;
				atmel,use-dma-tx;
				status = "okay";
			};
I had to adjust the stty by turning off ECHO and ONLCR to get my loopback to work normally.

stty -F /dev/ttyS2 -echo -onlcr

The problem is after receiving 2048 bytes the USART just stops receiving until I restart the USART.

I am just sending bytes from a file to /dev/ttyS2

cat testLines > /dev/ttyS2

and then

cat < /dev/ttyS2

Here is my current stty configuration

Code: Select all

stty -F /dev/ttyS3 -a   
atmel_usart f8020000.serial: using dma1chan6 for rx DMA transfers
atmel_usart f8020000.serial: using dma1chan7 for tx DMA transfers
speed 9600 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 -hupcl -cstopb cread -clocal -crtscts
-ignbrk brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl -ixon -ixoff
-iuclc -ixany imaxbel -iutf8
opost -olcuc -ocrnl -onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten -echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke
Any insight on what might be causing this?

Re: USART with DMA pauses after receiving 2048 bytes

Posted: Mon Dec 19, 2016 8:26 pm
by blue_z
cajjed wrote:The problem is after receiving 2048 bytes the USART just stops receiving until I restart the USART.
How do you "restart" a USART?
cajjed wrote:Any insight on what might be causing this?
Your contrived test (with deferred read) requires input buffers with infinite capacity.
You could be saturating the line discipline buffer, although it's typically 4KB.

Regards

Re: USART with DMA pauses after receiving 2048 bytes

Posted: Mon Dec 19, 2016 9:08 pm
by cajjed
Thanks for the reply, restarting just means that I ctrl-c the cat < /dev/ttyS2 and restart it.

Further play has shown me that it doesn't halt at 2048 bytes but after the first 2048 bytes it will only output 2048 bytes at a time?

Also I run the cat < /dev/ttyS2 in one terminal and then run the cat testFile > /dev/ttyS2 in another terminal. I also see the same results if I use a different serial port (say /dev/ttyS3).

Re: USART with DMA pauses after receiving 2048 bytes

Posted: Tue Dec 20, 2016 1:10 am
by cajjed
So I updated to kernel 4.8.12 and mostly left the configuration file default as found in /arch/arm/config and that fixed the issue. So not sure if it is the kernel or a configuration file related to DMA?