MCP2518FD Rx buffer overflow on imx8mm

cancel
Showing results for 
Search instead for 
Did you mean: 

MCP2518FD Rx buffer overflow on imx8mm

141 Views
MaxL
Contributor I

I develop a project using the imx8mm chip running Linux 4.19. The chip has no CAN controller so we use a SPI to CAN converter Microchip MCP2518FD. It is connected via SPI and one interrupt GPIO. The interaction between imx8 and mcp2518 is driven by that GPIO interrupt (for example, the GPIO pin is asserted when there's new data in Rx buffer).

I have a strange issue. The kernel log often says that mcp2518 Rx buffer gets overlowed and ifconfig shows a significant number of rx errors on can0 interface. While investigating the issue, I noticed that the number of errors highly depends on the load of imx8 core 0.

- When core 0 load is low, the rx error rate goes up to 6%.
- When core 0 load is 100%, there are no rx errors. For testing purposes, I used a script that creates a dummy load on core0 (continious archiving of a file or continios reading of /dev/random).

It looks very strange, that loading the main core fixes the issue. I suppose that some interrupts are missed or processed with delay due to wait or sleep mode of the CPU. And creating a dummy load prevents the CPU from entering such modes.

Could you suggest any ideas on how to make SPI or interrupt GPIO work reliable at low CPU load?

Labels (1)
0 Kudos
2 Replies

92 Views
nxf54947
NXP TechSupport
NXP TechSupport

Hi @MaxL,

It seems that the GPIO interrupt priority might not be handled correctly by the processor. Have you tried to use the spidev utility?

https://www.kernel.org/doc/Documentation/spi/spidev

I hope this helps!

Ruben

0 Kudos

74 Views
MaxL
Contributor I

Hi @nxf54947,

Thank you for response. The MCP2518 uses the kernel space driver linux-imx/drivers/net/can/spi/mcp251x.c and is available as "can0" network interface. I haven't tried to implement custom driver but I feel that user space driver might be  a bad choice. We also tried to backport the driver from the latest mainline kernel but the rx overlow is still there.

0 Kudos