i.MX6 DualLite Android 6 Flexcan receive problem

Showing results for 
Search instead for 
Did you mean: 

i.MX6 DualLite Android 6 Flexcan receive problem

Contributor III

Hello there, 

   Thank you for reading my problem first. I'm really grateful for that. Here is my problem with CANBus.

   I have followed the link below to implement CANBus. 

How to use FlexCAN in Android OS 

   However, it is not the best solution I think.  My scenario is two devices with CANBus. One is FTDI CANBus on Windows, another is i.MX6 Flexcan.  Both of them are 100k bitrate.

   I started transmitting over 10000 bytes data from FTDI CANBus to Flexcan. I used candump to printf the data I received. But the quantity of printf always less than transmitting.  

    I suspected the problem might be happened by the transmitting line. But the problem still happens after changing another line.

   Eventually, I found another method to check whether data loss or not. I used the command, cat /proc/net/dev/, to check the content of Receive and Transmit. Then it shows me there is no data loss in can0 interface and quantity of Receive Packets is correct!

   So I think the problem might happen due to using printf too frequently.  Is there anyone have this problem like me?

My problem only happens over 50k bitrate. If my bitrate equals 50k bitrate or less, everything will be fine.

Labels (1)
0 Kudos
2 Replies

Contributor III

jamesbone‌ Thank you for your reply. 

After getting your feedback. I started searching the latest driver of flexcan and canutils.

And finally, I found a solution to solve this problem.

Here are some links for reference:

Flexcan driver: Linux source code: drivers/net/can/flexcan.c (v4.19) - Bootlin 

canutils: GitHub - linux-can/can-utils: Linux-CAN / SocketCAN user space applications 

First, I porting the latest driver into my kernel. And compile the canutils into my source code.

Fortunately, everything is fine. I can have no data loss when using latest driver and canutils.

But it only worked when I ran the candump command.

After ensuring candump command had no problem, I started porting candump's code as hw_module. But I still found that had data loss. This is very depressing. 

Maybe the hw_module worked in JVM. And I think the performance of JVM is not better than running the candump command directly. 

I still keep thinking no matter how difficult it is.  After a few hours later. Here is an idea came out my mind. What would I have if I used the socket and send the data to Application directly?

Then I started adding socket into candump.c. And create a socket server in Android Application. 


Finally, it works. I can receive data without any data loss even I choose 1Mbps. 

I think hw_module should be worked. Maybe there is something problem but I don't know how so.

0 Kudos

NXP TechSupport
NXP TechSupport

Officially NXP don't support FlexCAN for Android. We do have a Driver for Linux for FLEXCAN but as you can see in the following thread, it is a very old driver that affects the performance of the Bus. 

i.MX6 Marsboard. FlexCan low performance 

Have a great day,

Note: If this post answers your question, please click the Correct Answer button. Thank you!

0 Kudos