How to implement DMA UART in AT91SAM9G25

Discussion around AT91RM9200 and SAM9 Series Products.

Moderator: nferre

maohong
Posts: 4
Joined: Fri Feb 22, 2019 5:36 pm

How to implement DMA UART in AT91SAM9G25

Fri Feb 22, 2019 6:04 pm

Hi
I have a question recently.
When I use serial communication, the serial port communication probability fails due to the disconnection and connection of the external usb device(option serial device). The phenomenon is: TTY _OVERRUN ERROR, so I decided to configure the DMA mode serial port.

My kernel version is 2.6.39, I look at the relevant code, I feel relatively simple, modify the code as follows:

static struct atmel_uart_data uart0_data = {
.use_dma_tx = 1,
.use_dma_rx = 1,
};

It was found through testing that the DMA UART TX is normal, but RX cannot receive data. Although there is no data, a receive interrupt can be generated each time.

Since the way the dma is sent and received is different, how do I debug it next? Or can you advise how to configure the enable DMA UART?

extremely grateful!
blue_z
Location: USA
Posts: 1959
Joined: Thu Apr 19, 2007 10:15 pm

Re: How to implement DMA UART in AT91SAM9G25

Sat Feb 23, 2019 12:55 am

maohong wrote: I decided to configure the DMA mode serial port.

My kernel version is 2.6.39,
You need to diff your board file with what is currently in the github 2.6.39-at91 branch.
Looks like the source was patched in February 2013 to configure DMAC support for the SAM9x5 serial ports.

Regards
maohong
Posts: 4
Joined: Fri Feb 22, 2019 5:36 pm

Re: How to implement DMA UART in AT91SAM9G25

Sat Feb 23, 2019 3:46 pm

Hi blue_z,
The board configuration (at91sam9x5_devices.c) has been compared to the GitHub 2.6.39 code, which is basically the same.

When I use DMA to receive data from the serial port, I added some logs for debugging. I found that the function atmel_rx_from_dma() can be called, but the log shows pending=0, ring->head=0, sg_dma_len(&atmel_port->sg_rx) =4096, State.residue=4096, the status of dmastat is DMA_IN_PROGRESS, obviously no serial port data is received. I don't understand why the interrupt has been received, but the DMA does not start receiving serial data.

How should I debug next?

Best Regards
blue_z
Location: USA
Posts: 1959
Joined: Thu Apr 19, 2007 10:15 pm

Re: How to implement DMA UART in AT91SAM9G25

Wed Feb 27, 2019 1:52 am

maohong wrote: How should I debug next?
Don't know.
FWIW I cannot replicate your issue with 2.6.39-at91 with UART0 as a fifth serial port on a SAM9x35-EK. DMA transfers seem to be functioning as expected.

Regards
maohong
Posts: 4
Joined: Fri Feb 22, 2019 5:36 pm

Re: How to implement DMA UART in AT91SAM9G25

Wed Feb 27, 2019 4:29 am

Hi blue_z,
Thank you for your reply.
Maybe because the code is old, it can't be debugged ok,I compared the uart driver of github 2.6.39 and the problem was solved.

Unfortunately, new problems arise.
Our project needs to enable 7 serial ports,There is an error occured。
log is as follows:

TX channel not available, switch to pio
RX channel not available, switch to pio
No channel available
Switch to PIO


Why does the DMA channel fail to apply?
blue_z
Location: USA
Posts: 1959
Joined: Thu Apr 19, 2007 10:15 pm

Re: How to implement DMA UART in AT91SAM9G25

Wed Feb 27, 2019 6:24 am

maohong wrote: There is an error occured。
log is as follows:

TX channel not available, switch to pio
RX channel not available, switch to pio
No channel available
Switch to PIO
Do not report error messages out of context.
What are the surrounding messages?

maohong wrote: Why does the DMA channel fail to apply?
You will probably have to insert printk() statements to various drivers in order to resolve the exact cause.


Regards
nferre
Site Admin
Posts: 205
Joined: Wed Feb 14, 2007 11:17 am

Re: How to implement DMA UART in AT91SAM9G25

Thu Feb 28, 2019 11:43 am

Hi,

It can be caused by mainly 2 reasons (except if it's a bug):
1/ DMA property not well defined or missing in USART DT node or DMA not enabled by using atmel,use-dma-tx/atmel,use-dma-rx properties
2/ No DMA channel remaining and able to be assigned to this USART interface

For the 2nd case, remove some DMA channels assignment to other drivers and see if channels are taken by your USART then.

Best regards,

Return to “SAM9 ARM9 MPU”

Who is online

Users browsing this forum: No registered users and 5 guests