iMX7 CAN bus doesn't work properly

Hello,
I have a custom board. I enabled flexcan1 and flexcan2 on iMX7. after trying to send and receive CAN message, I found that some of the data got missed. I have tried different Pad Control register setting and even updated CAN driver to linux kernel 4.20(I use linux- toradex branch toradex_4.9-2.3.x-imx which its CAN driver is old. ) but nothing has changed.

pinctrl_flexcan2: flexcan2-grp {
 		fsl,pins = <
-			MX7D_PAD_GPIO1_IO14__FLEXCAN2_RX	0x79 /* SODIMM 188 */
-			MX7D_PAD_GPIO1_IO15__FLEXCAN2_TX	0x79 /* SODIMM 178 */
+			MX7D_PAD_I2C3_SCL__FLEXCAN2_RX		0x59 /* SODIMM 81 */
+			MX7D_PAD_I2C3_SDA__FLEXCAN2_TX		0x59 /* SODIMM 94 */ // tried with 79, 59, 39, 3b
 		>;
 	};  

always some of my messages get missed. even I connected the CAN BUS Analyzer directly to CAN TX pin.
the CAN baud rate is 1 Mbit/s.

when other nodes send message I receive them without any misses.

yes, CAN bus is properly terminated with a 120 ohm resistor.

hi @nmarandi

always some of my messages get missed. even I connected the CAN BUS Analyzer directly to CAN TX pin. the CAN baud rate is 1 Mbit/s.

Did you see that the messages are missed on the TX pin?
Do you have the same behaviour regardless the SODIMM Pins you are using?

Could you provide a dmesg log and maybe a test code that to you used for your test setup?

Thanks and best regards,
Jaski

Hi @nmarandi!

Is your CAN bus properly terminated with a 120 ohm resistor?

I’ve seen the lack of the termination resistor lead to such issues, specially at higher baud rates.

I tested both CAN buses with a baud rate of 1 Mbit/s and a baud rate of 800 Kbit/s. in 800 Kbit/s, one of the buses works fine. in 1 Mbit/s, both of buses miss the message in sending. link text

I send a dmesg log and my test code. you can use it like this

./Can_Tester /address/to/file

pinctrl_flexcan2: flexcan2-grp {
 		fsl,pins = <
-			MX7D_PAD_GPIO1_IO14__FLEXCAN2_RX	0x79 /* SODIMM 188 */
-			MX7D_PAD_GPIO1_IO15__FLEXCAN2_TX	0x79 /* SODIMM 178 */
+			MX7D_PAD_I2C3_SCL__FLEXCAN2_RX		0x59 /* SODIMM 81 */
+			MX7D_PAD_I2C3_SDA__FLEXCAN2_TX		0x59 /* SODIMM 94 */
 		>;
 	};

pinctrl_flexcan1: flexcan1-grp {
 		fsl,pins = <
-			MX7D_PAD_ENET1_RGMII_RD3__FLEXCAN1_TX	0x79 /* SODIMM 55 */
-			MX7D_PAD_ENET1_RGMII_RD2__FLEXCAN1_RX	0x79 /* SODIMM 63 */
+			MX7D_PAD_ENET1_RGMII_RD3__FLEXCAN1_TX	0x59 /* SODIMM 55 */
+			MX7D_PAD_ENET1_RGMII_RD2__FLEXCAN1_RX	0x59 /* SODIMM 63 */
 		>;
 	};

thanks.

Hi @nmarandi

Thanks for the files. I tested your code and could not find any errors.
Regarding the dmesg log, I saw there is some misconfiguration regarding the devicetree. Could you have a look here to delete the IoMux errors.

Thanks and best regards,
Jaski

I fixed the IoMux error according to the link you sent for me. but nothing about the CAN problem changed. you can download new dmesg log from
link text

can you help me with this error? what is it? can it be the cause of my problem?

[    0.178057] 30a00000.can supply xceiver not found, using dummy regulator
[    0.178911] flexcan 30a00000.can: device registered (reg_base=f5a00000, irq=59)
[    0.179065] 30a10000.can supply xceiver not found, using dummy regulator
[    0.179796] flexcan 30a10000.can: device registered (reg_base=f5a10000, irq=60)

thanks.

Perfect, that you fixed IoMux errors.
You can ignore the messages above.

Have you terminated your CAN Line on both ends?
What is the length of the CAN cable?

Hi there,
sorry for late answering. I found the problem. it was the receiver that misses a CAN-BUS receive interrupt.
many thanks for your helping.

Perfect that it works. Thanks for your feedback.

how the receiver that misses a CAN-BUS receive interrupt? can you give me the solution because i have the same problem

I don’t remember now. it was around 4 years ago. sorry :slightly_smiling_face:

Hi @aymen !

Please create a now thread sharing information about your current setup so we can help you:

  • Module (full name and version)
  • Carrier board (full name and version)
  • OS used (with version)
  • Hardware setup (possibly with a electronics schematic)

I am closing this thread as this is too old :slight_smile:

Best regards,